@sheetxl/primitives 0.8.0-beta.1 → 0.8.0-beta.10
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/browser/esm/index.mjs +94 -75
- package/node/esm/index.mjs +104 -83
- package/package.json +3 -4
- package/types/src/ErrorPolicy.d.ts +48 -57
- package/types/src/Flatten.d.ts +6 -3
- package/types/src/FormulaContext.d.ts +30 -7
- package/types/src/IFormulaContext.d.ts +205 -11
- package/types/src/IFunction.d.ts +368 -54
- package/types/src/IFunctionArguments.d.ts +86 -15
- package/types/src/IRange.d.ts +170 -38
- package/types/src/IRangeStats.d.ts +34 -3
- package/types/src/IRuntime.d.ts +24 -1
- package/types/src/Lazy.d.ts +76 -0
- package/types/src/NoFilter.d.ts +34 -0
- package/types/src/NoLift.d.ts +31 -0
- package/types/src/Repeating.d.ts +24 -4
- package/types/src/ReportType.d.ts +42 -0
- package/types/src/Scalar.d.ts +1 -1
- package/types/src/ValueKind.d.ts +43 -0
- package/types/src/Volatile.d.ts +12 -0
- package/types/src/WildCard.d.ts +13 -9
- package/types/src/index.d.ts +6 -1
- package/browser/cjs/index.cjs +0 -1
- package/types/src/Compat.d.ts +0 -77
package/node/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.
|
|
2
|
+
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.10
|
|
3
3
|
*
|
|
4
4
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
@@ -32,7 +32,13 @@ var t, r, o, n, s = {
|
|
|
32
32
|
}, a = {
|
|
33
33
|
...s,
|
|
34
34
|
Date: "date"
|
|
35
|
-
}, i =
|
|
35
|
+
}, i = {
|
|
36
|
+
...s,
|
|
37
|
+
Reference: "reference",
|
|
38
|
+
Array: "array",
|
|
39
|
+
Lambda: "lambda",
|
|
40
|
+
Omitted: "omitted"
|
|
41
|
+
}, c = /[.*+?^${}()|[\]\\]/, u = (e) => c.test(e) ? "\\" + e : e, l = {
|
|
36
42
|
isWildCard: (e) => "string" == typeof e && /[*?]/.test(e),
|
|
37
43
|
toRegex: (e, t, r = !1) => {
|
|
38
44
|
let o = "";
|
|
@@ -41,30 +47,14 @@ var t, r, o, n, s = {
|
|
|
41
47
|
const r = e[t];
|
|
42
48
|
if ("~" === r) {
|
|
43
49
|
const r = e[t + 1];
|
|
44
|
-
"*"
|
|
50
|
+
"*" !== r && "?" !== r && "~" !== r || (o += u(r), t++);
|
|
45
51
|
continue;
|
|
46
52
|
}
|
|
47
|
-
"*" !== r ? o += "?" !== r ?
|
|
48
|
-
}
|
|
49
|
-
return RegExp(r ? `^${o}$` : o, t);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
noReferenceLift: "A multi-cell reference at a non-repeating scalar parameter is #VALUE! rather than a broadcast.",
|
|
53
|
-
noMemberFilter: "Members of a repeating scalar parameter are coerced rather than filtered; one that cannot be is #VALUE!."
|
|
54
|
-
}, d = { atp: ["noReferenceLift", "noMemberFilter"] };
|
|
55
|
-
function g(e) {
|
|
56
|
-
const t = p(e);
|
|
57
|
-
if (t) return [t];
|
|
58
|
-
const r = (e ?? "").trim().toLowerCase();
|
|
59
|
-
for (const e of Object.keys(d)) if (e.toLowerCase() === r) return d[e];
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
function p(e) {
|
|
63
|
-
if (!e) return null;
|
|
64
|
-
const t = e.trim().toLowerCase();
|
|
65
|
-
for (const e of Object.keys(l)) if (e.toLowerCase() === t) return e;
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
53
|
+
"*" !== r ? o += "?" !== r ? u(r) : "[\\s\\S]" : o += "[\\s\\S]*";
|
|
54
|
+
}
|
|
55
|
+
return "start" === r ? RegExp(`^${o}`, t) : RegExp(r ? `^${o}$` : o, t);
|
|
56
|
+
}
|
|
57
|
+
}, d = (e) => null !== e && "object" == typeof e && !0 === e.isLazy;
|
|
68
58
|
(r = t || (t = {})).Axis = {
|
|
69
59
|
Column: "column",
|
|
70
60
|
Row: "row"
|
|
@@ -262,7 +252,7 @@ function p(e) {
|
|
|
262
252
|
}
|
|
263
253
|
}
|
|
264
254
|
e.Connect = m;
|
|
265
|
-
class
|
|
255
|
+
class S extends o {
|
|
266
256
|
constructor(e, o) {
|
|
267
257
|
super(t.Blocked, r.Blocked, e, o);
|
|
268
258
|
}
|
|
@@ -270,8 +260,8 @@ function p(e) {
|
|
|
270
260
|
this.code = n.Code.Blocked;
|
|
271
261
|
}
|
|
272
262
|
}
|
|
273
|
-
e.Blocked =
|
|
274
|
-
class
|
|
263
|
+
e.Blocked = S;
|
|
264
|
+
class C extends o {
|
|
275
265
|
constructor(e, o) {
|
|
276
266
|
super(t.Unknown, r.Unknown, e, o);
|
|
277
267
|
}
|
|
@@ -279,8 +269,8 @@ function p(e) {
|
|
|
279
269
|
this.code = n.Code.Unknown;
|
|
280
270
|
}
|
|
281
271
|
}
|
|
282
|
-
e.Unknown =
|
|
283
|
-
class
|
|
272
|
+
e.Unknown = C;
|
|
273
|
+
class w extends o {
|
|
284
274
|
constructor(e, o) {
|
|
285
275
|
super(t.Field, r.Field, e, o);
|
|
286
276
|
}
|
|
@@ -288,8 +278,8 @@ function p(e) {
|
|
|
288
278
|
this.code = n.Code.Field;
|
|
289
279
|
}
|
|
290
280
|
}
|
|
291
|
-
e.Field =
|
|
292
|
-
class
|
|
281
|
+
e.Field = w;
|
|
282
|
+
class f extends o {
|
|
293
283
|
constructor(e, o) {
|
|
294
284
|
super(t.Calc, r.Calc, e, o);
|
|
295
285
|
}
|
|
@@ -297,8 +287,8 @@ function p(e) {
|
|
|
297
287
|
this.code = n.Code.Calc;
|
|
298
288
|
}
|
|
299
289
|
}
|
|
300
|
-
e.Calc =
|
|
301
|
-
class
|
|
290
|
+
e.Calc = f;
|
|
291
|
+
class y extends o {
|
|
302
292
|
constructor(e, o) {
|
|
303
293
|
super(t.Busy, r.Busy, e, o);
|
|
304
294
|
}
|
|
@@ -306,7 +296,7 @@ function p(e) {
|
|
|
306
296
|
this.code = n.Code.Busy;
|
|
307
297
|
}
|
|
308
298
|
}
|
|
309
|
-
e.Busy =
|
|
299
|
+
e.Busy = y;
|
|
310
300
|
class N extends o {
|
|
311
301
|
constructor(e, o) {
|
|
312
302
|
super(t.Python, r.Python, e, o);
|
|
@@ -316,7 +306,7 @@ function p(e) {
|
|
|
316
306
|
}
|
|
317
307
|
}
|
|
318
308
|
e.Python = N;
|
|
319
|
-
class
|
|
309
|
+
class b extends o {
|
|
320
310
|
constructor(e, o) {
|
|
321
311
|
super(t.Timeout, r.Timeout, e, o);
|
|
322
312
|
}
|
|
@@ -324,17 +314,17 @@ function p(e) {
|
|
|
324
314
|
this.code = n.Code.Timeout;
|
|
325
315
|
}
|
|
326
316
|
}
|
|
327
|
-
e.Timeout =
|
|
317
|
+
e.Timeout = b;
|
|
328
318
|
}(n || (n = {}));
|
|
329
|
-
var
|
|
330
|
-
|
|
331
|
-
var
|
|
332
|
-
for (let e = 0; e <
|
|
333
|
-
const t =
|
|
334
|
-
|
|
319
|
+
var g = {};
|
|
320
|
+
g[n.Code.Parse] = n.Parse, g[n.Code.Null] = n.Null, g[n.Code.Div0] = n.Div0, g[n.Code.Value] = n.Value, g[n.Code.Ref] = n.Ref, g[n.Code.Name] = n.Name, g[n.Code.Num] = n.Num, g[n.Code.NA] = n.NA, g[n.Code.GettingData] = n.GettingData, g[n.Code.Spill] = n.Spill, g[n.Code.Connect] = n.Connect, g[n.Code.Blocked] = n.Blocked, g[n.Code.Unknown] = n.Unknown, g[n.Code.Field] = n.Field, g[n.Code.Calc] = n.Calc, g[n.Code.Busy] = n.Busy, g[n.Code.Python] = n.Python, g[n.Code.Timeout] = n.Timeout;
|
|
321
|
+
var p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map(), C = Object.keys(g);
|
|
322
|
+
for (let e = 0; e < C.length; e++) {
|
|
323
|
+
const t = g[C[e]], r = new t();
|
|
324
|
+
m.set(r.getLabel(), t), S.set(r.getCode(), t), p.set(r.getLabel(), r), h.set(r.getCode(), r);
|
|
335
325
|
}
|
|
336
326
|
(function(e) {
|
|
337
|
-
const t = e.getBuiltInByCode = (e) =>
|
|
327
|
+
const t = e.getBuiltInByCode = (e) => h.get(e);
|
|
338
328
|
e.BuiltIn = {
|
|
339
329
|
Parse: t(n.Code.Parse),
|
|
340
330
|
Null: t(n.Code.Null),
|
|
@@ -356,12 +346,12 @@ for (let e = 0; e < w.length; e++) {
|
|
|
356
346
|
Timeout: t(n.Code.Timeout)
|
|
357
347
|
}, e.newTypedError = (e, t, r) => {
|
|
358
348
|
let o;
|
|
359
|
-
return o = "string" == typeof e ?
|
|
360
|
-
}, e.getBuiltInByLabel = (e) =>
|
|
349
|
+
return o = "string" == typeof e ? m.get(e) : S.get(e), o || (o = n.Unknown), new o(t, r);
|
|
350
|
+
}, e.getBuiltInByLabel = (e) => p.get(e), e.isError = function(e, t) {
|
|
361
351
|
return !!e && !0 === e.isFormulaError && (void 0 === t || e.getCode() === t);
|
|
362
352
|
};
|
|
363
353
|
})(n || (n = {}));
|
|
364
|
-
var
|
|
354
|
+
var w = class {
|
|
365
355
|
constructor(e) {
|
|
366
356
|
this._subscribeFn = e;
|
|
367
357
|
}
|
|
@@ -381,42 +371,48 @@ var b = class {
|
|
|
381
371
|
"function" == typeof n && n();
|
|
382
372
|
}, o;
|
|
383
373
|
}
|
|
384
|
-
},
|
|
374
|
+
}, f = class {
|
|
385
375
|
createRange(e, t, r) {
|
|
386
|
-
throw new
|
|
376
|
+
throw new b();
|
|
377
|
+
}
|
|
378
|
+
flattenAreas(e) {
|
|
379
|
+
throw new b();
|
|
387
380
|
}
|
|
388
381
|
getReference(e, t) {
|
|
389
|
-
throw new
|
|
382
|
+
throw new b();
|
|
390
383
|
}
|
|
391
384
|
getResizedReference(e, t, r) {
|
|
392
|
-
throw new
|
|
385
|
+
throw new b();
|
|
393
386
|
}
|
|
394
387
|
getNumberFormat(e, t) {
|
|
395
|
-
throw new
|
|
388
|
+
throw new b();
|
|
396
389
|
}
|
|
397
390
|
fromSerialDate(e, t) {
|
|
398
|
-
throw new
|
|
391
|
+
throw new b();
|
|
399
392
|
}
|
|
400
393
|
toSerialDate(e, t) {
|
|
401
|
-
throw new
|
|
394
|
+
throw new b();
|
|
402
395
|
}
|
|
403
396
|
getDateParts(e, t) {
|
|
404
|
-
throw new
|
|
397
|
+
throw new b();
|
|
405
398
|
}
|
|
406
399
|
getSerialDate(e, t, r, o, n, s, a) {
|
|
407
|
-
throw new
|
|
400
|
+
throw new b();
|
|
408
401
|
}
|
|
409
402
|
getNow() {
|
|
410
|
-
throw new
|
|
403
|
+
throw new b();
|
|
404
|
+
}
|
|
405
|
+
getRandom() {
|
|
406
|
+
return Math.random();
|
|
411
407
|
}
|
|
412
408
|
getValueAt(e, t, r, o) {
|
|
413
409
|
return null;
|
|
414
410
|
}
|
|
415
411
|
getEntireCoords() {
|
|
416
|
-
return
|
|
412
|
+
return A;
|
|
417
413
|
}
|
|
418
414
|
isValidDate(e, t) {
|
|
419
|
-
return e instanceof Date || "[object Date]" === Object.prototype.toString.call(e) ? !isNaN(e.getTime()) : !t && "number" == typeof e && !(e < 0 || e >
|
|
415
|
+
return e instanceof Date || "[object Date]" === Object.prototype.toString.call(e) ? !isNaN(e.getTime()) : !t && "number" == typeof e && !(e < 0 || e > _);
|
|
420
416
|
}
|
|
421
417
|
getRow() {
|
|
422
418
|
return 0;
|
|
@@ -424,6 +420,9 @@ var b = class {
|
|
|
424
420
|
getColumn() {
|
|
425
421
|
return 0;
|
|
426
422
|
}
|
|
423
|
+
isImplicitIntersect() {
|
|
424
|
+
return !1;
|
|
425
|
+
}
|
|
427
426
|
getFormulaAt(e, t, r) {
|
|
428
427
|
return null;
|
|
429
428
|
}
|
|
@@ -448,19 +447,22 @@ var b = class {
|
|
|
448
447
|
return null;
|
|
449
448
|
}
|
|
450
449
|
getAddress(e, t) {
|
|
451
|
-
throw new
|
|
450
|
+
throw new b();
|
|
452
451
|
}
|
|
453
452
|
parseAsSerialDate(e, t) {
|
|
454
|
-
throw new
|
|
453
|
+
throw new b();
|
|
455
454
|
}
|
|
456
455
|
parseAsDate(e, t) {
|
|
457
|
-
throw new
|
|
456
|
+
throw new b();
|
|
458
457
|
}
|
|
459
458
|
parseAsNumber(e, t) {
|
|
460
|
-
throw new
|
|
459
|
+
throw new b();
|
|
461
460
|
}
|
|
462
|
-
createCriteria(e) {
|
|
463
|
-
throw new
|
|
461
|
+
createCriteria(e, t) {
|
|
462
|
+
throw new b();
|
|
463
|
+
}
|
|
464
|
+
createGrouping(e, t) {
|
|
465
|
+
throw new b();
|
|
464
466
|
}
|
|
465
467
|
parseAsLiteral(e) {
|
|
466
468
|
const t = e.toUpperCase();
|
|
@@ -475,10 +477,10 @@ var b = class {
|
|
|
475
477
|
return o !== n ? o < n ? -1 : 1 : e < t ? -1 : e > t ? 1 : 0;
|
|
476
478
|
}
|
|
477
479
|
getRuntime() {
|
|
478
|
-
return
|
|
480
|
+
return D;
|
|
479
481
|
}
|
|
480
482
|
getArgs() {
|
|
481
|
-
throw new
|
|
483
|
+
throw new b(N);
|
|
482
484
|
}
|
|
483
485
|
}, y = (e) => {
|
|
484
486
|
if (null == e) return 0;
|
|
@@ -488,32 +490,33 @@ var b = class {
|
|
|
488
490
|
case "boolean": return 3;
|
|
489
491
|
default: return 4;
|
|
490
492
|
}
|
|
491
|
-
},
|
|
493
|
+
}, N = "FormulaContext.getArgs() is only valid while a function body is running", b = class extends Error {
|
|
492
494
|
constructor(e = "Not implemented in StubbedFormulaContext") {
|
|
493
495
|
super(e), this.name = "NotImplementedError";
|
|
494
496
|
}
|
|
495
|
-
},
|
|
497
|
+
}, A = Object.freeze({
|
|
496
498
|
colStart: 0,
|
|
497
499
|
rowStart: 0,
|
|
498
500
|
colEnd: Math.pow(2, 14) - 1,
|
|
499
501
|
rowEnd: Math.pow(2, 20) - 1
|
|
500
|
-
}),
|
|
502
|
+
}), D = {
|
|
501
503
|
isDate1904: () => !1,
|
|
502
|
-
getLocale: () =>
|
|
503
|
-
getLocaleProfile: () =>
|
|
504
|
+
getLocale: () => F.tag,
|
|
505
|
+
getLocaleProfile: () => F,
|
|
504
506
|
isR1C1: () => !1,
|
|
505
507
|
getNow: () => 0,
|
|
508
|
+
getRandom: () => Math.random(),
|
|
506
509
|
getLocation: () => "unknown",
|
|
507
510
|
getVersion: () => "1.0.0",
|
|
508
511
|
getOS: () => "unknown",
|
|
509
512
|
getUser: () => "unidentified",
|
|
510
513
|
getDescription: () => "Stubbed Formula Context"
|
|
511
|
-
},
|
|
514
|
+
}, _ = 2958465, R = new f(), x = class {
|
|
512
515
|
constructor() {
|
|
513
|
-
this._scope =
|
|
516
|
+
this._scope = R, this._argsFn = null;
|
|
514
517
|
}
|
|
515
518
|
_setScope(e) {
|
|
516
|
-
this._scope = e ??
|
|
519
|
+
this._scope = e ?? R;
|
|
517
520
|
}
|
|
518
521
|
_getScope() {
|
|
519
522
|
return this._scope;
|
|
@@ -525,7 +528,7 @@ var b = class {
|
|
|
525
528
|
return this._getScope().getNumberFormat(e, t);
|
|
526
529
|
}
|
|
527
530
|
getEntireCoords() {
|
|
528
|
-
return this._getScope().getEntireCoords() ??
|
|
531
|
+
return this._getScope().getEntireCoords() ?? A;
|
|
529
532
|
}
|
|
530
533
|
parseAsSerialDate(e, t) {
|
|
531
534
|
return this._getScope().parseAsSerialDate(e, t);
|
|
@@ -536,12 +539,15 @@ var b = class {
|
|
|
536
539
|
parseAsNumber(e, t) {
|
|
537
540
|
return this._getScope().parseAsNumber(e, t);
|
|
538
541
|
}
|
|
539
|
-
createCriteria(e) {
|
|
540
|
-
return this._getScope().createCriteria(e);
|
|
542
|
+
createCriteria(e, t) {
|
|
543
|
+
return this._getScope().createCriteria(e, t);
|
|
544
|
+
}
|
|
545
|
+
createGrouping(e, t) {
|
|
546
|
+
return this._getScope().createGrouping(e, t);
|
|
541
547
|
}
|
|
542
548
|
parseAsLiteral(e) {
|
|
543
549
|
const t = this._getScope();
|
|
544
|
-
return t.parseAsLiteral ? t.parseAsLiteral(e) :
|
|
550
|
+
return t.parseAsLiteral ? t.parseAsLiteral(e) : R.parseAsLiteral(e);
|
|
545
551
|
}
|
|
546
552
|
toText(e) {
|
|
547
553
|
return this._getScope().toText(e);
|
|
@@ -564,15 +570,30 @@ var b = class {
|
|
|
564
570
|
getNow() {
|
|
565
571
|
return this._getScope().getNow();
|
|
566
572
|
}
|
|
573
|
+
getRandom() {
|
|
574
|
+
return this._getScope().getRandom?.() ?? Math.random();
|
|
575
|
+
}
|
|
567
576
|
createRange(e, t, r) {
|
|
568
577
|
return this._getScope().createRange(e, t, r);
|
|
569
578
|
}
|
|
579
|
+
flattenAreas(e) {
|
|
580
|
+
if (!Array.isArray(e)) return e;
|
|
581
|
+
const t = [];
|
|
582
|
+
for (let r = 0; r < e.length; r++) {
|
|
583
|
+
const o = e[r], { rows: n, columns: s } = o.getShape();
|
|
584
|
+
for (let e = 0; e < n; e++) for (let r = 0; r < s; r++) t.push(o.getValueAt(e, r));
|
|
585
|
+
}
|
|
586
|
+
return this.createRange(t.length, 1, (e, r) => t[r.rowIndex]);
|
|
587
|
+
}
|
|
570
588
|
getRow() {
|
|
571
589
|
return this._getScope().getRow?.() ?? 0;
|
|
572
590
|
}
|
|
573
591
|
getColumn() {
|
|
574
592
|
return this._getScope().getColumn?.() ?? 0;
|
|
575
593
|
}
|
|
594
|
+
isImplicitIntersect() {
|
|
595
|
+
return this._getScope().isImplicitIntersect?.() ?? !1;
|
|
596
|
+
}
|
|
576
597
|
getReference(e, t) {
|
|
577
598
|
return this._getScope().getReference(e, t);
|
|
578
599
|
}
|
|
@@ -613,14 +634,14 @@ var b = class {
|
|
|
613
634
|
return this._getScope().getAddress(e, t);
|
|
614
635
|
}
|
|
615
636
|
compare(e, t, r) {
|
|
616
|
-
return this._getScope().compare?.(e, t, r) ??
|
|
637
|
+
return this._getScope().compare?.(e, t, r) ?? R.compare(e, t, r);
|
|
617
638
|
}
|
|
618
639
|
getRuntime() {
|
|
619
640
|
return this._getScope().getRuntime();
|
|
620
641
|
}
|
|
621
642
|
getArgs() {
|
|
622
643
|
const e = this._argsFn, t = e ? e() : null;
|
|
623
|
-
if (!t) throw new
|
|
644
|
+
if (!t) throw new b(N);
|
|
624
645
|
return t;
|
|
625
646
|
}
|
|
626
647
|
get [Symbol.toStringTag]() {
|
|
@@ -629,7 +650,7 @@ var b = class {
|
|
|
629
650
|
toString() {
|
|
630
651
|
return this._getScope()?.toString?.() ?? "{STUB SCOPE}";
|
|
631
652
|
}
|
|
632
|
-
},
|
|
653
|
+
}, F = Object.freeze({
|
|
633
654
|
tag: "en-US",
|
|
634
655
|
numberingSystem: "latn",
|
|
635
656
|
decimal: ".",
|
|
@@ -709,5 +730,5 @@ var b = class {
|
|
|
709
730
|
sensitivity: "base",
|
|
710
731
|
numeric: !0
|
|
711
732
|
})
|
|
712
|
-
}),
|
|
713
|
-
export {
|
|
733
|
+
}), T = new x();
|
|
734
|
+
export { F as DEFAULT_LOCALE_PROFILE, T as FormulaContext, n as FormulaError, t as IRange, o as IRangeStats, a as InteropScalarType, w as Observable, e as Scalar, s as ScalarType, x as ScopedFormulaContext, f as StubbedFormulaContext, i as ValueKind, l as WildCard, d as isLazyValue };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheetxl/primitives",
|
|
3
3
|
"description": "Primitives - Base types for SheetXL functions.",
|
|
4
|
-
"version": "0.8.0-beta.
|
|
4
|
+
"version": "0.8.0-beta.10",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
"types": "./types/index.d.ts",
|
|
10
10
|
"browser": "./browser/esm/index.mjs",
|
|
11
11
|
"node": "./node/esm/index.mjs",
|
|
12
|
-
"
|
|
13
|
-
"require": "./browser/cjs/index.cjs"
|
|
12
|
+
"default": "./browser/esm/index.mjs"
|
|
14
13
|
}
|
|
15
14
|
},
|
|
16
15
|
"types": "./types/index.d.ts",
|
|
17
16
|
"module": "./browser/esm/index.mjs",
|
|
18
|
-
"main": "./browser/
|
|
17
|
+
"main": "./browser/esm/index.mjs",
|
|
19
18
|
"sideEffects": false,
|
|
20
19
|
"engines": {
|
|
21
20
|
"node": ">=22"
|
|
@@ -1,78 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The one parameter marker that speaks about errors — and it is a RULE, not quite a type. At the
|
|
3
|
+
* type level it is an identity alias (what arrives at any slot may already be an error — `Scalar`
|
|
4
|
+
* says so in its own definition); the marker says the ENGINE DOES NOT AUTO-REJECT a bare error at
|
|
5
|
+
* this slot: it is delivered raw, and the body decides.
|
|
5
6
|
*
|
|
6
|
-
* **
|
|
7
|
-
* flattened members, and range parameters alike propagate the first error — preserving its
|
|
8
|
-
* identity (`#N/A` stays `#N/A`) — and the body never runs. Opt out with {@link AcceptError}.
|
|
9
|
-
* The single exception needs no marker: a `FormulaError.Known`-typed parameter receives
|
|
10
|
-
* errors because the type declares it.
|
|
7
|
+
* **There are two kinds of error, and the marker is about the first only:**
|
|
11
8
|
*
|
|
12
|
-
*
|
|
9
|
+
* 1. an error *instead of* a value or a range — `NA()`, an unresolvable name (`#NAME?`), a
|
|
10
|
+
* union `(A1,C1)` where one rectangle is needed;
|
|
11
|
+
* 2. an error *inside* a range — a cell or member holding `#N/A`.
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* | `FormulaError.Known` parameter | receive (the type declares it) | — |
|
|
13
|
+
* The engine never delivers the first unless the slot declares {@link AcceptError} — any `T`,
|
|
14
|
+
* one meaning. Without the marker the error propagates with its identity (`#N/A` stays `#N/A`)
|
|
15
|
+
* and the body never runs: as the call's answer for a scalar argument, as an error MEMBER of the
|
|
16
|
+
* output under a lift, as the first error in argument order for a flattened list. The single
|
|
17
|
+
* exception needs no marker: a `FormulaError.Known`-typed parameter receives errors because the
|
|
18
|
+
* type declares it.
|
|
21
19
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
20
|
+
* The second is never the engine's business. A valid range is handed over whole, marker or no
|
|
21
|
+
* marker, and a body that cares asks:
|
|
24
22
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* if (range.hasError()) return range.firstError();
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* placed before its own validation where Excel's error outranks it (`LARGE(range-with-#N/A, 0)`
|
|
28
|
+
* is `#N/A`, not `#NUM!`). Aggregators and consumers say it; reshapers and lookups, whose members
|
|
29
|
+
* pass through or are never read, need no line at all. Where a function takes several ranges the
|
|
30
|
+
* lines run in ARGUMENT order — the whole of argument N before N+1, row-major within — which is
|
|
31
|
+
* Excel's which-error-wins order, and a function that pairs its ranges (the paired
|
|
32
|
+
* statistics) orders its own scan the way it pairs.
|
|
27
33
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* `IRange.hasError()` — raw stored members only, same definition as
|
|
31
|
-
* `getStats().getTypedCounts([ScalarType.Error])`.
|
|
34
|
+
* > *A bare error propagates unless your function opts in to seeing it; the members of a range
|
|
35
|
+
* > are yours.*
|
|
32
36
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* their in-body, data-dependent policy), counters (COUNT, COUNTA), and the error handlers
|
|
39
|
-
* themselves (IS*, IFERROR…).
|
|
37
|
+
* There is no marker for the default. A `RejectError<T>` alias existed and declared nothing the
|
|
38
|
+
* engine did not already do, so it was removed rather than left as a second way to say nothing.
|
|
39
|
+
* `AcceptRefError<T>`, which split the policy by argument shape, retired with the engine's member
|
|
40
|
+
* scan: its range form is this default, and its scalar form (the database `field`) is a range
|
|
41
|
+
* slot whose body reads the one cell.
|
|
40
42
|
*/
|
|
41
43
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* The engine does not auto-reject a bare error at this parameter: it is delivered RAW — a
|
|
45
|
+
* `FormulaError.Known`, never boxed as a 1×1 range — and the body narrows with
|
|
46
|
+
* `FormulaError.isError` (if it cares). A raw error is therefore never confusable with a
|
|
47
|
+
* one-cell range holding an error MEMBER: the two kinds this file keeps apart stay apart in the
|
|
48
|
+
* value itself, and members are no engine concern at all. For the functions whose job is to
|
|
49
|
+
* inspect, replace, or count errors — the IS* family, IFERROR, ERROR.TYPE, TYPE, COUNT and
|
|
50
|
+
* COUNTA — for the binders (`LET`, `LAMBDA`), whose value slots carry an argument unevaluated,
|
|
51
|
+
* and for a body that owns a reading ORDER or a LIFT the engine cannot see (SERIESSUM's
|
|
52
|
+
* coefficients; CONCATENATE broadcasts the error over its lifted ranges, so the SHAPE of the
|
|
53
|
+
* answer is the marker's work).
|
|
47
54
|
*
|
|
48
|
-
* On a TYPED parameter (`IRange<number>`)
|
|
49
|
-
*
|
|
55
|
+
* On a TYPED range parameter (`IRange<number>`) the marker also lets error members and failed
|
|
56
|
+
* coercions ride through the typed read as raw members — COUNT ignores them, COUNTA counts them.
|
|
57
|
+
* On an untyped range it changes nothing about members: they arrive raw either way.
|
|
50
58
|
*
|
|
51
59
|
* @example
|
|
52
60
|
* ```ts
|
|
53
61
|
* export function ISERROR(value: AcceptError<Scalar>): Scalar { ... }
|
|
54
62
|
* export function IFERROR(value: AcceptError<Scalar>, valueIfError: AcceptError<Scalar>): Scalar { ... }
|
|
55
63
|
* // Both parameters: an unused error fallback must pass through untouched (IFERROR(5,NA()) → 5).
|
|
56
|
-
* export function
|
|
57
|
-
* //
|
|
64
|
+
* export function COUNT(number: AcceptError<IRange<number>>[]): number { ... }
|
|
65
|
+
* // COUNT(NA()) is 0: the error is a value, and not a number.
|
|
58
66
|
* ```
|
|
59
67
|
*/
|
|
60
68
|
export type AcceptError<T> = T;
|
|
61
|
-
/**
|
|
62
|
-
* Splits the policy by the ARGUMENT'S SHAPE: a **direct or computed** error rejects (propagates
|
|
63
|
-
* with its identity, exactly the default), while a **reference-shaped** one is accepted and the
|
|
64
|
-
* body receives it raw. "Direct" is the same runtime-shape test the coercion uses — a scalar,
|
|
65
|
-
* typed or computed; a reference or a computed array is not (`isDirectArg` in `TypedFunction`).
|
|
66
|
-
*
|
|
67
|
-
* ```
|
|
68
|
-
* =DSUM(A1:B3,NA(),G1:G2) #N/A direct — rejects, identity preserved
|
|
69
|
-
* =DSUM(A1:B3,NA()+0,G1:G2) #N/A computed — still direct
|
|
70
|
-
* =DSUM(A1:B3,E1,G1:G2) #VALUE! E1=#N/A — reference: body remaps
|
|
71
|
-
* =DSUM(A1:B3,E2,G1:G2) #VALUE! E2=#DIV/0!
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
* A body under this marker MUST handle the error it may now receive; a `FormulaError` reaching
|
|
75
|
-
* an unguarded body is the item 18 hazard.
|
|
76
|
-
*/
|
|
77
|
-
export type AcceptRefError<T> = T;
|
|
78
69
|
//# sourceMappingURL=ErrorPolicy.d.ts.map
|
package/types/src/Flatten.d.ts
CHANGED
|
@@ -18,8 +18,11 @@
|
|
|
18
18
|
*
|
|
19
19
|
* Both are the same mechanism at different granularity — the marshaller picks the unit from the
|
|
20
20
|
* element type — and a blank drops out of either. The scalar case is the common one; the range case
|
|
21
|
-
* exists because a reference UNION is a single argument holding several areas
|
|
22
|
-
*
|
|
21
|
+
* exists because a reference UNION is a single argument holding several areas: a parameter that does
|
|
22
|
+
* not declare `Flatten` refuses one outright (`#VALUE!` — `TRANSPOSE((A1:A3,C1:C3))` in Excel), and a
|
|
23
|
+
* body that declares it answers for the union itself, in one line, the way Excel's own do:
|
|
24
|
+
* `AREAS` counts the areas, `SUM` adds them, `ROWS` answers `#REF!` to more than one, the lookups
|
|
25
|
+
* `#N/A`.
|
|
23
26
|
*
|
|
24
27
|
* At the type level it is `T[]`, so the body reads the list directly.
|
|
25
28
|
*
|
|
@@ -27,7 +30,7 @@
|
|
|
27
30
|
* ```ts
|
|
28
31
|
* export function IRR(values: Flatten<number>, guess?: number): number { ... }
|
|
29
32
|
* export function NETWORKDAYS(start: Date, end: Date, holidays?: Flatten<Scalar>): number { ... }
|
|
30
|
-
* export function INDEX(array: Flatten<
|
|
33
|
+
* export function INDEX(array: Flatten<IRange>, rowNum?: number, ...): any { ... }
|
|
31
34
|
* ```
|
|
32
35
|
*/
|
|
33
36
|
export type Flatten<T> = T[];
|