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.
Optionaloptions: { fetchedFrom?: string }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.
The calls to group, usually every call the executor was handed.
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.
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.
Optionaldata: anyFetches 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.
Optionalinit: RequestInitThe 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.
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.
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.
The delimited text.
Optionaloptions: ParseTextOptions
How the text is split.
The rows, padded with blanks to the widest row.
What an executor is given beside its calls.