@devmm/puredocs-excel-formula 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +321 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +322 -107
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -202,6 +202,8 @@ interface FunctionDef {
|
|
|
202
202
|
readonly maxArgs: number;
|
|
203
203
|
readonly isVolatile: boolean;
|
|
204
204
|
readonly handler: FormulaFunction;
|
|
205
|
+
/** Scalar function: an array argument maps it over the array. See {@link FunctionRegistry.registerElementwise}. */
|
|
206
|
+
readonly elementwise: boolean;
|
|
205
207
|
}
|
|
206
208
|
declare class FunctionRegistry {
|
|
207
209
|
#private;
|
|
@@ -209,6 +211,23 @@ declare class FunctionRegistry {
|
|
|
209
211
|
static get default(): FunctionRegistry;
|
|
210
212
|
/** Registers a function. Name is normalised to UPPERCASE. */
|
|
211
213
|
register(name: string, handler: FormulaFunction, minArgs?: number, maxArgs?: number, isVolatile?: boolean): void;
|
|
214
|
+
/**
|
|
215
|
+
* Registers a **scalar** function — one whose arguments are single values —
|
|
216
|
+
* and lifts it over arrays automatically.
|
|
217
|
+
*
|
|
218
|
+
* `LEFT(A2:A100, 3)` is not a special form in Excel: LEFT takes one string, and
|
|
219
|
+
* the grid maps it over the range, giving a 99-row array. Without that lifting
|
|
220
|
+
* the range collapses to one value, so the dynamic array built on top of it —
|
|
221
|
+
* `FILTER(IFERROR(LEFT(A2:A100,3),""), …)` — filters a 1×1 input and returns
|
|
222
|
+
* `#CALC!`. Lifting belongs here rather than in each handler: the ~40 scalar
|
|
223
|
+
* text/math/date functions then get it for free and cannot each get it subtly
|
|
224
|
+
* wrong.
|
|
225
|
+
*
|
|
226
|
+
* Only mark functions that are genuinely per-cell. Anything that *consumes* an
|
|
227
|
+
* array (SUM, COUNTIF, FILTER, SORT, the lazy branch functions) must keep
|
|
228
|
+
* `register`, or lifting would map it over the array it is meant to reduce.
|
|
229
|
+
*/
|
|
230
|
+
registerElementwise(name: string, handler: FormulaFunction, minArgs?: number, maxArgs?: number): void;
|
|
212
231
|
/** Executes a function by name with argument validation. */
|
|
213
232
|
execute(name: string, args: FormulaNode[], ctx: FormulaContext): FormulaValue;
|
|
214
233
|
/** Returns true if the named function is volatile (NOW, RAND, etc.). */
|
package/dist/index.d.ts
CHANGED
|
@@ -202,6 +202,8 @@ interface FunctionDef {
|
|
|
202
202
|
readonly maxArgs: number;
|
|
203
203
|
readonly isVolatile: boolean;
|
|
204
204
|
readonly handler: FormulaFunction;
|
|
205
|
+
/** Scalar function: an array argument maps it over the array. See {@link FunctionRegistry.registerElementwise}. */
|
|
206
|
+
readonly elementwise: boolean;
|
|
205
207
|
}
|
|
206
208
|
declare class FunctionRegistry {
|
|
207
209
|
#private;
|
|
@@ -209,6 +211,23 @@ declare class FunctionRegistry {
|
|
|
209
211
|
static get default(): FunctionRegistry;
|
|
210
212
|
/** Registers a function. Name is normalised to UPPERCASE. */
|
|
211
213
|
register(name: string, handler: FormulaFunction, minArgs?: number, maxArgs?: number, isVolatile?: boolean): void;
|
|
214
|
+
/**
|
|
215
|
+
* Registers a **scalar** function — one whose arguments are single values —
|
|
216
|
+
* and lifts it over arrays automatically.
|
|
217
|
+
*
|
|
218
|
+
* `LEFT(A2:A100, 3)` is not a special form in Excel: LEFT takes one string, and
|
|
219
|
+
* the grid maps it over the range, giving a 99-row array. Without that lifting
|
|
220
|
+
* the range collapses to one value, so the dynamic array built on top of it —
|
|
221
|
+
* `FILTER(IFERROR(LEFT(A2:A100,3),""), …)` — filters a 1×1 input and returns
|
|
222
|
+
* `#CALC!`. Lifting belongs here rather than in each handler: the ~40 scalar
|
|
223
|
+
* text/math/date functions then get it for free and cannot each get it subtly
|
|
224
|
+
* wrong.
|
|
225
|
+
*
|
|
226
|
+
* Only mark functions that are genuinely per-cell. Anything that *consumes* an
|
|
227
|
+
* array (SUM, COUNTIF, FILTER, SORT, the lazy branch functions) must keep
|
|
228
|
+
* `register`, or lifting would map it over the array it is meant to reduce.
|
|
229
|
+
*/
|
|
230
|
+
registerElementwise(name: string, handler: FormulaFunction, minArgs?: number, maxArgs?: number): void;
|
|
212
231
|
/** Executes a function by name with argument validation. */
|
|
213
232
|
execute(name: string, args: FormulaNode[], ctx: FormulaContext): FormulaValue;
|
|
214
233
|
/** Returns true if the named function is volatile (NOW, RAND, etc.). */
|