Reference / @open-music-sdk/core / endpoint
Function: endpoint()
Call Signature
function endpoint<A, R>(
fn,
unwrap,
plan
): tEndpoint<A, R, Promise<tItem<R>>, "resource">;Defined in: packages/core/src/endpoint.ts:211
Declares a function for one endpoint. plan turns the function's arguments into a request, [path, init], checking them as it goes: it is where a mistake becomes a TypeError naming fn, before Apple is asked. unwrap says what the bound form hands over. The declaration itself is checked as it is made, and what it gives is frozen.
A bound function that walks pages is planned when it is called, like any other, so what it is handed is checked and taken then: a mistake the plan throws is thrown from the call. Apple is asked for nothing until a loop starts, and each loop over what the call gave asks afresh. A plan that has to ask the client for something gives the rest of itself as a function, a tLater, which is what keeps that asking for the loop as well.
written with a plan whose answer is void is for a write whose answer holds nothing, such as an add or a delete: bound, it resolves to undefined, and the write happened.
Type Parameters
A
A extends readonly unknown[]
R
R extends tResources
Parameters
fn
string
The function's name, as its errors say it.
unwrap
"resource"
What the bound form hands over: the resource, the resources, every item of all its pages, what a write has written, or the answer as it is.
plan
tPlan<A, R>
From the client and the arguments of a call, the request to make: [path, init], a promise of it, or the rest of the plan as a function to call when the request is about to be made. It checks the arguments, and throws a TypeError for a mistake.
Returns
tEndpoint<A, R, Promise<tItem<R>>, "resource">
The function, frozen, with bound and unwrap on it.
Throws
TypeError if fn is not a string with something in it, unwrap is none of the five kinds, or plan is no function.
Call Signature
function endpoint<A, R>(
fn,
unwrap,
plan
): tEndpoint<A, R, Promise<tItem<R>[]>, "resources">;Defined in: packages/core/src/endpoint.ts:212
Declares a function for one endpoint. plan turns the function's arguments into a request, [path, init], checking them as it goes: it is where a mistake becomes a TypeError naming fn, before Apple is asked. unwrap says what the bound form hands over. The declaration itself is checked as it is made, and what it gives is frozen.
A bound function that walks pages is planned when it is called, like any other, so what it is handed is checked and taken then: a mistake the plan throws is thrown from the call. Apple is asked for nothing until a loop starts, and each loop over what the call gave asks afresh. A plan that has to ask the client for something gives the rest of itself as a function, a tLater, which is what keeps that asking for the loop as well.
written with a plan whose answer is void is for a write whose answer holds nothing, such as an add or a delete: bound, it resolves to undefined, and the write happened.
Type Parameters
A
A extends readonly unknown[]
R
R extends tResources
Parameters
fn
string
The function's name, as its errors say it.
unwrap
"resources"
What the bound form hands over: the resource, the resources, every item of all its pages, what a write has written, or the answer as it is.
plan
tPlan<A, R>
From the client and the arguments of a call, the request to make: [path, init], a promise of it, or the rest of the plan as a function to call when the request is about to be made. It checks the arguments, and throws a TypeError for a mistake.
Returns
tEndpoint<A, R, Promise<tItem<R>[]>, "resources">
The function, frozen, with bound and unwrap on it.
Throws
TypeError if fn is not a string with something in it, unwrap is none of the five kinds, or plan is no function.
Call Signature
function endpoint<A, R>(
fn,
unwrap,
plan
): tEndpoint<A, R, AsyncIterable<tItem<R>, any, any>, "pages">;Defined in: packages/core/src/endpoint.ts:213
Declares a function for one endpoint. plan turns the function's arguments into a request, [path, init], checking them as it goes: it is where a mistake becomes a TypeError naming fn, before Apple is asked. unwrap says what the bound form hands over. The declaration itself is checked as it is made, and what it gives is frozen.
A bound function that walks pages is planned when it is called, like any other, so what it is handed is checked and taken then: a mistake the plan throws is thrown from the call. Apple is asked for nothing until a loop starts, and each loop over what the call gave asks afresh. A plan that has to ask the client for something gives the rest of itself as a function, a tLater, which is what keeps that asking for the loop as well.
written with a plan whose answer is void is for a write whose answer holds nothing, such as an add or a delete: bound, it resolves to undefined, and the write happened.
Type Parameters
A
A extends readonly unknown[]
R
R extends tPage<unknown>
Parameters
fn
string
The function's name, as its errors say it.
unwrap
"pages"
What the bound form hands over: the resource, the resources, every item of all its pages, what a write has written, or the answer as it is.
plan
tPlan<A, R>
From the client and the arguments of a call, the request to make: [path, init], a promise of it, or the rest of the plan as a function to call when the request is about to be made. It checks the arguments, and throws a TypeError for a mistake.
Returns
tEndpoint<A, R, AsyncIterable<tItem<R>, any, any>, "pages">
The function, frozen, with bound and unwrap on it.
Throws
TypeError if fn is not a string with something in it, unwrap is none of the five kinds, or plan is no function.
Call Signature
function endpoint<A, R>(
fn,
unwrap,
plan
): tEndpoint<A, R, Promise<tItem<R> | undefined>, "written">;Defined in: packages/core/src/endpoint.ts:214
Declares a function for one endpoint. plan turns the function's arguments into a request, [path, init], checking them as it goes: it is where a mistake becomes a TypeError naming fn, before Apple is asked. unwrap says what the bound form hands over. The declaration itself is checked as it is made, and what it gives is frozen.
A bound function that walks pages is planned when it is called, like any other, so what it is handed is checked and taken then: a mistake the plan throws is thrown from the call. Apple is asked for nothing until a loop starts, and each loop over what the call gave asks afresh. A plan that has to ask the client for something gives the rest of itself as a function, a tLater, which is what keeps that asking for the loop as well.
written with a plan whose answer is void is for a write whose answer holds nothing, such as an add or a delete: bound, it resolves to undefined, and the write happened.
Type Parameters
A
A extends readonly unknown[]
R
R extends tResources
Parameters
fn
string
The function's name, as its errors say it.
unwrap
"written"
What the bound form hands over: the resource, the resources, every item of all its pages, what a write has written, or the answer as it is.
plan
tPlan<A, R>
From the client and the arguments of a call, the request to make: [path, init], a promise of it, or the rest of the plan as a function to call when the request is about to be made. It checks the arguments, and throws a TypeError for a mistake.
Returns
tEndpoint<A, R, Promise<tItem<R> | undefined>, "written">
The function, frozen, with bound and unwrap on it.
Throws
TypeError if fn is not a string with something in it, unwrap is none of the five kinds, or plan is no function.
Call Signature
function endpoint<A>(
fn,
unwrap,
plan
): tEndpoint<A, void, Promise<undefined>, "written">;Defined in: packages/core/src/endpoint.ts:215
Declares a function for one endpoint. plan turns the function's arguments into a request, [path, init], checking them as it goes: it is where a mistake becomes a TypeError naming fn, before Apple is asked. unwrap says what the bound form hands over. The declaration itself is checked as it is made, and what it gives is frozen.
A bound function that walks pages is planned when it is called, like any other, so what it is handed is checked and taken then: a mistake the plan throws is thrown from the call. Apple is asked for nothing until a loop starts, and each loop over what the call gave asks afresh. A plan that has to ask the client for something gives the rest of itself as a function, a tLater, which is what keeps that asking for the loop as well.
written with a plan whose answer is void is for a write whose answer holds nothing, such as an add or a delete: bound, it resolves to undefined, and the write happened.
Type Parameters
A
A extends readonly unknown[]
Parameters
fn
string
The function's name, as its errors say it.
unwrap
"written"
What the bound form hands over: the resource, the resources, every item of all its pages, what a write has written, or the answer as it is.
plan
tPlan<A, void>
From the client and the arguments of a call, the request to make: [path, init], a promise of it, or the rest of the plan as a function to call when the request is about to be made. It checks the arguments, and throws a TypeError for a mistake.
Returns
tEndpoint<A, void, Promise<undefined>, "written">
The function, frozen, with bound and unwrap on it.
Throws
TypeError if fn is not a string with something in it, unwrap is none of the five kinds, or plan is no function.
Call Signature
function endpoint<A, R>(
fn,
unwrap,
plan
): tEndpoint<A, R, Promise<R>, "answer">;Defined in: packages/core/src/endpoint.ts:216
Declares a function for one endpoint. plan turns the function's arguments into a request, [path, init], checking them as it goes: it is where a mistake becomes a TypeError naming fn, before Apple is asked. unwrap says what the bound form hands over. The declaration itself is checked as it is made, and what it gives is frozen.
A bound function that walks pages is planned when it is called, like any other, so what it is handed is checked and taken then: a mistake the plan throws is thrown from the call. Apple is asked for nothing until a loop starts, and each loop over what the call gave asks afresh. A plan that has to ask the client for something gives the rest of itself as a function, a tLater, which is what keeps that asking for the loop as well.
written with a plan whose answer is void is for a write whose answer holds nothing, such as an add or a delete: bound, it resolves to undefined, and the write happened.
Type Parameters
A
A extends readonly unknown[]
R
R
Parameters
fn
string
The function's name, as its errors say it.
unwrap
"answer"
What the bound form hands over: the resource, the resources, every item of all its pages, what a write has written, or the answer as it is.
plan
tPlan<A, R>
From the client and the arguments of a call, the request to make: [path, init], a promise of it, or the rest of the plan as a function to call when the request is about to be made. It checks the arguments, and throws a TypeError for a mistake.
Returns
tEndpoint<A, R, Promise<R>, "answer">
The function, frozen, with bound and unwrap on it.
Throws
TypeError if fn is not a string with something in it, unwrap is none of the five kinds, or plan is no function.