@sheetxl/primitives 0.8.0-beta.2 → 0.8.0-beta.21
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/LICENSE.md +17 -7
- package/browser/esm/index.mjs +92 -42
- package/node/esm/index.mjs +113 -59
- package/package.json +4 -5
- package/types/src/ErrorPolicy.d.ts +2 -2
- package/types/src/Flatten.d.ts +2 -2
- package/types/src/FormulaContext.d.ts +31 -11
- package/types/src/FormulaError.d.ts +1 -1
- package/types/src/IFormulaContext.d.ts +460 -28
- package/types/src/IFunction.d.ts +47 -59
- package/types/src/IFunctionArguments.d.ts +25 -4
- package/types/src/IRange.d.ts +22 -4
- package/types/src/IRangeStats.d.ts +8 -7
- package/types/src/IRichData.d.ts +47 -7
- package/types/src/IRichType.d.ts +139 -0
- package/types/src/Repeating.d.ts +3 -3
- package/types/src/ReportType.d.ts +2 -2
- package/types/src/Scalar.d.ts +53 -2
- package/types/src/ValueKind.d.ts +2 -2
- package/types/src/WildCard.d.ts +1 -1
- package/types/src/index.d.ts +1 -0
- package/browser/cjs/index.cjs +0 -1
package/types/src/IFunction.d.ts
CHANGED
|
@@ -37,13 +37,19 @@ export interface IFunction {
|
|
|
37
37
|
*/
|
|
38
38
|
isBuiltIn(): boolean;
|
|
39
39
|
/**
|
|
40
|
-
* Indicates whether the function is a
|
|
40
|
+
* Indicates whether the function is a `LAMBDA` rather than a built-in or registered function.
|
|
41
41
|
*
|
|
42
42
|
* @remarks
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* Two kinds of function answer `true`:
|
|
44
|
+
*
|
|
45
|
+
* - **A defined name whose body is `LAMBDA(…)`.** It is reachable by name like any other
|
|
46
|
+
* function, so signature help and function lookups can describe it: its parameters are the
|
|
47
|
+
* lambda's, and its summary is the name's comment, or the name's formula when it has no
|
|
48
|
+
* comment. A formula calls it through the NAME, never through {@link execute}, which answers
|
|
49
|
+
* `#CALC!`.
|
|
50
|
+
* - **A `LAMBDA` passed as a value** and received by
|
|
51
|
+
* {@link IFunctionArguments.getFunctionsAt}. It has no name ({@link getName} is `''`), its
|
|
52
|
+
* parameters are the lambda's, and {@link execute} applies it.
|
|
47
53
|
*/
|
|
48
54
|
isLambda(): boolean;
|
|
49
55
|
/**
|
|
@@ -278,11 +284,9 @@ export declare namespace IFunction {
|
|
|
278
284
|
getMembers(): readonly IFunction.IEnumMember[];
|
|
279
285
|
}
|
|
280
286
|
/**
|
|
281
|
-
* Describes the runtime return behavior of a function, including modifiers like
|
|
282
|
-
* async resolution, streaming data, or volatility.
|
|
287
|
+
* Describes the runtime return behavior of a function, including modifiers like volatility.
|
|
283
288
|
*
|
|
284
289
|
* @remarks
|
|
285
|
-
* All return type modifiers are mutually exclusive.
|
|
286
290
|
* If none are specified, The value will be returned with no special behavior.
|
|
287
291
|
*/
|
|
288
292
|
interface IReturnType extends IValueType {
|
|
@@ -294,26 +298,13 @@ export declare namespace IFunction {
|
|
|
294
298
|
* @see {@link ReturnTypeJSON.kind}
|
|
295
299
|
*/
|
|
296
300
|
getKind(): ValueKind | null;
|
|
297
|
-
/**
|
|
298
|
-
* Indicates the return value is a Promise or Promise-like (i.e., async).
|
|
299
|
-
* The system will mark the result as pending and re-trigger evaluation once resolved.
|
|
300
|
-
*
|
|
301
|
-
* Can be combined with any scalar, array, or range return type.
|
|
302
|
-
*/
|
|
303
|
-
isAsync(): boolean;
|
|
304
|
-
/**
|
|
305
|
-
* Indicates whether the function produces a continuous stream of output (e.g., real-time data).
|
|
306
|
-
*
|
|
307
|
-
* @defaultValue `false`
|
|
308
|
-
*/
|
|
309
|
-
isStreaming(): boolean;
|
|
310
301
|
/**
|
|
311
302
|
* True when the result can change with nothing dirty, so a cell naming this function
|
|
312
303
|
* recalculates on every pass — the `Volatile<T>` marker.
|
|
313
304
|
*
|
|
314
305
|
* @remarks
|
|
315
306
|
* STATIC, and read from the formula text at compile time: it is true of the call whether or
|
|
316
|
-
* not the call runs, which is what a lazy argument
|
|
307
|
+
* not the call runs, which is what a lazy argument requires.
|
|
317
308
|
*
|
|
318
309
|
* @see {@link ReturnTypeJSON.volatile}
|
|
319
310
|
*/
|
|
@@ -352,7 +343,7 @@ export declare namespace IFunction {
|
|
|
352
343
|
* @remarks
|
|
353
344
|
* Only meaningful for a VARIADIC function; a fixed parameter list is already its own maximum.
|
|
354
345
|
* The number is the whole CALL's argument count, prefix and optional suffix included, and it
|
|
355
|
-
* is refused
|
|
346
|
+
* is refused at entry, before evaluation.
|
|
356
347
|
*
|
|
357
348
|
* @see {@link Repeating}
|
|
358
349
|
*/
|
|
@@ -363,6 +354,15 @@ export declare namespace IFunction {
|
|
|
363
354
|
* @defaultValue `{ type: 'void' }`
|
|
364
355
|
*/
|
|
365
356
|
getReturnType(): IReturnType;
|
|
357
|
+
/**
|
|
358
|
+
* Whether the function is left out of function lists, from its `@hidden` or `@deprecated` tag.
|
|
359
|
+
*
|
|
360
|
+
* @remarks
|
|
361
|
+
* A hidden function is still callable from a formula and still found by name. Listing calls
|
|
362
|
+
* leave it out unless asked to include it. {@link IDescriptor.isDeprecated} carries the tag's
|
|
363
|
+
* label, if it has one.
|
|
364
|
+
*/
|
|
365
|
+
isHidden(): boolean;
|
|
366
366
|
}
|
|
367
367
|
/**
|
|
368
368
|
* Locale-specific, user-facing metadata: display name, summary, category, and
|
|
@@ -395,14 +395,11 @@ export declare namespace IFunction {
|
|
|
395
395
|
*/
|
|
396
396
|
getCategory(): string;
|
|
397
397
|
/**
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
* @defaultValue 'null'
|
|
398
|
+
* The label of the function's `@hidden` or `@deprecated` tag (`Unimplemented`), `true` for a tag
|
|
399
|
+
* with no label, or `false`.
|
|
402
400
|
*
|
|
403
401
|
* @remarks
|
|
404
|
-
*
|
|
405
|
-
* * This is useful for functions that are in beta or deprecated.
|
|
402
|
+
* Whether the function is listed is {@link IDeclaration.isHidden}; this is the text to show for it.
|
|
406
403
|
*/
|
|
407
404
|
isDeprecated(): boolean | string;
|
|
408
405
|
/**
|
|
@@ -648,8 +645,8 @@ export declare namespace IFunction {
|
|
|
648
645
|
* Generated from the `NoLift<T>` marker.
|
|
649
646
|
*
|
|
650
647
|
* @remarks
|
|
651
|
-
* Per parameter, because Excel
|
|
652
|
-
* and lifts one at `weekend`. An ARRAY at the slot still lifts, a one-cell reference is an
|
|
648
|
+
* Per parameter, because Excel's built-ins differ by slot: `NETWORKDAYS.INTL` refuses a
|
|
649
|
+
* reference at its date slots and lifts one at `weekend`. An ARRAY at the slot still lifts, a one-cell reference is an
|
|
653
650
|
* ordinary argument, and a repeating slot absorbs a container as members, so the marker only
|
|
654
651
|
* ever applies to a non-repeating scalar parameter.
|
|
655
652
|
*/
|
|
@@ -689,7 +686,7 @@ export declare namespace IFunction {
|
|
|
689
686
|
* union is the range arm, handed over whole. The slot never lifts.
|
|
690
687
|
*
|
|
691
688
|
* @remarks
|
|
692
|
-
*
|
|
689
|
+
* Some array slots read a one-cell argument as THE ARGUMENT rather than as a
|
|
693
690
|
* one-cell container: `SORT(<#N/A cell>,1,1,<#DIV/0! cell>)` is `#N/A` where
|
|
694
691
|
* `TAKE(<#N/A cell>,<#DIV/0! cell>)` is `#DIV/0!`. The engine's default
|
|
695
692
|
* for a range slot is TAKE's; this flag is SORT's. {@link scalar} and {@link range} each carry
|
|
@@ -726,8 +723,7 @@ export declare namespace IFunction {
|
|
|
726
723
|
members: [name: string, value: number | string, deprecated?: string | true][];
|
|
727
724
|
}
|
|
728
725
|
/**
|
|
729
|
-
* Describes the runtime return behavior of a function, including modifiers like
|
|
730
|
-
* async resolution, streaming data, or volatility.
|
|
726
|
+
* Describes the runtime return behavior of a function, including modifiers like volatility.
|
|
731
727
|
*
|
|
732
728
|
* @remarks
|
|
733
729
|
* If none are specified, The value will be returned with no special behavior.
|
|
@@ -751,29 +747,15 @@ export declare namespace IFunction {
|
|
|
751
747
|
* is a scalar is its member value downstream.
|
|
752
748
|
*/
|
|
753
749
|
kind?: ValueKind;
|
|
754
|
-
/**
|
|
755
|
-
* Indicates the return value is a Promise or Promise-like (i.e., async).
|
|
756
|
-
* The system will mark the result as pending and re-trigger evaluation once resolved.
|
|
757
|
-
*
|
|
758
|
-
* Can be combined with any scalar, array, or range return type.
|
|
759
|
-
*/
|
|
760
|
-
async?: boolean;
|
|
761
|
-
/**
|
|
762
|
-
* Indicates whether the function produces a continuous stream of output (e.g., real-time data).
|
|
763
|
-
*
|
|
764
|
-
* @defaultValue `false`
|
|
765
|
-
*/
|
|
766
|
-
stream?: boolean;
|
|
767
750
|
/**
|
|
768
751
|
* The result can change with nothing dirty — a cell naming this function recalculates on
|
|
769
752
|
* every pass. Generated from the `Volatile<T>` marker.
|
|
770
753
|
*
|
|
771
754
|
* @remarks
|
|
772
755
|
* Collected at COMPILE time from the formula text (`CompiledFormula.hasVolatile`), because
|
|
773
|
-
* that is where
|
|
756
|
+
* that is where volatility is decided: `=IF(TRUE,1,RAND())` recalculates on every idle pass though
|
|
774
757
|
* no branch selects the arm, and with lazy arguments the call never happens for the engine to
|
|
775
|
-
* observe.
|
|
776
|
-
* result arrives rather than what it is.
|
|
758
|
+
* observe.
|
|
777
759
|
*
|
|
778
760
|
* @see {@link Volatile}
|
|
779
761
|
*/
|
|
@@ -794,11 +776,10 @@ export declare namespace IFunction {
|
|
|
794
776
|
* parameter. Omitted at the default of 255.
|
|
795
777
|
*
|
|
796
778
|
* @remarks
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
* takes 254.
|
|
779
|
+
* The cap is one number per NAME, compared against the whole call's argument count, so a call
|
|
780
|
+
* past it is refused AT ENTRY rather than answered — which is why the cap lives on the
|
|
781
|
+
* declaration and not in a body. It is not derivable from the shape: in Excel `STDEV` takes 255
|
|
782
|
+
* arguments and `STDEV.S`, the same function under its dotted name, takes 254.
|
|
802
783
|
*
|
|
803
784
|
* @defaultValue 255
|
|
804
785
|
*/
|
|
@@ -825,6 +806,14 @@ export declare namespace IFunction {
|
|
|
825
806
|
* * If the context is not `IFunction.Calculation` then the function must return `void` or a cleanup function.
|
|
826
807
|
*/
|
|
827
808
|
context?: string;
|
|
809
|
+
/**
|
|
810
|
+
* Leave the function out of function lists.
|
|
811
|
+
*
|
|
812
|
+
* @defaultValue `false`
|
|
813
|
+
*
|
|
814
|
+
* @see {@link IDeclaration.isHidden}
|
|
815
|
+
*/
|
|
816
|
+
hidden?: boolean;
|
|
828
817
|
/**
|
|
829
818
|
* Additional metadata about the function's behavior or requirements.
|
|
830
819
|
*/
|
|
@@ -859,13 +848,12 @@ export declare namespace IFunction {
|
|
|
859
848
|
*/
|
|
860
849
|
category?: string;
|
|
861
850
|
/**
|
|
862
|
-
*
|
|
851
|
+
* The label of a `@hidden` or `@deprecated` tag, or `true` for a tag with no label.
|
|
863
852
|
*
|
|
864
|
-
* @defaultValue
|
|
853
|
+
* @defaultValue `false`
|
|
865
854
|
*
|
|
866
855
|
* @remarks
|
|
867
|
-
*
|
|
868
|
-
* * This is useful for functions that are in beta or deprecated.
|
|
856
|
+
* Display text only. Whether the function is listed is {@link DeclarationJSON.hidden}.
|
|
869
857
|
*/
|
|
870
858
|
deprecated?: string | boolean;
|
|
871
859
|
/**
|
|
@@ -2,6 +2,7 @@ import { Scalar } from './Scalar';
|
|
|
2
2
|
import { ValueKind } from './ValueKind';
|
|
3
3
|
import { IRange } from './IRange';
|
|
4
4
|
import { Lambda } from './Lambda';
|
|
5
|
+
import { IFunction } from './IFunction';
|
|
5
6
|
/**
|
|
6
7
|
* The current call's arguments, as the body sees them — argument **reflection**.
|
|
7
8
|
*
|
|
@@ -14,9 +15,8 @@ import { Lambda } from './Lambda';
|
|
|
14
15
|
* - What was the value BEFORE the parameter's type coerced it?
|
|
15
16
|
* - Was that empty slot an omission, or a blank cell the caller pointed at?
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
* parameters
|
|
19
|
-
* declined to express one. `CUMIPMT` refuses a boolean at every slot while `FV` coerces one at
|
|
18
|
+
* Some functions have behaviors that turn on exactly those questions, and they cluster at
|
|
19
|
+
* parameters declared `any` — where there is nothing to express as a type. `CUMIPMT` refuses a boolean at every slot while `FV` coerces one at
|
|
20
20
|
* every slot; the difference is not the values, it is that `CUMIPMT`'s slots are `any` and its
|
|
21
21
|
* body decides.
|
|
22
22
|
*
|
|
@@ -141,7 +141,7 @@ export interface IFunctionArguments {
|
|
|
141
141
|
*/
|
|
142
142
|
getKindAt(index: number): ValueKind;
|
|
143
143
|
/**
|
|
144
|
-
* True when the argument at `index` is DIRECT —
|
|
144
|
+
* True when the argument at `index` is DIRECT — typed into the list of arguments:
|
|
145
145
|
* the evaluated value IS a value, not a container or a callable.
|
|
146
146
|
*
|
|
147
147
|
* @param index The PARAMETER index — the position in the body's own signature.
|
|
@@ -170,6 +170,27 @@ export interface IFunctionArguments {
|
|
|
170
170
|
* other slot the marshaller has already answered `#VALUE!`.
|
|
171
171
|
*/
|
|
172
172
|
getAreaCountAt(index: number): number;
|
|
173
|
+
/**
|
|
174
|
+
* The functions the argument at `index` holds, in row-major order — or `null` unless it holds
|
|
175
|
+
* nothing but functions.
|
|
176
|
+
*
|
|
177
|
+
* @param index The PARAMETER index — the position in the body's own signature.
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* A formula can pass a function as a value: `LAMBDA(x, x * 2)`, or a built-in by name, as `SUM`
|
|
181
|
+
* is in `BYROW(A1:C3, SUM)`. A `Lambda` parameter takes ONE such value. This is for an untyped
|
|
182
|
+
* parameter that also takes an ARRAY of them, as `HSTACK(SUM, AVERAGE)` makes.
|
|
183
|
+
*
|
|
184
|
+
* The argument's shape is its own: {@link getKindAt} is `Lambda` for one function and `Array`
|
|
185
|
+
* for several, and {@link getRawAt} is that array. A function value IS an {@link IFunction}: a
|
|
186
|
+
* built-in by name answers as the registry's function does, and a `LAMBDA` is one whose
|
|
187
|
+
* {@link IFunction.isLambda} is `true`. A body whose untyped parameter holds the value reads the
|
|
188
|
+
* functions from it directly; this is reflection, for when the declaration does not hand it over.
|
|
189
|
+
*
|
|
190
|
+
* Nothing is collected until every member has proved to be a function, so a data range given by
|
|
191
|
+
* mistake costs one member.
|
|
192
|
+
*/
|
|
193
|
+
getFunctionsAt(index: number): readonly IFunction[] | null;
|
|
173
194
|
}
|
|
174
195
|
/**
|
|
175
196
|
* {@inheritDoc IFunctionArguments}
|
package/types/src/IRange.d.ts
CHANGED
|
@@ -255,7 +255,7 @@ export interface IRange<T extends Scalar = Scalar> {
|
|
|
255
255
|
* @remarks
|
|
256
256
|
* Errors INSIDE a range are the body's to judge: the engine hands a valid range over whole and
|
|
257
257
|
* never looks inside, so a function whose answer depends on every member says so with this
|
|
258
|
-
* line, placed before its own validation where
|
|
258
|
+
* line, placed before its own validation where the member's error outranks it. A reshaper or a
|
|
259
259
|
* lookup, whose members pass through or are never read, needs no line at all.
|
|
260
260
|
*/
|
|
261
261
|
firstError(): FormulaError.Known | null;
|
|
@@ -268,7 +268,7 @@ export interface IRange<T extends Scalar = Scalar> {
|
|
|
268
268
|
* @remarks
|
|
269
269
|
* `options.axis` is the TRAVERSAL order feeding the ordinal, not the orientation of the result:
|
|
270
270
|
* the result is always Nx1, and a row is `flatten().transpose()`. The default is row-major,
|
|
271
|
-
* which is the order
|
|
271
|
+
* which is the order two range operands pair in.
|
|
272
272
|
*
|
|
273
273
|
* `options.type` carries a read type onto the result, so a member the type filters out becomes
|
|
274
274
|
* a HOLE at its ordinal rather than compacting the column. That is what lets two operands be
|
|
@@ -787,6 +787,24 @@ export declare namespace IRange {
|
|
|
787
787
|
* If passing a large bound care must be taken.
|
|
788
788
|
*/
|
|
789
789
|
includeEmpty?: boolean;
|
|
790
|
+
/**
|
|
791
|
+
* Skips rows of the range: given the next row that would be read, answers the row to read
|
|
792
|
+
* instead - the same row when it is read, or the next one that is (the previous, when
|
|
793
|
+
* `reverse`).
|
|
794
|
+
*
|
|
795
|
+
* @param index The 0-based row about to be read.
|
|
796
|
+
* @param reverse Whether the read runs from the last row back.
|
|
797
|
+
* @returns The row to read, at or past `index`.
|
|
798
|
+
*
|
|
799
|
+
* @remarks
|
|
800
|
+
* A skipped cell is not visited, reads as empty and is left out of the statistics; the shape
|
|
801
|
+
* of the range is unchanged. `SUBTOTAL` reads a range this way when it skips hidden rows.
|
|
802
|
+
*/
|
|
803
|
+
processRowSkip?: (index: number, reverse?: boolean) => number;
|
|
804
|
+
/**
|
|
805
|
+
* Skips columns of the range, as {@link processRowSkip} skips rows.
|
|
806
|
+
*/
|
|
807
|
+
processColumnSkip?: (index: number, reverse?: boolean) => number;
|
|
790
808
|
/**
|
|
791
809
|
* Useful for callback functions that want a this.
|
|
792
810
|
*/
|
|
@@ -898,7 +916,7 @@ export declare namespace IRange {
|
|
|
898
916
|
*
|
|
899
917
|
* - By default, `broadcast()` follows strict alignment rules like NumPy and will
|
|
900
918
|
* throw an error if the input ranges cannot be broadcasted together.
|
|
901
|
-
* - When `misalignValue` is provided, `broadcast()` will instead
|
|
919
|
+
* - When `misalignValue` is provided, `broadcast()` will instead follow Excel's behavior:
|
|
902
920
|
* - It finds the **largest valid intersection** of the ranges.
|
|
903
921
|
* - It expands the result to the **union of both range sizes**.
|
|
904
922
|
* - Any cells that do not have valid corresponding values from the inputs
|
|
@@ -956,7 +974,7 @@ export declare namespace IRange {
|
|
|
956
974
|
*
|
|
957
975
|
* @remarks
|
|
958
976
|
* Off, a dimension of 1 is a short dimension like any other and pads `misalignValue` past
|
|
959
|
-
* its one position:
|
|
977
|
+
* its one position: the `MAP` rule, where a 1-row array is not stretched.
|
|
960
978
|
*/
|
|
961
979
|
tile?: boolean;
|
|
962
980
|
/**
|
|
@@ -71,7 +71,7 @@ export interface IRangeStats {
|
|
|
71
71
|
*/
|
|
72
72
|
getAggregates(options?: IRange.IteratorOptions): Readonly<IRangeStats.Aggregates>;
|
|
73
73
|
/**
|
|
74
|
-
* Returns the sum as
|
|
74
|
+
* Returns the sum as `SUM` reports it — {@link getAggregates}'s `sum` with Excel's
|
|
75
75
|
* cancellation-to-zero rule applied.
|
|
76
76
|
*
|
|
77
77
|
* @param total A total the caller accumulated across SEVERAL stats instances. Omit for a
|
|
@@ -82,7 +82,7 @@ export interface IRangeStats {
|
|
|
82
82
|
* @remarks
|
|
83
83
|
* Collapses a total to exactly zero when it lands at least 50 binary exponents below the
|
|
84
84
|
* operands that produced it, so `SUM(0.1,0.2,-0.3)` is `0` rather than `5.55111512312578E-17`.
|
|
85
|
-
* Use this wherever you mean "the number
|
|
85
|
+
* Use this wherever you mean "the number SUM shows" — a status bar, a report
|
|
86
86
|
* total, a formula. Use `getAggregates().sum` where you mean the true total of the data.
|
|
87
87
|
*
|
|
88
88
|
* The two genuinely differ, and neither is a rounding of the other:
|
|
@@ -92,12 +92,12 @@ export interface IRangeStats {
|
|
|
92
92
|
* and `PERCENTOF`, and to NOTHING else — `SUMIF`, `SUMPRODUCT`, `SERIESSUM`, `DSUM`, the
|
|
93
93
|
* `SUMX2MY2` family and every binary operator all keep the residue over the same values.
|
|
94
94
|
* That is why this is a method you call and not a change to `getAggregates`.
|
|
95
|
-
* - `AVERAGE` divides THIS, not the raw sum: snapping the mean instead is
|
|
95
|
+
* - `AVERAGE` divides THIS, not the raw sum: snapping the mean instead is wrong.
|
|
96
96
|
*
|
|
97
97
|
* It is also cheap when it does not fire: a bound derived from `min`/`max` rejects any
|
|
98
98
|
* ordinary total without re-reading the range.
|
|
99
99
|
*
|
|
100
|
-
* **Multiple ranges.**
|
|
100
|
+
* **Multiple ranges.** The rule applies on the *final* accumulation step, so a total
|
|
101
101
|
* spanning several ranges must be judged against the range holding the LAST value — pass the
|
|
102
102
|
* running total as `total` and call this on that range. (Snapping each range separately gets
|
|
103
103
|
* `SUM(A1:A3,0)` and `SUM(A1:A1,A2:A2,A3:A3)` wrong in opposite directions.) A composite
|
|
@@ -160,7 +160,8 @@ export interface IRangeStats {
|
|
|
160
160
|
*
|
|
161
161
|
* - Every requested type (all types when omitted) is present with an explicit count —
|
|
162
162
|
* a `0` is a fact about the range, a missing key would be ambiguous.
|
|
163
|
-
* - Blanks report under {@link ScalarType.Null}: total cells minus non-empty values.
|
|
163
|
+
* - Blanks report under {@link ScalarType.Null}: total cells minus non-empty values. A cell the
|
|
164
|
+
* range skips ({@link IRange.IteratorOptions.processRowSkip}) is not a blank; it is not counted.
|
|
164
165
|
* - Never throws on error values — errors are population here, not faults — regardless of
|
|
165
166
|
* the `onError` iterator policy the stats were created with.
|
|
166
167
|
*/
|
|
@@ -244,7 +245,7 @@ export declare namespace IRangeStats {
|
|
|
244
245
|
* Sorting requires materializing the full numeric population (O(n log n), one allocation).
|
|
245
246
|
* Unlike `Aggregates`, sorted views are **not composable across sub-ranges**.
|
|
246
247
|
*
|
|
247
|
-
* Covers the following
|
|
248
|
+
* Covers the following functions (all share one sort per coords per calc cycle):
|
|
248
249
|
* - `LARGE`, `SMALL`
|
|
249
250
|
* - `MEDIAN`, `PERCENTILE`, `PERCENTILE.INC`, `PERCENTILE.EXC`
|
|
250
251
|
* - `QUARTILE`, `QUARTILE.INC`, `QUARTILE.EXC` (q1 = k=0.25, q3 = k=0.75)
|
|
@@ -309,7 +310,7 @@ export declare namespace IRangeStats {
|
|
|
309
310
|
* one outside the population is not found.
|
|
310
311
|
* @param exclusive If true, uses exclusive formula (0 and 1 are excluded).
|
|
311
312
|
* @param significance Number of DECIMAL PLACES to TRUNCATE the result to — despite what
|
|
312
|
-
* Excel's
|
|
313
|
+
* Excel's help calls the argument, it is not significant digits and it does not round.
|
|
313
314
|
* Truncated toward zero first (1.9 places means 1), and must be at least 1. Omit it for the
|
|
314
315
|
* exact untruncated rank, which is also the only form that cannot fail.
|
|
315
316
|
* @returns The percent rank of x; `null` if x is not found or there are no numbers in range.
|
package/types/src/IRichData.d.ts
CHANGED
|
@@ -1,37 +1,77 @@
|
|
|
1
1
|
import { Scalar } from './Scalar';
|
|
2
|
+
import { IRichMeta, IRichType } from './IRichType';
|
|
2
3
|
/**
|
|
3
4
|
* A complex object type. This allows for more complex data types to be stored in a cell.
|
|
4
5
|
*/
|
|
5
6
|
export interface IRichData {
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* The value's kind: the properties it has and how they show. Every value of a kind returns the
|
|
9
|
+
* same instance.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
getKind(): IRichType;
|
|
11
12
|
/**
|
|
12
13
|
* @param name The name of the property to retrieve.
|
|
13
14
|
*/
|
|
14
15
|
getProperty(name: string): Scalar;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* How the property `name` shows on this value: the value's own presentation where it differs
|
|
18
|
+
* from its kind's (a price in another currency), else the kind's ({@link IRichType.Property.meta}).
|
|
19
|
+
* `null`, or the method absent, for none.
|
|
20
|
+
*/
|
|
21
|
+
getPropertyMeta?(name: string): IRichMeta | null;
|
|
22
|
+
/**
|
|
23
|
+
* The text shown for this value where nothing renders it: a client with no renderer for the
|
|
24
|
+
* kind, a log, a placeholder. A rich text shows its text; an image a short description.
|
|
17
25
|
*
|
|
18
26
|
* @remarks
|
|
19
|
-
*
|
|
27
|
+
* Display only. What the value reads as to calculation, sorting and the clipboard is
|
|
28
|
+
* {@link toPrimitive}.
|
|
20
29
|
*/
|
|
21
30
|
toString(): string;
|
|
22
31
|
/**
|
|
23
|
-
*
|
|
32
|
+
* The primitive this value reads as wherever one is consumed: `LEN`, `&`, `+`, comparison,
|
|
33
|
+
* `ISTEXT`, `TYPE()`, sort, filter, find. A rich text reads as its text; an error that carries
|
|
34
|
+
* more than its code reads as that error; an image reads as nothing (`null`, or the method
|
|
35
|
+
* absent), and is `#VALUE!` wherever a primitive is needed.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* The ordinary rules then apply to the primitive (text-to-number coercion, collation, error
|
|
39
|
+
* propagation), so a value adds no coercions of its own.
|
|
40
|
+
*/
|
|
41
|
+
toPrimitive?(): Exclude<Scalar, IRichData>;
|
|
42
|
+
/**
|
|
43
|
+
* The items this value unpacks to where a range or array is accepted (a list); `null`, or the
|
|
44
|
+
* method absent, for a value that is one value.
|
|
45
|
+
*/
|
|
46
|
+
toArray?(): Scalar[][] | null;
|
|
47
|
+
/**
|
|
48
|
+
* The value as JSON, which its kind makes it again from. A value that holds a resource (a
|
|
49
|
+
* picture's bytes) names it by the id `toResourceId` answers, and the file saves the resource;
|
|
50
|
+
* without `toResourceId` it names none.
|
|
24
51
|
*/
|
|
25
|
-
toJSON?(): IRichData.JSON | Promise<IRichData.JSON>;
|
|
52
|
+
toJSON?(toResourceId?: IRichData.ToResourceId): IRichData.JSON | Promise<IRichData.JSON>;
|
|
26
53
|
/**
|
|
27
54
|
* For runtime type checking.
|
|
28
55
|
*/
|
|
29
56
|
get isIRichData(): true;
|
|
30
57
|
}
|
|
31
58
|
export declare namespace IRichData {
|
|
59
|
+
/**
|
|
60
|
+
* The id a file being saved gives a resource a value holds (an `IResource`); `null` when the
|
|
61
|
+
* file does not save it.
|
|
62
|
+
*/
|
|
63
|
+
type ToResourceId = (resource: any) => number | null;
|
|
32
64
|
interface JSON {
|
|
65
|
+
/** The name of the value's kind ({@link IRichType.getName}). */
|
|
33
66
|
type: string;
|
|
67
|
+
/** The value's own data, as its kind reads it. */
|
|
34
68
|
data?: any;
|
|
69
|
+
/**
|
|
70
|
+
* Presentation for the properties where this value differs from its kind, by property name.
|
|
71
|
+
*/
|
|
72
|
+
meta?: {
|
|
73
|
+
readonly [property: string]: IRichMeta;
|
|
74
|
+
};
|
|
35
75
|
}
|
|
36
76
|
}
|
|
37
77
|
//# sourceMappingURL=IRichData.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Scalar } from './Scalar';
|
|
2
|
+
/**
|
|
3
|
+
* The kind of a rich value: its class. A kind is a static set of typed property definitions, and
|
|
4
|
+
* every value of a kind shares the one `IRichType` its {@link IRichData.getKind} returns.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* For introspection: a renderer, a card, a formula editor offering `A1.` completions, or a
|
|
8
|
+
* function reading a field asks the value's kind which properties it has. What a value reads as
|
|
9
|
+
* where a primitive is consumed is the value's own answer ({@link IRichData.toPrimitive}).
|
|
10
|
+
*/
|
|
11
|
+
export interface IRichType {
|
|
12
|
+
/**
|
|
13
|
+
* The kind's name: what a value's JSON names as its `type`.
|
|
14
|
+
*/
|
|
15
|
+
getName(): string;
|
|
16
|
+
/**
|
|
17
|
+
* The name a UI shows for the kind, such as in a list of what can be inserted. The name when the
|
|
18
|
+
* kind has no label of its own.
|
|
19
|
+
*/
|
|
20
|
+
getLabel(): string;
|
|
21
|
+
/**
|
|
22
|
+
* The kind's properties, in the order the kind declares them.
|
|
23
|
+
*/
|
|
24
|
+
getProperties(): readonly IRichType.Property[];
|
|
25
|
+
/**
|
|
26
|
+
* The property `name`, or `null` when the kind has none by that name.
|
|
27
|
+
*/
|
|
28
|
+
getProperty(name: string): IRichType.Property | null;
|
|
29
|
+
/**
|
|
30
|
+
* The property whose value is the text a cell shows for a value of this kind, or `null` when
|
|
31
|
+
* the kind shows none (an image).
|
|
32
|
+
*/
|
|
33
|
+
getDisplayProperty(): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* The kind's own presentation (a card, an icon, a provider), or `null` for none.
|
|
36
|
+
*/
|
|
37
|
+
getMeta(): IRichMeta | null;
|
|
38
|
+
}
|
|
39
|
+
export declare namespace IRichType {
|
|
40
|
+
/**
|
|
41
|
+
* What a property holds.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* `rich` is another rich value (a capital city, an image); `array` is an array value; `resource`
|
|
45
|
+
* is a workbook resource such as a picture's bytes.
|
|
46
|
+
*/
|
|
47
|
+
type ValueType = 'number' | 'integer' | 'string' | 'boolean' | 'error' | 'rich' | 'array' | 'resource';
|
|
48
|
+
/**
|
|
49
|
+
* One property a kind declares.
|
|
50
|
+
*/
|
|
51
|
+
interface Property {
|
|
52
|
+
/** The property's name. */
|
|
53
|
+
readonly name: string;
|
|
54
|
+
/** What it holds. */
|
|
55
|
+
readonly valueType: ValueType;
|
|
56
|
+
/** What it reads as on a value that holds none. Omitted, `null`. */
|
|
57
|
+
readonly defaultValue?: Scalar;
|
|
58
|
+
/** How the property shows, unless a value says otherwise. */
|
|
59
|
+
readonly meta?: IRichMeta;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A kind saved with the workbook whose values name it: one that is not registered in code, such
|
|
63
|
+
* as a kind read from a file.
|
|
64
|
+
*/
|
|
65
|
+
interface JSON {
|
|
66
|
+
/** {@inheritDoc IRichType.getName} */
|
|
67
|
+
name: string;
|
|
68
|
+
/** {@inheritDoc IRichType.getLabel} */
|
|
69
|
+
label?: string;
|
|
70
|
+
/** {@inheritDoc IRichType.getProperties} */
|
|
71
|
+
properties?: readonly Property[];
|
|
72
|
+
/** {@inheritDoc IRichType.getDisplayProperty} */
|
|
73
|
+
displayProperty?: string | null;
|
|
74
|
+
/** {@inheritDoc IRichType.getMeta} */
|
|
75
|
+
meta?: IRichMeta;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* How a rich value, or one of its properties, is presented: the number format and caption of a
|
|
80
|
+
* property, where it is offered, its sources; a kind's card, icon and provider.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Presentation only, never a value. A kind gives each of its properties a default; a value gives
|
|
84
|
+
* one only for a property where it differs (a price in another currency).
|
|
85
|
+
*/
|
|
86
|
+
export interface IRichMeta {
|
|
87
|
+
/** The number format a number property shows in. */
|
|
88
|
+
readonly numberFormat?: string;
|
|
89
|
+
/** A short caption shown beside the property, such as its unit or the year of its data. */
|
|
90
|
+
readonly sublabel?: string;
|
|
91
|
+
/** Where the property is not offered. Each omitted entry is `false`. */
|
|
92
|
+
readonly excludeFrom?: IRichMeta.ExcludeFrom;
|
|
93
|
+
/** Where the property's data comes from and under what license. */
|
|
94
|
+
readonly attribution?: readonly IRichMeta.Attribution[];
|
|
95
|
+
/** A kind's card. */
|
|
96
|
+
readonly card?: IRichMeta.Card;
|
|
97
|
+
/** A kind's icon, by name. */
|
|
98
|
+
readonly icon?: string;
|
|
99
|
+
/** Who provides a kind's data. */
|
|
100
|
+
readonly provider?: IRichMeta.Provider;
|
|
101
|
+
}
|
|
102
|
+
export declare namespace IRichMeta {
|
|
103
|
+
/** Where a property is not offered. */
|
|
104
|
+
interface ExcludeFrom {
|
|
105
|
+
/** Not shown on the card. */
|
|
106
|
+
readonly cardView?: boolean;
|
|
107
|
+
/** Not offered after `A1.` in a formula. */
|
|
108
|
+
readonly dotNotation?: boolean;
|
|
109
|
+
/** Not offered by formula autocomplete. */
|
|
110
|
+
readonly autoComplete?: boolean;
|
|
111
|
+
/** A change to the property is not a change to the value. */
|
|
112
|
+
readonly calcCompare?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/** One source of a property's data. */
|
|
115
|
+
interface Attribution {
|
|
116
|
+
readonly sourceText?: string;
|
|
117
|
+
readonly sourceAddress?: string;
|
|
118
|
+
readonly licenseText?: string;
|
|
119
|
+
readonly licenseAddress?: string;
|
|
120
|
+
}
|
|
121
|
+
/** A kind's card: which properties it shows, and how. */
|
|
122
|
+
interface Card {
|
|
123
|
+
/** The properties shown, in order. Omitted, the kind's order. */
|
|
124
|
+
readonly order?: readonly string[];
|
|
125
|
+
/** The property shown as the title. */
|
|
126
|
+
readonly title?: string;
|
|
127
|
+
/** The property shown under the title. */
|
|
128
|
+
readonly subTitle?: string;
|
|
129
|
+
/** The image property shown at the top. */
|
|
130
|
+
readonly mainImage?: string;
|
|
131
|
+
}
|
|
132
|
+
/** Who provides a kind's data. */
|
|
133
|
+
interface Provider {
|
|
134
|
+
readonly description?: string;
|
|
135
|
+
readonly logoSourceAddress?: string;
|
|
136
|
+
readonly logoTargetAddress?: string;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=IRichType.d.ts.map
|
package/types/src/Repeating.d.ts
CHANGED
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
* omitted when there is a single repetition. `SORTBY`'s legal arities are 2 and 1+2n and nothing
|
|
47
47
|
* else — `SORTBY(array, by1)` is legal, `SORTBY(array, by1, o1, by2)` is not. It is not a general
|
|
48
48
|
* "the final element of the final group may be omitted" rule; that rule would accept a formula
|
|
49
|
-
*
|
|
49
|
+
* that must be refused. An optional slot anywhere else in the group is a compiler error.
|
|
50
50
|
*
|
|
51
51
|
* ### The maximum, `Max`
|
|
52
52
|
*
|
|
53
|
-
* The second type argument is the largest number of arguments the WHOLE CALL accepts
|
|
54
|
-
*
|
|
53
|
+
* The second type argument is the largest number of arguments the WHOLE CALL accepts: one
|
|
54
|
+
* number per NAME, compared against the call's total argument count and
|
|
55
55
|
* refused at entry (`Excess_function_arguments`), never a count of this parameter's own share.
|
|
56
56
|
* `SWITCH`'s 254 therefore covers its `expression` and its trailing `default` as well as the
|
|
57
57
|
* pairs, and `CHOOSEROWS`' covers its `array`.
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
* what can arrive and {@link IFunctionArguments.getAreaCountAt} answers the union question the
|
|
28
28
|
* kind cannot — a plain reference is one area, a union is more.
|
|
29
29
|
*
|
|
30
|
-
* Its use is meant to stay countable: a slot earns it with a
|
|
31
|
-
*
|
|
30
|
+
* Its use is meant to stay countable: a slot earns it with a concrete behavior that needs it,
|
|
31
|
+
* never speculatively.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```ts
|