@sheetxl/primitives 0.7.28-beta.4 → 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 +101 -55
- package/node/esm/index.mjs +115 -67
- 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 +47 -7
- package/types/src/IFormulaContext.d.ts +223 -11
- package/types/src/IFunction.d.ts +368 -39
- package/types/src/IFunctionArguments.d.ts +214 -0
- package/types/src/IRange.d.ts +199 -40
- 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 +7 -0
- package/browser/cjs/index.cjs +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declares a parameter the engine may hand over UNEVALUATED — the argument's subtree is not run
|
|
3
|
+
* before the call, and it runs only if this call's answer needs it.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* An argument that is a bare reference has always been cheap to ignore: it resolves into a
|
|
7
|
+
* register and a body that never reads it never dereferences it. An argument that is an
|
|
8
|
+
* EXPRESSION is not — `IF(FALSE,B1+1,1)` evaluates `B1+1` before `IF` runs, so the untaken branch
|
|
9
|
+
* opens `B1` anyway. That is a correctness difference and not a cost one: a read is what decides
|
|
10
|
+
* a circular reference and what registers a volatile, so an arm nobody takes can report a cycle
|
|
11
|
+
* the sheet does not have.
|
|
12
|
+
*
|
|
13
|
+
* The marker is what closes it, and it is a CONTRACT rather than an inference. Nothing in
|
|
14
|
+
* JavaScript intercepts a plain parameter read, so a body holding a deferred value is only safe
|
|
15
|
+
* while it never touches it — which the declaration has to say out loud:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* export function IF(
|
|
19
|
+
* logicalTest: boolean,
|
|
20
|
+
* valueIfTrue: Lazy<AcceptError<any>>,
|
|
21
|
+
* valueIfFalse: Lazy<AcceptError<any>, false>
|
|
22
|
+
* ): any {
|
|
23
|
+
* return logicalTest ? valueIfTrue : valueIfFalse;
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The parameter is ALWAYS an {@link ILazy} handle and never a union with the bare value, so the
|
|
28
|
+
* body has two things it may do with it and the type says which is which:
|
|
29
|
+
*
|
|
30
|
+
* - **return it unread**, which is what every branch-selecting function does. The engine
|
|
31
|
+
* recognizes its own handle coming back as the call's result and evaluates that subtree then.
|
|
32
|
+
* - **read it** with {@link ILazy.getValue}, which forces the subtree in place. Synchronous only:
|
|
33
|
+
* the engine is mid-formula there and has no way to wait, so an ASYNC subtree at a forced
|
|
34
|
+
* handle is an error rather than a wrong answer.
|
|
35
|
+
*
|
|
36
|
+
* Only the RESULT positions are marked. A condition, an index and a case value are eager, which
|
|
37
|
+
* is what keeps `AND(FALSE,A1)` a circular reference: laziness is a property of what the function
|
|
38
|
+
* READS, not of the syntax around it.
|
|
39
|
+
*
|
|
40
|
+
* The engine may DECLINE to defer at any time and hand the body a handle that is already full —
|
|
41
|
+
* an absent argument, an async subtree, a lift that needs every arm anyway. `getValue()` then
|
|
42
|
+
* returns the value it was built with. The author cannot tell the two apart and must not try.
|
|
43
|
+
*
|
|
44
|
+
* @typeParam T - what the argument evaluates to; the marker is otherwise transparent.
|
|
45
|
+
* @typeParam V - what an ABSENT argument means, as a literal. It replaces the `= false`
|
|
46
|
+
* initializer an ordinary parameter would carry, which cannot typecheck against a handle;
|
|
47
|
+
* declaring it makes the parameter optional and the engine supplies the value, so the body
|
|
48
|
+
* still sees nothing but a handle.
|
|
49
|
+
*
|
|
50
|
+
* @see {@link IFunction.ParameterTypeJSON.lazy}
|
|
51
|
+
*/
|
|
52
|
+
export type Lazy<T, V = never> = ILazy<T | V>;
|
|
53
|
+
/**
|
|
54
|
+
* The handle a {@link Lazy} parameter receives: an argument's subtree, anchored at the calling
|
|
55
|
+
* cell, that has either not been evaluated yet or has been evaluated already.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* The brand exists for the same reason {@link Lambda}'s does — the value-layer sites (coercion,
|
|
59
|
+
* the operators, a range's typed read, a cell's final value) RECOGNIZE a handle and refuse it, so
|
|
60
|
+
* that one can never reach a grid, a spill or a named-formula result. A handle is only ever a
|
|
61
|
+
* live call's argument.
|
|
62
|
+
*/
|
|
63
|
+
export interface ILazy<T = any> {
|
|
64
|
+
/** The brand itself — the property every recognizing site reads. */
|
|
65
|
+
readonly isLazy: true;
|
|
66
|
+
/**
|
|
67
|
+
* Evaluates the argument and answers its value, forcing the subtree where the engine deferred
|
|
68
|
+
* it and answering the value it already has where it declined to.
|
|
69
|
+
*
|
|
70
|
+
* Forced at most once: a second call answers the same value.
|
|
71
|
+
*/
|
|
72
|
+
getValue(): T;
|
|
73
|
+
}
|
|
74
|
+
/** `true` for a deferred-argument handle — see {@link ILazy}. */
|
|
75
|
+
export declare const isLazyValue: (value: unknown) => value is ILazy;
|
|
76
|
+
//# sourceMappingURL=Lazy.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declares that the members reaching a REPEATING scalar parameter are COERCED rather than
|
|
3
|
+
* filtered — one that cannot be coerced is `#VALUE!` for the whole call.
|
|
4
|
+
*
|
|
5
|
+
* The native functions FILTER: `SUM({1,"8",TRUE})` is 1, the text and the boolean skipped, and a
|
|
6
|
+
* blank cell contributes nothing. Excel's Analysis-ToolPak heritage coerces at the slot instead,
|
|
7
|
+
* and the difference is visible in both directions:
|
|
8
|
+
*
|
|
9
|
+
* | argument | native (`SUM`) | this marker (`GCD`) |
|
|
10
|
+
* | --- | --- | --- |
|
|
11
|
+
* | numeric text, `{6,"8",12}` | skipped | parses — `GCD({6,"8",12})` is 2 |
|
|
12
|
+
* | a boolean, `{6,TRUE,12}` | skipped | `#VALUE!` for the whole call |
|
|
13
|
+
* | a blank inside a multi-cell range | skipped | reads 0 — `LCM(6,A1:A2)` is 0 |
|
|
14
|
+
*
|
|
15
|
+
* A DIRECT argument follows the same rule (`GCD(6,TRUE,12)` is `#VALUE!` where `SUM(6,TRUE,12)`
|
|
16
|
+
* is 19). A one-cell blank reference and an omitted argument are still skipped either way: they
|
|
17
|
+
* never became members.
|
|
18
|
+
*
|
|
19
|
+
* Only a repeating slot has members to filter, so the marker means nothing on a plain scalar,
|
|
20
|
+
* range or lambda parameter and the linter refuses it there. It is the repeating counterpart of
|
|
21
|
+
* {@link NoLift}, which is the same heritage's reading of a NON-repeating scalar slot.
|
|
22
|
+
*
|
|
23
|
+
* It may be written over the group or on the slot — `NoFilter<number[]>` and `NoFilter<number>[]`
|
|
24
|
+
* mean the same thing, as they do for `AcceptError`.
|
|
25
|
+
*
|
|
26
|
+
* At the type level it is `T`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* export function GCD(number: NoFilter<number>[]): number { ... }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type NoFilter<T> = T;
|
|
34
|
+
//# sourceMappingURL=NoFilter.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declares that a SCALAR parameter refuses a multi-cell REFERENCE with `#VALUE!` instead of
|
|
3
|
+
* broadcasting over it.
|
|
4
|
+
*
|
|
5
|
+
* The native functions lift: `ROUND(B1:B3,3)` spills three results. Excel's Analysis-ToolPak
|
|
6
|
+
* heritage refuses at the slot instead — `EDATE(A1:A3,1)` is `#VALUE!` — and the refusal is per
|
|
7
|
+
* PARAMETER: `NETWORKDAYS.INTL` refuses a reference at its two date slots and lifts one at its
|
|
8
|
+
* `weekend` slot. Three qualifications:
|
|
9
|
+
*
|
|
10
|
+
* | argument at the slot | answer |
|
|
11
|
+
* | --- | --- |
|
|
12
|
+
* | a multi-cell REFERENCE, `A1:A3` | `#VALUE!` — the call never runs |
|
|
13
|
+
* | an ARRAY, `{3,4,5}` | lifts as usual (`MROUND({3,4,5},5)` spills) |
|
|
14
|
+
* | a one-cell reference or a value | an ordinary argument |
|
|
15
|
+
*
|
|
16
|
+
* Only a scalar slot can lift, so the marker means nothing on a range, list or lambda parameter
|
|
17
|
+
* and the linter refuses it there. A REPEATING scalar slot is also never this marker's business —
|
|
18
|
+
* it absorbs a container as members whatever the function's heritage (`GCD(C1:C3)` is 4); its
|
|
19
|
+
* ATP reading is `NoFilter<T>`.
|
|
20
|
+
*
|
|
21
|
+
* At the type level it is `T`.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* export function NETWORKDAYS_INTL(
|
|
26
|
+
* startDate: NoLift<Scalar>, endDate: NoLift<Scalar>, weekend?: Scalar, holidays?: Flatten<Scalar>
|
|
27
|
+
* ): number { ... }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export type NoLift<T> = T;
|
|
31
|
+
//# sourceMappingURL=NoLift.d.ts.map
|
package/types/src/Repeating.d.ts
CHANGED
|
@@ -48,19 +48,39 @@
|
|
|
48
48
|
* "the final element of the final group may be omitted" rule; that rule would accept a formula
|
|
49
49
|
* Excel refuses. An optional slot anywhere else in the group is a compiler error.
|
|
50
50
|
*
|
|
51
|
+
* ### The maximum, `Max`
|
|
52
|
+
*
|
|
53
|
+
* The second type argument is the largest number of arguments the WHOLE CALL accepts, which is
|
|
54
|
+
* how Excel states it: one number per NAME, compared against the call's total argument count and
|
|
55
|
+
* refused at entry (`Excess_function_arguments`), never a count of this parameter's own share.
|
|
56
|
+
* `SWITCH`'s 254 therefore covers its `expression` and its trailing `default` as well as the
|
|
57
|
+
* pairs, and `CHOOSEROWS`' covers its `array`.
|
|
58
|
+
*
|
|
59
|
+
* It defaults to **255**, which is the ceiling for most names and the highest any name carries.
|
|
60
|
+
* Declare it only where a name draws the line lower — `XOR`, `IFS`, `SWITCH`, `LAMBDA`, `LET`,
|
|
61
|
+
* `AGGREGATE`, `SORTBY`, `MAXIFS`, `MINIFS`, `CONCAT`, `TEXTJOIN`, `HSTACK`, `VSTACK`,
|
|
62
|
+
* `CHOOSEROWS`, `CHOOSECOLS` and every DOTTED
|
|
63
|
+
* descriptive spelling (`STDEV.S`, `VAR.P`, `MODE.MULT`, …) all stop at 254 where their legacy
|
|
64
|
+
* twins take 255. It cannot be derived from the shape, so it belongs to the declaration.
|
|
65
|
+
*
|
|
66
|
+
* A REST parameter is the one place `Repeating` may be written alongside `...`, and only with an
|
|
67
|
+
* explicit `Max`: `...rest: Repeating<T, 254>` keeps the rest parameter's own 0-or-more meaning
|
|
68
|
+
* and adds nothing but the ceiling. A bare `Repeating<T>` on a rest parameter stays an error —
|
|
69
|
+
* that is the spelling collision the marker exists to avoid.
|
|
70
|
+
*
|
|
51
71
|
* @example
|
|
52
72
|
* ```ts
|
|
53
73
|
* export function SUMIFS(
|
|
54
|
-
* sumRange:
|
|
55
|
-
* criteria: Repeating<[criteriaRange:
|
|
74
|
+
* sumRange: IRange,
|
|
75
|
+
* criteria: Repeating<[criteriaRange: IReferenceRange, criteria: AcceptError<Scalar>]>
|
|
56
76
|
* ): IRange {
|
|
57
77
|
* for (const [range, test] of criteria) { ... }
|
|
58
78
|
* }
|
|
59
79
|
*
|
|
60
|
-
* export function HSTACK(array: Repeating<
|
|
80
|
+
* export function HSTACK(array: Repeating<IRange, 254>): IRange {
|
|
61
81
|
* return array.reduce((acc, next) => acc.concat(next, IRange.Axis.Column));
|
|
62
82
|
* }
|
|
63
83
|
* ```
|
|
64
84
|
*/
|
|
65
|
-
export type Repeating<T> = T[];
|
|
85
|
+
export type Repeating<T, Max extends number = 255> = T[];
|
|
66
86
|
//# sourceMappingURL=Repeating.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declares the parameter's type as ADVISORY: the engine delivers it when it can, and hands the
|
|
3
|
+
* body whatever actually arrived when it cannot, instead of answering `#VALUE!` on the body's
|
|
4
|
+
* behalf.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Excel has no marshalling contract. A function there is called with the operands as they are and
|
|
8
|
+
* calls library helpers for whatever it needs — `LARGE` asks for a range's values and gets every
|
|
9
|
+
* area of a union, `ROWS` never dereferences at all and answers `#REF!` when it sees two areas,
|
|
10
|
+
* `SUMPRODUCT` demands one rectangle and fails on the same argument. Three answers, no rule: the
|
|
11
|
+
* body's own access pattern is the whole of it.
|
|
12
|
+
*
|
|
13
|
+
* A declared surface cannot express that, and modelling it would mean a marker per behavior. This
|
|
14
|
+
* is the boundary instead — ONE marker saying "the type is what the caller is told, not a
|
|
15
|
+
* guarantee to the body". The declared `T` still reaches the function help, the wizard and the
|
|
16
|
+
* linter, because that IS what the slot means to a user; it just stops being a gate.
|
|
17
|
+
*
|
|
18
|
+
* | argument | plain `IRange` | `ReportType<IRange>` |
|
|
19
|
+
* | --- | --- | --- |
|
|
20
|
+
* | `A1:A5` | the range | the range |
|
|
21
|
+
* | `(A1:A5,B1:B2)` — a union | `#VALUE!`, the call never runs | the areas, as `IRange[]` |
|
|
22
|
+
* | a value, an error | `#VALUE!` / propagates | the value, the error |
|
|
23
|
+
*
|
|
24
|
+
* At the type level it is `T` — like {@link AcceptError}, and for the same reason: the marker is a
|
|
25
|
+
* RULE, not a type. A body that declares it and then assumes `T` will crash on the argument the
|
|
26
|
+
* marker exists to deliver, so narrow first. {@link IFunctionArguments.getKindAt} is total over
|
|
27
|
+
* what can arrive and {@link IFunctionArguments.getAreaCountAt} answers the union question the
|
|
28
|
+
* kind cannot — a plain reference is one area, a union is more.
|
|
29
|
+
*
|
|
30
|
+
* Its use is meant to stay countable: a slot earns it with a rule Excel actually shows, never
|
|
31
|
+
* with a guess.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* export function ROWS(array: ReportType<IRange>): Scalar {
|
|
36
|
+
* if (FormulaContext.getArgs().getAreaCountAt(0) > 1) return FormulaError.BuiltIn.Ref!;
|
|
37
|
+
* return array.getRowCount();
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export type ReportType<T> = T;
|
|
42
|
+
//# sourceMappingURL=ReportType.d.ts.map
|
package/types/src/Scalar.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export declare namespace Scalar {
|
|
|
42
42
|
* text's shape (decimal places, grouping) survives for format inference.
|
|
43
43
|
*
|
|
44
44
|
* @remarks
|
|
45
|
-
* Callers apply this to every text→number path and to nothing else
|
|
45
|
+
* Callers apply this to every text→number path and to nothing else. It is
|
|
46
46
|
* truncation, not rounding: `1234567890.123456789` stores `…345`, never `…346`.
|
|
47
47
|
*/
|
|
48
48
|
function truncateNumberText(text: string): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The KIND of one value — the total discriminator over {@link IFunctionArguments.RawArg}, and the
|
|
3
|
+
* vocabulary a RETURN declaration speaks ({@link IFunction.IReturnType.getKind}).
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A value's kind and its extent are different axes: `{10}`, `A1` and a bare `10` all reach a
|
|
7
|
+
* range-typed parameter as a 1x1 container, yet Excel separates them:
|
|
8
|
+
* `VLOOKUP(10,10,1,TRUE)` is `#N/A` while `VLOOKUP(10,{10},1,TRUE)` is 10, and `TYPE` answers
|
|
9
|
+
* 1 vs 64. The kind is what the CALLER supplied; the extent is merely its size.
|
|
10
|
+
*
|
|
11
|
+
* The scalar kinds ARE {@link ScalarType} values — one vocabulary, so
|
|
12
|
+
* `getKindAt(i) === ScalarType.Boolean` reads naturally — extended with the four kinds only an
|
|
13
|
+
* argument can be: a reference, a non-reference array, a callable, and no argument at all. As an
|
|
14
|
+
* argument kind, {@link ScalarType.Null} means a BLANK value.
|
|
15
|
+
*
|
|
16
|
+
* The names and values are ours. The numeric codes Excel's `TYPE` function answers are a
|
|
17
|
+
* PROJECTION of this kind (see `TYPE`'s implementation), not the kind itself.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link IFunctionArguments.getKindAt}
|
|
20
|
+
*/
|
|
21
|
+
export declare const ValueKind: {
|
|
22
|
+
/** A reference — `A1`, `A1:B3`, or a reference-returning call (`INDEX`, `OFFSET`, `TAKE`). */
|
|
23
|
+
readonly Reference: "reference";
|
|
24
|
+
/** An ARRAY that is not a reference — `{1,2}`, or a computed one (`SEQUENCE`, `TRANSPOSE(…)`). */
|
|
25
|
+
readonly Array: "array";
|
|
26
|
+
/** A callable — `LAMBDA(…)`, an eta-reduced function name, or a lambda-valued binding. */
|
|
27
|
+
readonly Lambda: "lambda";
|
|
28
|
+
/**
|
|
29
|
+
* OMITTED — nothing at this position: the empty comma of `CUMIPMT(,120,…)`, or a position
|
|
30
|
+
* past what the caller wrote. A blank CELL is a `Reference` (blankness is the cell's value).
|
|
31
|
+
* ABSENT-vs-omitted — whether the position exists in the call at all — is not a kind; it is
|
|
32
|
+
* `index >= getLength()`.
|
|
33
|
+
*/
|
|
34
|
+
readonly Omitted: "omitted";
|
|
35
|
+
readonly Number: "number";
|
|
36
|
+
readonly String: "string";
|
|
37
|
+
readonly Boolean: "boolean";
|
|
38
|
+
readonly Error: "error";
|
|
39
|
+
readonly RichData: "richData";
|
|
40
|
+
readonly Null: "null";
|
|
41
|
+
};
|
|
42
|
+
export type ValueKind = typeof ValueKind[keyof typeof ValueKind];
|
|
43
|
+
//# sourceMappingURL=ValueKind.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declares that a function's RESULT can change with nothing dirty, so a cell naming it
|
|
3
|
+
* recalculates on every pass.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* export function NOW(): Volatile<number> { ... }
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* @see {@link IFunction.ReturnTypeJSON.volatile}
|
|
10
|
+
*/
|
|
11
|
+
export type Volatile<T> = T;
|
|
12
|
+
//# sourceMappingURL=Volatile.d.ts.map
|
package/types/src/WildCard.d.ts
CHANGED
|
@@ -10,17 +10,21 @@ export declare const WildCard: {
|
|
|
10
10
|
/**
|
|
11
11
|
* Compiles Excel wildcard text into a regex.
|
|
12
12
|
*
|
|
13
|
-
* @param anchor
|
|
14
|
-
*
|
|
13
|
+
* @param anchor Where the pattern has to line up: `true` for the WHOLE string, `'start'` for a
|
|
14
|
+
* PREFIX, `false` for anywhere in it. Excel matches a whole cell, so every lookup and criteria
|
|
15
|
+
* caller anchors; `SEARCH`, which looks for a substring, does not; and a `D` function's criteria
|
|
16
|
+
* table is the prefix form — `DSUM` with the criterion `appl` takes the row whose value is
|
|
17
|
+
* `Apple`, where `COUNTIF` with the same criterion takes none.
|
|
15
18
|
*
|
|
16
19
|
* @remarks
|
|
17
|
-
* `~` escapes the next `*`, `?` or `~`;
|
|
18
|
-
* "
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* `~` escapes the next `*`, `?` or `~`; before anything else it is dropped, not kept —
|
|
21
|
+
* `SEARCH("~b","abc")` is 2 and `MATCH("a~b",…)` finds the text `ab`. A caller that reaches this
|
|
22
|
+
* compiler only when the pattern holds a `*` or `?` — which is what COUNTIF and its family do —
|
|
23
|
+
* therefore still compares `"a~b"` literally, because that criteria never becomes a pattern.
|
|
24
|
+
*
|
|
25
|
+
* One left-to-right pass; chained replaces cannot express the escape, since by the time a pass
|
|
26
|
+
* could unescape `~*` the `*` has already become `.*`.
|
|
23
27
|
*/
|
|
24
|
-
toRegex: (lookupText: string, flags?: any, anchor?: boolean) => RegExp;
|
|
28
|
+
toRegex: (lookupText: string, flags?: any, anchor?: boolean | "start") => RegExp;
|
|
25
29
|
};
|
|
26
30
|
//# sourceMappingURL=WildCard.d.ts.map
|
package/types/src/index.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
export * from './Scalar';
|
|
2
2
|
export * from './ScalarType';
|
|
3
|
+
export * from './ValueKind';
|
|
3
4
|
export * from './WildCard';
|
|
4
5
|
export * from './Lambda';
|
|
5
6
|
export * from './ErrorPolicy';
|
|
6
7
|
export * from './Repeating';
|
|
7
8
|
export * from './Flatten';
|
|
9
|
+
export * from './NoLift';
|
|
10
|
+
export * from './NoFilter';
|
|
11
|
+
export * from './ReportType';
|
|
8
12
|
export * from './Omittable';
|
|
13
|
+
export * from './Lazy';
|
|
14
|
+
export * from './Volatile';
|
|
9
15
|
export * from './IRange';
|
|
10
16
|
export * from './IReferenceRange';
|
|
11
17
|
export * from './IRichData';
|
|
12
18
|
export * from './IFunction';
|
|
13
19
|
export * from './IFormulaContext';
|
|
20
|
+
export * from './IFunctionArguments';
|
|
14
21
|
export * from './LocaleProfile';
|
|
15
22
|
export * from './IRuntime';
|
|
16
23
|
export * from './IRangeStats';
|
package/browser/cjs/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e;Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),function(e){e.MAX_TEXT_LENGTH=32767;let t=e.MAX_SIGNIFICANT_DIGITS=15;e.truncateNumberText=function(e){let n=e.length;if(n<=t)return e;let r=0,i=null;for(let a=0;a<n;a++){let n=e.charCodeAt(a);if(n>=48&&n<=57){if(r===0&&n===48)continue;r++,r>t&&((i??=e.split(``))[a]=`0`)}else if((n===69||n===101)&&r>0)break}return i===null?e:i.join(``)}}(e||={});var t,n,r,i,a={Number:`number`,String:`string`,Boolean:`boolean`,Error:`error`,RichData:`richData`,Null:`null`},o={...a,Date:`date`},s=/[.*+?^${}()|[\]\\]/,c=e=>s.test(e)?`\\`+e:e,l={isWildCard:e=>typeof e==`string`&&/[*?]/.test(e),toRegex:(e,t,n=!1)=>{let r=``,i=e.length;for(let t=0;t<i;t++){let n=e[t];if(n===`~`){let n=e[t+1];n===`*`||n===`?`||n===`~`?(r+=c(n),t++):r+=`~`;continue}n===`*`?r+=`.*`:r+=n===`?`?`.`:c(n)}return RegExp(n?`^${r}$`:r,t)}};(n=t||={}).Axis={Column:`column`,Row:`row`},n.AxisSelection={...t.Axis,Both:`both`},n.Direction={Up:`up`,Down:`down`,Left:`left`,Right:`right`},(r||={}).Aggregate={Count:`count`,NumericalCount:`numericalCount`,Sum:`sum`,Average:`average`,StdDev:`stdDev`,PopulationStdDev:`stdDevP`,Variance:`var`,PopulationVariance:`varP`,Min:`min`,Max:`max`},function(e){let t=e.Code={Parse:0,Null:1,Div0:2,Value:3,Ref:4,Name:5,Num:6,NA:7,GettingData:8,Spill:9,Connect:10,Blocked:11,Unknown:12,Field:13,Calc:14,Busy:16,Python:19,Timeout:20},n=e.Label={Parse:`#PARSE!`,Null:`#NULL!`,Div0:`#DIV/0!`,Value:`#VALUE!`,Ref:`#REF!`,Name:`#NAME?`,Num:`#NUM!`,NA:`#N/A`,GettingData:`#GETTING_DATA`,Spill:`#SPILL!`,Connect:`#CONNECT!`,Blocked:`#BLOCKED!`,Unknown:`#UNKNOWN!`,Field:`#FIELD!`,Calc:`#CALC!`,Busy:`#BUSY!`,Python:`#PYTHON!`,Timeout:`#TIMEOUT!`};class r extends Error{constructor(e,t,n,r){super(n,r),this._label=t,this._code=e,this.details=r}static{this.code=i.Code.Unknown}get isFormulaError(){return!0}getLabel(){return this._label}getCode(){return this._code}equals(e){return!!e&&(this._code===e._code||this._code===e.code)}get[Symbol.toStringTag](){return`[FormulaError]`}toString(){return this._label}}e.Known=r;class a extends r{constructor(e,r){super(t.Parse,n.Parse,e,r)}static{this.code=i.Code.Parse}getDetails(){let e=this.details;return{line:e?.line??1,column:e?.column??1,offset:e?.offset??0,length:e?.length??0}}}e.Parse=a;class o extends r{constructor(e,r){super(t.Null,n.Null,e,r)}static{this.code=i.Code.Null}}e.Null=o;class s extends r{constructor(e,r){super(t.Div0,n.Div0,e,r)}static{this.code=i.Code.Div0}}e.Div0=s;class c extends r{constructor(e,r){super(t.Value,n.Value,e,r)}static{this.code=i.Code.Value}}e.Value=c;class l extends r{constructor(e,r){super(t.Ref,n.Ref,e,r)}static{this.code=i.Code.Ref}}e.Ref=l;class u extends r{constructor(e,r){super(t.Name,n.Name,e,r)}static{this.code=i.Code.Name}}e.Name=u;class d extends r{constructor(e,r){super(t.Num,n.Num,e,r)}static{this.code=i.Code.Num}}e.Num=d;class f extends r{constructor(e,r){super(t.NA,n.NA,e,r)}static{this.code=i.Code.NA}}e.NA=f;class p extends r{constructor(e,r){super(t.GettingData,n.GettingData,e,r)}static{this.code=i.Code.GettingData}}e.GettingData=p;class m extends r{constructor(e,r){super(t.Spill,n.Spill,e,r)}static{this.code=i.Code.Spill}}e.Spill=m;class h extends r{constructor(e,r){super(t.Connect,n.Connect,e,r)}static{this.code=i.Code.Connect}}e.Connect=h;class g extends r{constructor(e,r){super(t.Blocked,n.Blocked,e,r)}static{this.code=i.Code.Blocked}}e.Blocked=g;class _ extends r{constructor(e,r){super(t.Unknown,n.Unknown,e,r)}static{this.code=i.Code.Unknown}}e.Unknown=_;class v extends r{constructor(e,r){super(t.Field,n.Field,e,r)}static{this.code=i.Code.Field}}e.Field=v;class y extends r{constructor(e,r){super(t.Calc,n.Calc,e,r)}static{this.code=i.Code.Calc}}e.Calc=y;class b extends r{constructor(e,r){super(t.Busy,n.Busy,e,r)}static{this.code=i.Code.Busy}}e.Busy=b;class x extends r{constructor(e,r){super(t.Python,n.Python,e,r)}static{this.code=i.Code.Python}}e.Python=x;class S extends r{constructor(e,r){super(t.Timeout,n.Timeout,e,r)}static{this.code=i.Code.Timeout}}e.Timeout=S}(i||={});var u={};u[i.Code.Parse]=i.Parse,u[i.Code.Null]=i.Null,u[i.Code.Div0]=i.Div0,u[i.Code.Value]=i.Value,u[i.Code.Ref]=i.Ref,u[i.Code.Name]=i.Name,u[i.Code.Num]=i.Num,u[i.Code.NA]=i.NA,u[i.Code.GettingData]=i.GettingData,u[i.Code.Spill]=i.Spill,u[i.Code.Connect]=i.Connect,u[i.Code.Blocked]=i.Blocked,u[i.Code.Unknown]=i.Unknown,u[i.Code.Field]=i.Field,u[i.Code.Calc]=i.Calc,u[i.Code.Busy]=i.Busy,u[i.Code.Python]=i.Python,u[i.Code.Timeout]=i.Timeout;var d=new Map,f=new Map,p=new Map,m=new Map,h=Object.keys(u);for(let e=0;e<h.length;e++){let t=u[h[e]],n=new t;p.set(n.getLabel(),t),m.set(n.getCode(),t),d.set(n.getLabel(),n),f.set(n.getCode(),n)}(function(e){let t=e.getBuiltInByCode=e=>f.get(e);e.BuiltIn={Parse:t(i.Code.Parse),Null:t(i.Code.Null),Div0:t(i.Code.Div0),Value:t(i.Code.Value),Ref:t(i.Code.Ref),Name:t(i.Code.Name),Num:t(i.Code.Num),NA:t(i.Code.NA),GettingData:t(i.Code.GettingData),Spill:t(i.Code.Spill),Connect:t(i.Code.Connect),Blocked:t(i.Code.Blocked),Unknown:t(i.Code.Unknown),Field:t(i.Code.Field),Calc:t(i.Code.Calc),Busy:t(i.Code.Busy),Python:t(i.Code.Python),Timeout:t(i.Code.Timeout)},e.newTypedError=(e,t,n)=>{let r;return r=typeof e==`string`?p.get(e):m.get(e),r||=i.Unknown,new r(t,n)},e.getBuiltInByLabel=e=>d.get(e),e.isError=function(e,t){return!!e&&!0===e.isFormulaError&&(t===void 0||e.getCode()===t)}})(i||={});var g=class{createRange(e,t,n){throw new v}getReference(e,t){throw new v}getResizedReference(e,t,n){throw new v}getNumberFormat(e,t){throw new v}fromSerialDate(e,t){throw new v}toSerialDate(e,t){throw new v}getDateParts(e,t){throw new v}getSerialDate(e,t,n,r,i,a,o){throw new v}getNow(){throw new v}getValueAt(e,t,n,r){return null}getEntireCoords(){return y}isValidDate(e,t){return e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`?!isNaN(e.getTime()):!t&&typeof e==`number`&&!(e<0||e>x)}getRow(){return 0}getColumn(){return 0}getFormulaAt(e,t,n){return null}getSpillAt(e,t,n){return null}getSheetIndex(e){return-1}getSheetCount(){return 1}markVolatile(){}formatResults(e){}filterHidden(e,t){return e}filterTotals(e){return e}getFunction(e){return null}getAddress(e,t){throw new v}parseAsSerialDate(e,t){throw new v}parseAsDate(e,t){throw new v}parseAsNumber(e,t){throw new v}createCriteria(e){throw new v}parseAsLiteral(e){let t=e.toUpperCase();return t===`TRUE`||t!==`FALSE`&&i.getBuiltInByLabel(t)}toText(e){return typeof e==`string`?e:e==null?``:typeof e==`boolean`?e?`TRUE`:`FALSE`:e?.isFormulaError?e.getLabel():String(e)}compare(e,t,n){if(e===t)return 0;let r=_(e),i=_(t);return r===i?e<t?-1:+(e>t):r<i?-1:1}getRuntime(){return b}},_=e=>{if(e==null)return 0;switch(typeof e){case`number`:return 1;case`string`:return 2;case`boolean`:return 3;default:return 4}},v=class extends Error{constructor(e=`Not implemented in StubbedFormulaContext`){super(e),this.name=`NotImplementedError`}},y=Object.freeze({colStart:0,rowStart:0,colEnd:2**14-1,rowEnd:2**20-1}),b={isDate1904:()=>!1,getLocale:()=>w.tag,getLocaleProfile:()=>w,isR1C1:()=>!1,getNow:()=>0,getLocation:()=>`unknown`,getVersion:()=>`1.0.0`,getOS:()=>`unknown`,getUser:()=>`unidentified`,getDescription:()=>`Stubbed Formula Context`},x=2958465,S=new g,C=class{constructor(){this._scope=S}_setScope(e){this._scope=e??S}_getScope(){return this._scope}getNumberFormat(e,t){return this._getScope().getNumberFormat(e,t)}getEntireCoords(){return this._getScope().getEntireCoords()??y}parseAsSerialDate(e,t){return this._getScope().parseAsSerialDate(e,t)}parseAsDate(e,t){return this._getScope().parseAsDate(e,t)}parseAsNumber(e,t){return this._getScope().parseAsNumber(e,t)}createCriteria(e){return this._getScope().createCriteria(e)}parseAsLiteral(e){let t=this._getScope();return t.parseAsLiteral?t.parseAsLiteral(e):S.parseAsLiteral(e)}toText(e){return this._getScope().toText(e)}isValidDate(e,t=!1){return this._getScope().isValidDate(e,t)}fromSerialDate(e,t=!1){return this._getScope().fromSerialDate(e,t)}toSerialDate(e,t=!1){return this._getScope().toSerialDate(e,t)}getDateParts(e,t){return this._getScope().getDateParts(e,t)}getSerialDate(e,t,n,r=0,i=0,a=0,o=0){return this._getScope().getSerialDate(e,t,n,r,i,a,o)}getNow(){return this._getScope().getNow()}createRange(e,t,n){return this._getScope().createRange(e,t,n)}getRow(){return this._getScope().getRow?.()??0}getColumn(){return this._getScope().getColumn?.()??0}getReference(e,t){return this._getScope().getReference(e,t)}getResizedReference(e,t,n){return this._getScope().getResizedReference(e,t,n)}getValueAt(e,t,n){return this._getScope().getValueAt(e,t,n)}getFormulaAt(e,t,n){return this._getScope().getFormulaAt?.(e,t,n)??null}getSpillAt(e,t,n){return this._getScope().getSpillAt?.(e,t,n)??null}getSheetIndex(e){return this._getScope().getSheetIndex?.(e)??-1}getSheetCount(){return this._getScope().getSheetCount?.()??1}markVolatile(){this._getScope().markVolatile?.()}formatResults(e){this._getScope().formatResults?.(e)}filterHidden(e,t){return this._getScope().filterHidden?.(e,t)??e}filterTotals(e){return this._getScope().filterTotals?.(e)??e}getFunction(e){return this._getScope().getFunction?.(e)??null}getAddress(e,t){return this._getScope().getAddress(e,t)}compare(e,t,n){return this._getScope().compare?.(e,t,n)??S.compare(e,t,n)}getRuntime(){return this._getScope().getRuntime()}get[Symbol.toStringTag](){return`[FormulaContext]`}toString(){return this._getScope()?.toString?.()??`{STUB SCOPE}`}},w=Object.freeze({tag:`en-US`,numberingSystem:`latn`,decimal:`.`,group:`,`,grouping:[3],minusSign:`-`,percentSign:`%`,permilleSign:`‰`,currencyCode:`USD`,currencySymbol:`$`,currencyDisplay:`symbol`,currencyPosition:`before`,currencySpacing:`tight`,date:Object.freeze({calendar:`gregory`,short:`M/d/yy`,medium:`MMM d, y`,long:`MMMM d, y`,timeShort:`h:mm a`,timeLong:`h:mm:ss a`,am:`AM`,pm:`PM`,firstDay:0,weekend:[6,0],monthsWide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],monthsAbbr:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],weekdaysWide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],weekdaysAbbr:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],hour12:!0}),listSeparator:`,`,csvDelimiter:`,`,rtl:!1,collator:Object.freeze({sensitivity:`base`,numeric:!0})}),T=new C;exports.DEFAULT_LOCALE_PROFILE=w,exports.FormulaContext=T,Object.defineProperty(exports,"FormulaError",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"IRange",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"IRangeStats",{enumerable:!0,get:function(){return r}}),exports.InteropScalarType=o,exports.Observable=class{constructor(e){this._subscribeFn=e}subscribe(e,t,n){let r=typeof e==`object`?{next:e.next||(()=>{}),error:e.error||(()=>{}),complete:e.complete||(()=>{}),unsubscribe:()=>{}}:{next:e||(()=>{}),error:t||(()=>{}),complete:n||(()=>{}),unsubscribe:()=>{}},i=this._subscribeFn(r);return r.unsubscribe=()=>{typeof i==`function`&&i()},r}},Object.defineProperty(exports,"Scalar",{enumerable:!0,get:function(){return e}}),exports.ScalarType=a,exports.ScopedFormulaContext=C,exports.StubbedFormulaContext=g,exports.WildCard=l;
|