Skip to content

Commit

Permalink
refactor: per self review
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Sep 6, 2024
1 parent afd6d69 commit daac44f
Show file tree
Hide file tree
Showing 9 changed files with 1,828 additions and 38 deletions.
Binary file added prismicio-client-7.8.1.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/BaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ type FetchJobResult<TJSON = any> = {
text?: string
}

export class BaseClient {
export abstract class BaseClient {
/**
* The function used to make network requests to the Prismic REST API. In
* environments where a global `fetch` function does not exist, such as
Expand Down
2 changes: 0 additions & 2 deletions src/Migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ export class Migration<
*/
assets: Map<MigrationAsset["file"], MigrationAsset> = new Map()

constructor() {}

createAsset(
asset: Asset | FilledImageFieldImage | FilledLinkToMediaField,
): CreateAssetReturnType
Expand Down
43 changes: 25 additions & 18 deletions src/lib/pLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,31 @@ type AnyFunction = (...arguments_: readonly any[]) => unknown

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))

export type LimitFunction = {
/**
* @param fn - Promise-returning/async function.
* @param arguments - Any arguments to pass through to `fn`. Support for
* passing arguments on to the `fn` is provided in order to be able to avoid
* creating unnecessary closures. You probably don't need this optimization
* unless you're pushing a lot of functions.
*
* @returns The promise returned by calling `fn(...arguments)`.
*/
<Arguments extends unknown[], ReturnType>(
function_: (
...arguments_: Arguments
) => PromiseLike<ReturnType> | ReturnType,
...arguments_: Arguments
): Promise<ReturnType>
}

/**
* @param fn - Promise-returning/async function.
* @param arguments - Any arguments to pass through to `fn`. Support for passing
* arguments on to the `fn` is provided in order to be able to avoid creating
* unnecessary closures. You probably don't need this optimization unless
* you're pushing a lot of functions.
*
* @returns The promise returned by calling `fn(...arguments)`.
*/
export type LimitFunction = <TArguments extends unknown[], TReturnType>(
function_: (
...arguments_: TArguments
) => PromiseLike<TReturnType> | TReturnType,
...arguments_: TArguments
) => Promise<TReturnType>

/**
* Creates a limiting function that will only execute one promise at a time and
* respect a given interval between each call.
*
* @param args - Options for the function, `interval` is the minimum time to
* wait between each promise execution.
*
* @returns A limiting function as per configuration, see {@link LimitFunction}.
*/
export const pLimit = ({
interval,
}: { interval?: number } = {}): LimitFunction => {
Expand Down
Loading

0 comments on commit daac44f

Please sign in to comment.