SheetXL - v1.0.2
    Preparing search index...

    What an executor is given beside its calls.

    interface IDeferContext {
        addResource(
            buffer: ArrayBuffer,
            options?: { fetchedFrom?: string },
        ): object;
        byPayload<T = any, P = unknown>(
            calls: readonly IFormulaContext.DeferredCall<T>[],
            answer: (
                payload: P,
                group: readonly IFormulaContext.DeferredCall<T>[],
            ) => void | Promise<void>,
        ): Promise<void>;
        createRichData(type: string, data?: any): IRichData;
        fetch(input: string, init?: RequestInit): Promise<Response>;
        getFormulaContext(): IFormulaContext;
        getRandom(): number;
        getState<S>(init: () => S): S;
        parseText(text: string, options?: ParseTextOptions): Promise<Scalar[][]>;
    }
    Index
    • Adds bytes to the workbook being calculated as a resource (an IResource), for a rich value to hold: pass it in createRichData's data. The workbook saves it while a value holds it. With fetchedFrom it is the workbook's copy of that URL: fetch answers the URL from it, and adding the same URL again answers the resource already added.

      Parameters

      • buffer: ArrayBuffer
      • Optionaloptions: { fetchedFrom?: string }

      Returns object

    • Groups calls by payload and runs answer once per distinct payload with every call that asked it: one request per question, however many cells asked.

      Type Parameters

      • T = any
      • P = unknown

      Parameters

      • calls: readonly IFormulaContext.DeferredCall<T>[]

        The calls to group, usually every call the executor was handed.

      • answer: (
            payload: P,
            group: readonly IFormulaContext.DeferredCall<T>[],
        ) => void | Promise<void>

        Settles one group. When it throws, or the promise it returns rejects, the group's calls it has not settled fail with that error; the other groups are not affected.

      Returns Promise<void>

      Resolves once every group has been answered. It never rejects.

      Payloads are equal as defer compares them: the same primitive, or plain objects or arrays whose own values are the same one level deep. Groups are answered concurrently, in the order their first call appears.

      async function fetchQuotes(
      calls: readonly IFormulaContext.DeferredCall<number>[],
      ctx: IFormulaContext.IDeferContext
      ): Promise<void> {
      await ctx.byPayload(calls, async (ticker: string, group) => {
      const response = await ctx.fetch(`https://api.example.com/quote/${ticker}`);
      const price: number = (await response.json()).price;
      for (const call of group) call.resolve(price);
      });
      }
    • A rich value of a registered type, for the workbook being calculated: what IFormulaContext.createRichData makes inside a cell, made here for a call's result.

      Parameters

      • type: string
      • Optionaldata: any

      Returns IRichData

    • Fetches through the workbook being calculated: the standard fetch, answered by the fetchers the host registered for the URL's scheme, with the host's authentication. An answer the workbook already has for the URL (a picture it keeps, or anything fetched while it is open) answers from the workbook, and two calls for one URL share one request. In an external calculation (Refresh All) it goes to the source.

      Rejects when the URL cannot be reached, with a FormulaError.Blocked when the site responded but the browser would not let the page read it.

      Parameters

      • input: string
      • Optionalinit: RequestInit

      Returns Promise<Response>

    • The formula context of the workbook being calculated, with no cell: its parsing, text, comparison and dates, read with the workbook's locale and date system.

      Returns IFormulaContext

      Valid for as long as the executor runs, across every await. The ambient FormulaContext is not: it belongs to the cell being evaluated, and an executor runs after that evaluation ends. What needs a cell (getRow, getReference, getValueAt, defer, formatResults, getRandom) throws here; getRandom is the executor's own.

    • A random number in [0, 1) from the calculation's source, which a test can seed.

      Returns number

    • State kept for this executor across recalculations, made by init on first ask. Keep data here (maps, numbers, strings, buffers), not connections or sockets.

      Type Parameters

      • S

      Parameters

      • init: () => S

      Returns S

    • Reads delimited text (CSV, TSV) into rows of values, each field read the way the workbook reads typed entry: numbers, dates, booleans and error labels become values, anything else stays text, and an empty field is blank.

      Parameters

      • text: string

        The delimited text.

      • Optionaloptions: ParseTextOptions

        How the text is split.

      Returns Promise<Scalar[][]>

      The rows, padded with blanks to the widest row.