Skip to content
Client
Server

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

Function: initOf() ​

ts
function initOf<T>(
   fn, 
   options, 
   set?, 
   also?
): tRequestInit<T>;

Defined in: packages/core/src/options.ts:200

The options as request takes them: each read once, checked, and copied, so that nothing done to the caller's objects afterwards changes what is sent.

Three things fill the query, and the later wins: the caller's params; then the options that are given, with language sent as l; then set, which is what the function itself puts there, such as the ids it was handed. also names any further options the function takes, such as views, with what each one is, a "list" or a "name". Each is checked as that, and sent under its own name.

Type Parameters ​

T ​

T

Parameters ​

fn ​

string

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

options ​

tReadOptions<T> | undefined

What the caller gave, or undefined for nothing.

set? ​

tParams = {}

The parameters the function itself sends, such as { ids }, which win over every option.

also? ​

tAlsoKinds = {}

The further options the function takes, by name, with what each is.

Returns ​

tRequestInit<T>

What request takes: the query as params, and the schema and signal as given.

Throws ​

TypeError if options is not a plain object, an option is not what tReadOptions says it is, a further option is not what also says it is, or also says a kind that is neither "list" nor "name".

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