@sheetxl/primitives 0.8.0-beta.1 → 0.8.0-beta.2
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/cjs/index.cjs +1 -1
- package/browser/esm/index.mjs +88 -73
- package/node/esm/index.mjs +98 -83
- package/package.json +1 -1
- package/types/src/ErrorPolicy.d.ts +48 -57
- package/types/src/Flatten.d.ts +6 -3
- package/types/src/FormulaContext.d.ts +19 -5
- package/types/src/IFormulaContext.d.ts +83 -7
- package/types/src/IFunction.d.ts +339 -44
- package/types/src/IFunctionArguments.d.ts +64 -15
- package/types/src/IRange.d.ts +152 -38
- package/types/src/IRangeStats.d.ts +32 -2
- 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/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.2
|
|
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,19 @@ 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();
|
|
464
463
|
}
|
|
465
464
|
parseAsLiteral(e) {
|
|
466
465
|
const t = e.toUpperCase();
|
|
@@ -475,10 +474,10 @@ var b = class {
|
|
|
475
474
|
return o !== n ? o < n ? -1 : 1 : e < t ? -1 : e > t ? 1 : 0;
|
|
476
475
|
}
|
|
477
476
|
getRuntime() {
|
|
478
|
-
return
|
|
477
|
+
return D;
|
|
479
478
|
}
|
|
480
479
|
getArgs() {
|
|
481
|
-
throw new
|
|
480
|
+
throw new b(N);
|
|
482
481
|
}
|
|
483
482
|
}, y = (e) => {
|
|
484
483
|
if (null == e) return 0;
|
|
@@ -488,32 +487,33 @@ var b = class {
|
|
|
488
487
|
case "boolean": return 3;
|
|
489
488
|
default: return 4;
|
|
490
489
|
}
|
|
491
|
-
},
|
|
490
|
+
}, N = "FormulaContext.getArgs() is only valid while a function body is running", b = class extends Error {
|
|
492
491
|
constructor(e = "Not implemented in StubbedFormulaContext") {
|
|
493
492
|
super(e), this.name = "NotImplementedError";
|
|
494
493
|
}
|
|
495
|
-
},
|
|
494
|
+
}, A = Object.freeze({
|
|
496
495
|
colStart: 0,
|
|
497
496
|
rowStart: 0,
|
|
498
497
|
colEnd: Math.pow(2, 14) - 1,
|
|
499
498
|
rowEnd: Math.pow(2, 20) - 1
|
|
500
|
-
}),
|
|
499
|
+
}), D = {
|
|
501
500
|
isDate1904: () => !1,
|
|
502
|
-
getLocale: () =>
|
|
503
|
-
getLocaleProfile: () =>
|
|
501
|
+
getLocale: () => F.tag,
|
|
502
|
+
getLocaleProfile: () => F,
|
|
504
503
|
isR1C1: () => !1,
|
|
505
504
|
getNow: () => 0,
|
|
505
|
+
getRandom: () => Math.random(),
|
|
506
506
|
getLocation: () => "unknown",
|
|
507
507
|
getVersion: () => "1.0.0",
|
|
508
508
|
getOS: () => "unknown",
|
|
509
509
|
getUser: () => "unidentified",
|
|
510
510
|
getDescription: () => "Stubbed Formula Context"
|
|
511
|
-
},
|
|
511
|
+
}, _ = 2958465, R = new f(), x = class {
|
|
512
512
|
constructor() {
|
|
513
|
-
this._scope =
|
|
513
|
+
this._scope = R, this._argsFn = null;
|
|
514
514
|
}
|
|
515
515
|
_setScope(e) {
|
|
516
|
-
this._scope = e ??
|
|
516
|
+
this._scope = e ?? R;
|
|
517
517
|
}
|
|
518
518
|
_getScope() {
|
|
519
519
|
return this._scope;
|
|
@@ -525,7 +525,7 @@ var b = class {
|
|
|
525
525
|
return this._getScope().getNumberFormat(e, t);
|
|
526
526
|
}
|
|
527
527
|
getEntireCoords() {
|
|
528
|
-
return this._getScope().getEntireCoords() ??
|
|
528
|
+
return this._getScope().getEntireCoords() ?? A;
|
|
529
529
|
}
|
|
530
530
|
parseAsSerialDate(e, t) {
|
|
531
531
|
return this._getScope().parseAsSerialDate(e, t);
|
|
@@ -536,12 +536,12 @@ var b = class {
|
|
|
536
536
|
parseAsNumber(e, t) {
|
|
537
537
|
return this._getScope().parseAsNumber(e, t);
|
|
538
538
|
}
|
|
539
|
-
createCriteria(e) {
|
|
540
|
-
return this._getScope().createCriteria(e);
|
|
539
|
+
createCriteria(e, t) {
|
|
540
|
+
return this._getScope().createCriteria(e, t);
|
|
541
541
|
}
|
|
542
542
|
parseAsLiteral(e) {
|
|
543
543
|
const t = this._getScope();
|
|
544
|
-
return t.parseAsLiteral ? t.parseAsLiteral(e) :
|
|
544
|
+
return t.parseAsLiteral ? t.parseAsLiteral(e) : R.parseAsLiteral(e);
|
|
545
545
|
}
|
|
546
546
|
toText(e) {
|
|
547
547
|
return this._getScope().toText(e);
|
|
@@ -564,15 +564,30 @@ var b = class {
|
|
|
564
564
|
getNow() {
|
|
565
565
|
return this._getScope().getNow();
|
|
566
566
|
}
|
|
567
|
+
getRandom() {
|
|
568
|
+
return this._getScope().getRandom?.() ?? Math.random();
|
|
569
|
+
}
|
|
567
570
|
createRange(e, t, r) {
|
|
568
571
|
return this._getScope().createRange(e, t, r);
|
|
569
572
|
}
|
|
573
|
+
flattenAreas(e) {
|
|
574
|
+
if (!Array.isArray(e)) return e;
|
|
575
|
+
const t = [];
|
|
576
|
+
for (let r = 0; r < e.length; r++) {
|
|
577
|
+
const o = e[r], { rows: n, columns: s } = o.getShape();
|
|
578
|
+
for (let e = 0; e < n; e++) for (let r = 0; r < s; r++) t.push(o.getValueAt(e, r));
|
|
579
|
+
}
|
|
580
|
+
return this.createRange(t.length, 1, (e, r) => t[r.rowIndex]);
|
|
581
|
+
}
|
|
570
582
|
getRow() {
|
|
571
583
|
return this._getScope().getRow?.() ?? 0;
|
|
572
584
|
}
|
|
573
585
|
getColumn() {
|
|
574
586
|
return this._getScope().getColumn?.() ?? 0;
|
|
575
587
|
}
|
|
588
|
+
isImplicitIntersect() {
|
|
589
|
+
return this._getScope().isImplicitIntersect?.() ?? !1;
|
|
590
|
+
}
|
|
576
591
|
getReference(e, t) {
|
|
577
592
|
return this._getScope().getReference(e, t);
|
|
578
593
|
}
|
|
@@ -613,14 +628,14 @@ var b = class {
|
|
|
613
628
|
return this._getScope().getAddress(e, t);
|
|
614
629
|
}
|
|
615
630
|
compare(e, t, r) {
|
|
616
|
-
return this._getScope().compare?.(e, t, r) ??
|
|
631
|
+
return this._getScope().compare?.(e, t, r) ?? R.compare(e, t, r);
|
|
617
632
|
}
|
|
618
633
|
getRuntime() {
|
|
619
634
|
return this._getScope().getRuntime();
|
|
620
635
|
}
|
|
621
636
|
getArgs() {
|
|
622
637
|
const e = this._argsFn, t = e ? e() : null;
|
|
623
|
-
if (!t) throw new
|
|
638
|
+
if (!t) throw new b(N);
|
|
624
639
|
return t;
|
|
625
640
|
}
|
|
626
641
|
get [Symbol.toStringTag]() {
|
|
@@ -629,7 +644,7 @@ var b = class {
|
|
|
629
644
|
toString() {
|
|
630
645
|
return this._getScope()?.toString?.() ?? "{STUB SCOPE}";
|
|
631
646
|
}
|
|
632
|
-
},
|
|
647
|
+
}, F = Object.freeze({
|
|
633
648
|
tag: "en-US",
|
|
634
649
|
numberingSystem: "latn",
|
|
635
650
|
decimal: ".",
|
|
@@ -709,5 +724,5 @@ var b = class {
|
|
|
709
724
|
sensitivity: "base",
|
|
710
725
|
numeric: !0
|
|
711
726
|
})
|
|
712
|
-
}),
|
|
713
|
-
export {
|
|
727
|
+
}), T = new x();
|
|
728
|
+
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,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[];
|
|
@@ -21,6 +21,8 @@ import { LocaleProfile } from './LocaleProfile';
|
|
|
21
21
|
export declare class StubbedFormulaContext implements IFormulaContext {
|
|
22
22
|
/** @inheritdoc IFormulaContext.createRange */
|
|
23
23
|
createRange<TS extends Scalar = Scalar>(rows?: number, columns?: number, values?: Scalar | Scalar[][] | ((value: TS, coords: IRange.CellCoords, range: IRange<TS>) => TS)): IRange;
|
|
24
|
+
/** @inheritdoc IFormulaContext.flattenAreas */
|
|
25
|
+
flattenAreas(value: IRange | IRange[]): IRange;
|
|
24
26
|
/** @inheritdoc IFormulaContext.getReference */
|
|
25
27
|
getReference(coords?: Readonly<IRange.Coords>, r1c1?: boolean): IReferenceRange;
|
|
26
28
|
/** @inheritdoc IFormulaContext.getResizedReference */
|
|
@@ -37,6 +39,8 @@ export declare class StubbedFormulaContext implements IFormulaContext {
|
|
|
37
39
|
getSerialDate(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millis?: number): number;
|
|
38
40
|
/** @inheritdoc IFormulaContext.getNow */
|
|
39
41
|
getNow(): number;
|
|
42
|
+
/** @inheritdoc IFormulaContext.getRandom */
|
|
43
|
+
getRandom(): number;
|
|
40
44
|
/** @inheritdoc IFormulaContext.getValueAt */
|
|
41
45
|
getValueAt(row: number, column: number, sheetName?: string, options?: IRange.ValueOptions): Scalar | null;
|
|
42
46
|
/** @inheritdoc IFormulaContext.getEntireCoords */
|
|
@@ -47,6 +51,8 @@ export declare class StubbedFormulaContext implements IFormulaContext {
|
|
|
47
51
|
getRow(): number;
|
|
48
52
|
/** @inheritdoc IFormulaContext.getColumn */
|
|
49
53
|
getColumn(): number;
|
|
54
|
+
/** @inheritdoc IFormulaContext.isImplicitIntersect */
|
|
55
|
+
isImplicitIntersect(): boolean;
|
|
50
56
|
/** @inheritdoc IFormulaContext.getFormulaAt */
|
|
51
57
|
getFormulaAt(row: number, column: number, sheetName?: string): string | null;
|
|
52
58
|
/** @inheritdoc IFormulaContext.getSpillAt */
|
|
@@ -83,7 +89,7 @@ export declare class StubbedFormulaContext implements IFormulaContext {
|
|
|
83
89
|
* plausibly and wrongly, where throwing names the actual mistake (evaluating criteria outside an
|
|
84
90
|
* installed scope).
|
|
85
91
|
*/
|
|
86
|
-
createCriteria(criteria: Scalar): IFormulaContext.CriteriaEvaluator;
|
|
92
|
+
createCriteria(criteria: Scalar, options?: IFormulaContext.CriteriaOptions): IFormulaContext.CriteriaEvaluator;
|
|
87
93
|
/**
|
|
88
94
|
* Parses the canonical English boolean and error literals.
|
|
89
95
|
* See {@link IFormulaContext.parseAsLiteral}.
|
|
@@ -171,7 +177,7 @@ export declare class ScopedFormulaContext implements IFormulaContext {
|
|
|
171
177
|
parseAsNumber(textOrNumber: Scalar, options?: IFormulaContext.ParseNumberOptions): number;
|
|
172
178
|
parseAsNumber(textOrNumber: Scalar | undefined, options?: IFormulaContext.ParseNumberOptions): number | undefined;
|
|
173
179
|
/** @inheritdoc IFormulaContext.createCriteria */
|
|
174
|
-
createCriteria(criteria: Scalar): IFormulaContext.CriteriaEvaluator;
|
|
180
|
+
createCriteria(criteria: Scalar, options?: IFormulaContext.CriteriaOptions): IFormulaContext.CriteriaEvaluator;
|
|
175
181
|
/** @inheritdoc IFormulaContext.parseAsLiteral */
|
|
176
182
|
parseAsLiteral(text: string): boolean | FormulaError.Known | undefined;
|
|
177
183
|
/** @inheritdoc IFormulaContext.toText */
|
|
@@ -188,12 +194,18 @@ export declare class ScopedFormulaContext implements IFormulaContext {
|
|
|
188
194
|
getSerialDate(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millis?: number): number;
|
|
189
195
|
/** @inheritdoc IFormulaContext.getNow */
|
|
190
196
|
getNow(): number;
|
|
197
|
+
/** @inheritdoc IFormulaContext.getRandom */
|
|
198
|
+
getRandom(): number;
|
|
191
199
|
/** @inheritdoc IFormulaContext.createRange */
|
|
192
200
|
createRange<TS extends Scalar = Scalar>(rows?: number, columns?: number, values?: Scalar | Scalar[][] | ((value: TS, coords: IRange.CellCoords, range: IRange<TS>) => TS)): IRange;
|
|
201
|
+
/** @inheritdoc IFormulaContext.flattenAreas */
|
|
202
|
+
flattenAreas(value: IRange | IRange[]): IRange;
|
|
193
203
|
/** @inheritdoc IFormulaContext.getRow */
|
|
194
204
|
getRow(): number;
|
|
195
205
|
/** @inheritdoc IFormulaContext.getColumn */
|
|
196
206
|
getColumn(): number;
|
|
207
|
+
/** @inheritdoc IFormulaContext.isImplicitIntersect */
|
|
208
|
+
isImplicitIntersect(): boolean;
|
|
197
209
|
/** @inheritdoc IFormulaContext.getReference */
|
|
198
210
|
getReference(coords?: Readonly<IRange.Coords>, r1c1?: boolean): IReferenceRange;
|
|
199
211
|
/** @inheritdoc IFormulaContext.getResizedReference */
|
|
@@ -232,13 +244,15 @@ export declare class ScopedFormulaContext implements IFormulaContext {
|
|
|
232
244
|
/**
|
|
233
245
|
* A plain en-US profile, for stubs and for environments without `Intl`.
|
|
234
246
|
*
|
|
235
|
-
* @
|
|
236
|
-
*
|
|
237
|
-
* `makeLocaleProfile` in `@sheetxl/sdk`.
|
|
247
|
+
* @internal
|
|
248
|
+
* @hidden
|
|
238
249
|
*/
|
|
239
250
|
export declare const DEFAULT_LOCALE_PROFILE: LocaleProfile;
|
|
240
251
|
/**
|
|
241
252
|
* The shared {@link IFormulaContext} for formula implementations. See {@link ScopedFormulaContext}.
|
|
253
|
+
*
|
|
254
|
+
* @internal
|
|
255
|
+
* @hidden
|
|
242
256
|
*/
|
|
243
257
|
export declare const FormulaContext: IFormulaContext;
|
|
244
258
|
//# sourceMappingURL=FormulaContext.d.ts.map
|