INNER CODE UNIT · TypeScript

defaultOpts

logaretm/villus · packages/batch/src/index.ts:21

const defaultOpts = (): BatchOptions => ({
  fetch: resolveGlobalFetch(),
  timeout: 10,
  maxOperationCount: 10,
});

export function batch(opts?: Partial<BatchOptions>) {
  const { fetch, timeout, maxOperationCount } = { ...defaultOpts(), ...(opts || {}) };
  const fetchPluginInstance = fetchPlugin({ fetch });

  let operations: { resolveOp: (r: any, opIdx: number, err?: Error) => void; body: string }[] = [];
  let scheduledConsume: any;

  return definePlugin(function batchPlugin(ctx) {
    const { useResult, opContext, operation } = ctx;

    if (opts?.exclude?.(ctx.operation, ctx)) {
      return fetchPluginInstance(ctx);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…