Skip to content
Client
Server

Reference / @open-music-sdk/core / optionsOf

Function: optionsOf() ​

ts
function optionsOf<T>(
   fn, 
   options, 
   what
): T;

Defined in: packages/core/src/check.ts:54

An options bag as this call's own: what the caller's object holds itself, and the empty bag when none was given. The types rule anything but a plain object out, and a caller without them can still pass it.

Type Parameters ​

T ​

T extends object

Parameters ​

fn ​

string

The name of the function the options were handed to, for the error.

options ​

T | undefined

What the caller gave, or undefined for nothing.

what ​

string

What the error says was expected, such as "an options object".

Returns ​

T

The options' own properties as a new object with no prototype; an empty one when options is undefined.

Throws ​

TypeError if options is neither undefined nor a plain object.

MIT licensed. Not affiliated with, endorsed by, or sponsored by Apple Inc. Apple Music and MusicKit are trademarks of Apple Inc.