@devmm/puredocs-excel-formula 1.0.7 → 1.0.9
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 +435 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -3
- package/dist/index.d.ts +26 -3
- package/dist/index.js +436 -114
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -152,8 +152,11 @@ declare const enum TokenType {
|
|
|
152
152
|
SpillReference = 24,
|
|
153
153
|
Exclamation = 25,
|
|
154
154
|
AtSign = 26,
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
LeftBrace = 27,
|
|
156
|
+
RightBrace = 28,
|
|
157
|
+
Semicolon = 29,
|
|
158
|
+
ErrorLiteral = 30,
|
|
159
|
+
EOF = 31
|
|
157
160
|
}
|
|
158
161
|
interface Token {
|
|
159
162
|
readonly type: TokenType;
|
|
@@ -170,7 +173,8 @@ interface Token {
|
|
|
170
173
|
* - Error literals (#N/A, #REF!, #VALUE!, etc.)
|
|
171
174
|
* - Quoted sheet references ('My Sheet'!A1)
|
|
172
175
|
* - Unquoted sheet references (Sheet1!A1)
|
|
173
|
-
* - _xlfn. prefix stripping
|
|
176
|
+
* - _xlfn. / _xlws. / _xlpm. prefix stripping
|
|
177
|
+
* - Array constants ({1,2;3,4})
|
|
174
178
|
* - Cell references ($A$1, A1, AA123)
|
|
175
179
|
* - Named ranges
|
|
176
180
|
* - @ implicit intersection operator
|
|
@@ -198,6 +202,8 @@ interface FunctionDef {
|
|
|
198
202
|
readonly maxArgs: number;
|
|
199
203
|
readonly isVolatile: boolean;
|
|
200
204
|
readonly handler: FormulaFunction;
|
|
205
|
+
/** Scalar function: an array argument maps it over the array. See {@link FunctionRegistry.registerElementwise}. */
|
|
206
|
+
readonly elementwise: boolean;
|
|
201
207
|
}
|
|
202
208
|
declare class FunctionRegistry {
|
|
203
209
|
#private;
|
|
@@ -205,6 +211,23 @@ declare class FunctionRegistry {
|
|
|
205
211
|
static get default(): FunctionRegistry;
|
|
206
212
|
/** Registers a function. Name is normalised to UPPERCASE. */
|
|
207
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;
|
|
208
231
|
/** Executes a function by name with argument validation. */
|
|
209
232
|
execute(name: string, args: FormulaNode[], ctx: FormulaContext): FormulaValue;
|
|
210
233
|
/** Returns true if the named function is volatile (NOW, RAND, etc.). */
|
package/dist/index.d.ts
CHANGED
|
@@ -152,8 +152,11 @@ declare const enum TokenType {
|
|
|
152
152
|
SpillReference = 24,
|
|
153
153
|
Exclamation = 25,
|
|
154
154
|
AtSign = 26,
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
LeftBrace = 27,
|
|
156
|
+
RightBrace = 28,
|
|
157
|
+
Semicolon = 29,
|
|
158
|
+
ErrorLiteral = 30,
|
|
159
|
+
EOF = 31
|
|
157
160
|
}
|
|
158
161
|
interface Token {
|
|
159
162
|
readonly type: TokenType;
|
|
@@ -170,7 +173,8 @@ interface Token {
|
|
|
170
173
|
* - Error literals (#N/A, #REF!, #VALUE!, etc.)
|
|
171
174
|
* - Quoted sheet references ('My Sheet'!A1)
|
|
172
175
|
* - Unquoted sheet references (Sheet1!A1)
|
|
173
|
-
* - _xlfn. prefix stripping
|
|
176
|
+
* - _xlfn. / _xlws. / _xlpm. prefix stripping
|
|
177
|
+
* - Array constants ({1,2;3,4})
|
|
174
178
|
* - Cell references ($A$1, A1, AA123)
|
|
175
179
|
* - Named ranges
|
|
176
180
|
* - @ implicit intersection operator
|
|
@@ -198,6 +202,8 @@ interface FunctionDef {
|
|
|
198
202
|
readonly maxArgs: number;
|
|
199
203
|
readonly isVolatile: boolean;
|
|
200
204
|
readonly handler: FormulaFunction;
|
|
205
|
+
/** Scalar function: an array argument maps it over the array. See {@link FunctionRegistry.registerElementwise}. */
|
|
206
|
+
readonly elementwise: boolean;
|
|
201
207
|
}
|
|
202
208
|
declare class FunctionRegistry {
|
|
203
209
|
#private;
|
|
@@ -205,6 +211,23 @@ declare class FunctionRegistry {
|
|
|
205
211
|
static get default(): FunctionRegistry;
|
|
206
212
|
/** Registers a function. Name is normalised to UPPERCASE. */
|
|
207
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;
|
|
208
231
|
/** Executes a function by name with argument validation. */
|
|
209
232
|
execute(name: string, args: FormulaNode[], ctx: FormulaContext): FormulaValue;
|
|
210
233
|
/** Returns true if the named function is volatile (NOW, RAND, etc.). */
|