Skip to content
Client
Server

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

Function: withNamespaces() ​

ts
function withNamespaces<N>(client, namespaces): tWithNamespaces<N>;

Defined in: packages/core/src/namespaces.ts:53

client with each namespace of namespaces on it, under its name: withNamespaces(music, { catalog }) gives a client whose catalog is catalog(music). The factories are checked and read here, once, and each is called once for this client and once for each client that as() or forUser() derives. What is given is frozen and inherits nothing, and its functions need no this.

Type Parameters ​

N ​

N extends Readonly<Record<string, (client) => object>>

The factories by name, from which the names and what each holds are read.

Parameters ​

client ​

tAppleMusicClient

The client to put the namespaces on, from createClient or anything with its five methods.

namespaces ​

N

A plain object of factories, each taking a client and giving an object, under the name each goes by.

Returns ​

tWithNamespaces<N>

A frozen object with the client's request, paginate, storefront, as and forUser, and each namespace under its name.

Throws ​

TypeError if client is no client, namespaces is not a plain object, one of its values is no function, one of its names is a method of the client, or a factory gives no object.

Throws ​

Whatever a factory throws, as it is.

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