@omegagrid/grid-core 0.10.0 → 0.10.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/package.json +3 -3
- package/dist/__generated/functions.d.ts +0 -4
- package/dist/__generated/functions.d.ts.map +0 -1
- package/dist/__generated/functions.js +0 -45
- package/dist/__generated/functions.js.map +0 -1
- package/dist/calculations/autofill.d.ts +0 -7
- package/dist/calculations/autofill.d.ts.map +0 -1
- package/dist/calculations/autofill.js +0 -84
- package/dist/calculations/autofill.js.map +0 -1
- package/dist/calculations/conditions.d.ts +0 -4
- package/dist/calculations/conditions.d.ts.map +0 -1
- package/dist/calculations/conditions.js +0 -41
- package/dist/calculations/conditions.js.map +0 -1
- package/dist/calculations/context.d.ts +0 -53
- package/dist/calculations/context.d.ts.map +0 -1
- package/dist/calculations/context.js +0 -85
- package/dist/calculations/context.js.map +0 -1
- package/dist/calculations/formula.d.ts +0 -89
- package/dist/calculations/formula.d.ts.map +0 -1
- package/dist/calculations/formula.js +0 -443
- package/dist/calculations/formula.js.map +0 -1
- package/dist/calculations/functions/dates.d.ts +0 -13
- package/dist/calculations/functions/dates.d.ts.map +0 -1
- package/dist/calculations/functions/dates.js +0 -58
- package/dist/calculations/functions/dates.js.map +0 -1
- package/dist/calculations/functions/index.d.ts +0 -11
- package/dist/calculations/functions/index.d.ts.map +0 -1
- package/dist/calculations/functions/index.js +0 -21
- package/dist/calculations/functions/index.js.map +0 -1
- package/dist/calculations/functions/logical.d.ts +0 -11
- package/dist/calculations/functions/logical.d.ts.map +0 -1
- package/dist/calculations/functions/logical.js +0 -50
- package/dist/calculations/functions/logical.js.map +0 -1
- package/dist/calculations/functions/lookup.d.ts +0 -18
- package/dist/calculations/functions/lookup.d.ts.map +0 -1
- package/dist/calculations/functions/lookup.js +0 -169
- package/dist/calculations/functions/lookup.js.map +0 -1
- package/dist/calculations/functions/math.d.ts +0 -72
- package/dist/calculations/functions/math.d.ts.map +0 -1
- package/dist/calculations/functions/math.js +0 -182
- package/dist/calculations/functions/math.js.map +0 -1
- package/dist/calculations/functions/special.d.ts +0 -2
- package/dist/calculations/functions/special.d.ts.map +0 -1
- package/dist/calculations/functions/special.js +0 -51
- package/dist/calculations/functions/special.js.map +0 -1
- package/dist/calculations/functions/statistical.d.ts +0 -7
- package/dist/calculations/functions/statistical.d.ts.map +0 -1
- package/dist/calculations/functions/statistical.js +0 -47
- package/dist/calculations/functions/statistical.js.map +0 -1
- package/dist/calculations/functions/text.d.ts +0 -29
- package/dist/calculations/functions/text.d.ts.map +0 -1
- package/dist/calculations/functions/text.js +0 -58
- package/dist/calculations/functions/text.js.map +0 -1
- package/dist/calculations/helpers.d.ts +0 -13
- package/dist/calculations/helpers.d.ts.map +0 -1
- package/dist/calculations/helpers.js +0 -32
- package/dist/calculations/helpers.js.map +0 -1
- package/dist/calculations/index.d.ts +0 -7
- package/dist/calculations/index.d.ts.map +0 -1
- package/dist/calculations/index.js +0 -7
- package/dist/calculations/index.js.map +0 -1
- package/dist/calculations/operators.d.ts +0 -19
- package/dist/calculations/operators.d.ts.map +0 -1
- package/dist/calculations/operators.js +0 -58
- package/dist/calculations/operators.js.map +0 -1
- package/dist/calculations/tokenization.d.ts +0 -36
- package/dist/calculations/tokenization.d.ts.map +0 -1
- package/dist/calculations/tokenization.js +0 -203
- package/dist/calculations/tokenization.js.map +0 -1
- package/dist/common/index.d.ts +0 -2
- package/dist/common/index.d.ts.map +0 -1
- package/dist/common/index.js +0 -2
- package/dist/common/index.js.map +0 -1
- package/dist/common/range.d.ts +0 -66
- package/dist/common/range.d.ts.map +0 -1
- package/dist/common/range.js +0 -222
- package/dist/common/range.js.map +0 -1
- package/dist/constants.d.ts +0 -68
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -127
- package/dist/constants.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/model/calculationModel.d.ts +0 -30
- package/dist/model/calculationModel.d.ts.map +0 -1
- package/dist/model/calculationModel.js +0 -206
- package/dist/model/calculationModel.js.map +0 -1
- package/dist/model/cellModel.d.ts +0 -134
- package/dist/model/cellModel.d.ts.map +0 -1
- package/dist/model/cellModel.js +0 -371
- package/dist/model/cellModel.js.map +0 -1
- package/dist/model/columnModel.d.ts +0 -160
- package/dist/model/columnModel.d.ts.map +0 -1
- package/dist/model/columnModel.js +0 -159
- package/dist/model/columnModel.js.map +0 -1
- package/dist/model/commentModel.d.ts +0 -58
- package/dist/model/commentModel.d.ts.map +0 -1
- package/dist/model/commentModel.js +0 -81
- package/dist/model/commentModel.js.map +0 -1
- package/dist/model/conditionalFormats.d.ts +0 -104
- package/dist/model/conditionalFormats.d.ts.map +0 -1
- package/dist/model/conditionalFormats.js +0 -414
- package/dist/model/conditionalFormats.js.map +0 -1
- package/dist/model/cssStyle.d.ts +0 -20
- package/dist/model/cssStyle.d.ts.map +0 -1
- package/dist/model/cssStyle.js +0 -301
- package/dist/model/cssStyle.js.map +0 -1
- package/dist/model/dependencies.d.ts +0 -30
- package/dist/model/dependencies.d.ts.map +0 -1
- package/dist/model/dependencies.js +0 -139
- package/dist/model/dependencies.js.map +0 -1
- package/dist/model/dependencyModel.d.ts +0 -9
- package/dist/model/dependencyModel.d.ts.map +0 -1
- package/dist/model/dependencyModel.js +0 -9
- package/dist/model/dependencyModel.js.map +0 -1
- package/dist/model/elementModel.d.ts +0 -103
- package/dist/model/elementModel.d.ts.map +0 -1
- package/dist/model/elementModel.js +0 -181
- package/dist/model/elementModel.js.map +0 -1
- package/dist/model/filterModel.d.ts +0 -35
- package/dist/model/filterModel.d.ts.map +0 -1
- package/dist/model/filterModel.js +0 -153
- package/dist/model/filterModel.js.map +0 -1
- package/dist/model/gridModel.d.ts +0 -181
- package/dist/model/gridModel.d.ts.map +0 -1
- package/dist/model/gridModel.js +0 -797
- package/dist/model/gridModel.js.map +0 -1
- package/dist/model/groupModel.d.ts +0 -26
- package/dist/model/groupModel.d.ts.map +0 -1
- package/dist/model/groupModel.js +0 -112
- package/dist/model/groupModel.js.map +0 -1
- package/dist/model/history.d.ts +0 -24
- package/dist/model/history.d.ts.map +0 -1
- package/dist/model/history.js +0 -35
- package/dist/model/history.js.map +0 -1
- package/dist/model/index.d.ts +0 -23
- package/dist/model/index.d.ts.map +0 -1
- package/dist/model/index.js +0 -23
- package/dist/model/index.js.map +0 -1
- package/dist/model/iterableRange.d.ts +0 -49
- package/dist/model/iterableRange.d.ts.map +0 -1
- package/dist/model/iterableRange.js +0 -108
- package/dist/model/iterableRange.js.map +0 -1
- package/dist/model/merges.d.ts +0 -34
- package/dist/model/merges.d.ts.map +0 -1
- package/dist/model/merges.js +0 -123
- package/dist/model/merges.js.map +0 -1
- package/dist/model/namingModel.d.ts +0 -25
- package/dist/model/namingModel.d.ts.map +0 -1
- package/dist/model/namingModel.js +0 -77
- package/dist/model/namingModel.js.map +0 -1
- package/dist/model/options.d.ts +0 -257
- package/dist/model/options.d.ts.map +0 -1
- package/dist/model/options.js +0 -35
- package/dist/model/options.js.map +0 -1
- package/dist/model/rowModel.d.ts +0 -104
- package/dist/model/rowModel.d.ts.map +0 -1
- package/dist/model/rowModel.js +0 -155
- package/dist/model/rowModel.js.map +0 -1
- package/dist/model/selectionModel.d.ts +0 -19
- package/dist/model/selectionModel.d.ts.map +0 -1
- package/dist/model/selectionModel.js +0 -40
- package/dist/model/selectionModel.js.map +0 -1
- package/dist/model/sortingModel.d.ts +0 -46
- package/dist/model/sortingModel.d.ts.map +0 -1
- package/dist/model/sortingModel.js +0 -157
- package/dist/model/sortingModel.js.map +0 -1
- package/dist/model/style.d.ts +0 -90
- package/dist/model/style.d.ts.map +0 -1
- package/dist/model/style.js +0 -34
- package/dist/model/style.js.map +0 -1
- package/dist/model/styleModel.d.ts +0 -22
- package/dist/model/styleModel.d.ts.map +0 -1
- package/dist/model/styleModel.js +0 -91
- package/dist/model/styleModel.js.map +0 -1
- package/dist/model/tableTheme.d.ts +0 -46
- package/dist/model/tableTheme.d.ts.map +0 -1
- package/dist/model/tableTheme.js +0 -93
- package/dist/model/tableTheme.js.map +0 -1
- package/dist/model/validations.d.ts +0 -5
- package/dist/model/validations.d.ts.map +0 -1
- package/dist/model/validations.js +0 -24
- package/dist/model/validations.js.map +0 -1
- package/dist/sparklines/index.d.ts +0 -2
- package/dist/sparklines/index.d.ts.map +0 -1
- package/dist/sparklines/index.js +0 -2
- package/dist/sparklines/index.js.map +0 -1
- package/dist/sparklines/sparklines.d.ts +0 -59
- package/dist/sparklines/sparklines.d.ts.map +0 -1
- package/dist/sparklines/sparklines.js +0 -176
- package/dist/sparklines/sparklines.js.map +0 -1
- package/dist/types.d.ts +0 -103
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -4
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -11
- package/dist/utils.js.map +0 -1
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-loss-of-precision */
|
|
2
|
-
/**
|
|
3
|
-
* Coefficients for each term of the numerator sum (p_j) for each approximation
|
|
4
|
-
* interval (see W. J. Cody's paper for more details)
|
|
5
|
-
* @constant
|
|
6
|
-
*/
|
|
7
|
-
const P = [[
|
|
8
|
-
3.16112374387056560e00, 1.13864154151050156e02,
|
|
9
|
-
3.77485237685302021e02, 3.20937758913846947e03,
|
|
10
|
-
1.85777706184603153e-1
|
|
11
|
-
], [
|
|
12
|
-
5.64188496988670089e-1, 8.88314979438837594e00,
|
|
13
|
-
6.61191906371416295e01, 2.98635138197400131e02,
|
|
14
|
-
8.81952221241769090e02, 1.71204761263407058e03,
|
|
15
|
-
2.05107837782607147e03, 1.23033935479799725e03,
|
|
16
|
-
2.15311535474403846e-8
|
|
17
|
-
], [
|
|
18
|
-
3.05326634961232344e-1, 3.60344899949804439e-1,
|
|
19
|
-
1.25781726111229246e-1, 1.60837851487422766e-2,
|
|
20
|
-
6.58749161529837803e-4, 1.63153871373020978e-2
|
|
21
|
-
]];
|
|
22
|
-
/**
|
|
23
|
-
* Coefficients for each term of the denominator sum (q_j) for each approximation
|
|
24
|
-
* interval (see W. J. Cody's paper for more details)
|
|
25
|
-
* @constant
|
|
26
|
-
*/
|
|
27
|
-
const Q = [[
|
|
28
|
-
2.36012909523441209e01, 2.44024637934444173e02,
|
|
29
|
-
1.28261652607737228e03, 2.84423683343917062e03
|
|
30
|
-
], [
|
|
31
|
-
1.57449261107098347e01, 1.17693950891312499e02,
|
|
32
|
-
5.37181101862009858e02, 1.62138957456669019e03,
|
|
33
|
-
3.29079923573345963e03, 4.36261909014324716e03,
|
|
34
|
-
3.43936767414372164e03, 1.23033935480374942e03
|
|
35
|
-
], [
|
|
36
|
-
2.56852019228982242e00, 1.87295284992346047e00,
|
|
37
|
-
5.27905102951428412e-1, 6.05183413124413191e-2,
|
|
38
|
-
2.33520497626869185e-3
|
|
39
|
-
]];
|
|
40
|
-
export function erfc(y) {
|
|
41
|
-
const ysq = y * y;
|
|
42
|
-
let xnum = P[0][4] * ysq;
|
|
43
|
-
let xden = ysq;
|
|
44
|
-
let i;
|
|
45
|
-
for (i = 0; i < 3; i += 1) {
|
|
46
|
-
xnum = (xnum + P[0][i]) * ysq;
|
|
47
|
-
xden = (xden + Q[0][i]) * ysq;
|
|
48
|
-
}
|
|
49
|
-
return y * (xnum + P[0][3]) / (xden + Q[0][3]);
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=special.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"special.js","sourceRoot":"","sources":["../../../src/calculations/functions/special.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D;;;;GAIG;AACH,MAAM,CAAC,GAAG,CAAC;QACV,sBAAsB,EAAE,sBAAsB;QAC9C,sBAAsB,EAAE,sBAAsB;QAC9C,sBAAsB;KACtB,EAAE;QACF,sBAAsB,EAAE,s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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-loss-of-precision */\n\n/**\n * Coefficients for each term of the numerator sum (p_j) for each approximation\n * interval (see W. J. Cody's paper for more details)\n * @constant\n */\nconst P = [[\n\t3.16112374387056560e00, 1.13864154151050156e02,\n\t3.77485237685302021e02, 3.20937758913846947e03,\n\t1.85777706184603153e-1\n], [\n\t5.64188496988670089e-1, 8.88314979438837594e00,\n\t6.61191906371416295e01, 2.98635138197400131e02,\n\t8.81952221241769090e02, 1.71204761263407058e03,\n\t2.05107837782607147e03, 1.23033935479799725e03,\n\t2.15311535474403846e-8\n], [\n\t3.05326634961232344e-1, 3.60344899949804439e-1,\n\t1.25781726111229246e-1, 1.60837851487422766e-2,\n\t6.58749161529837803e-4, 1.63153871373020978e-2\n]]\n \n/**\n * Coefficients for each term of the denominator sum (q_j) for each approximation\n * interval (see W. J. Cody's paper for more details)\n * @constant\n */\nconst Q = [[\n\t2.36012909523441209e01, 2.44024637934444173e02,\n\t1.28261652607737228e03, 2.84423683343917062e03\n], [\n\t1.57449261107098347e01, 1.17693950891312499e02,\n\t5.37181101862009858e02, 1.62138957456669019e03,\n\t3.29079923573345963e03, 4.36261909014324716e03,\n\t3.43936767414372164e03, 1.23033935480374942e03\n], [\n\t2.56852019228982242e00, 1.87295284992346047e00,\n\t5.27905102951428412e-1, 6.05183413124413191e-2,\n\t2.33520497626869185e-3\n]]\n\nexport function erfc(y: number) {\n\tconst ysq = y * y\n let xnum = P[0][4] * ysq\n let xden = ysq\n let i\n\n for (i = 0; i < 3; i += 1) {\n xnum = (xnum + P[0][i]) * ysq\n xden = (xden + Q[0][i]) * ysq\n }\n return y * (xnum + P[0][3]) / (xden + Q[0][3])\n}"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ArrayArg } from "../helpers";
|
|
2
|
-
export declare function average(...args: ArrayArg): number;
|
|
3
|
-
export declare function average_weighted(values: ArrayArg<number>, weights: ArrayArg<number>): number;
|
|
4
|
-
export declare function avedev(...args: ArrayArg<number>): number;
|
|
5
|
-
export declare function min(...args: ArrayArg): number;
|
|
6
|
-
export declare function max(...args: ArrayArg): number;
|
|
7
|
-
//# sourceMappingURL=statistical.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"statistical.d.ts","sourceRoot":"","sources":["../../../src/calculations/functions/statistical.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoC,MAAM,YAAY,CAAC;AAWxE,wBAAgB,OAAO,CAAC,GAAG,IAAI,EAAE,QAAQ,UASxC;AAED,wBAAgB,gBAAgB,CAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,UAUpF;AAED,wBAAgB,MAAM,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,UAI/C;AAED,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,QAAQ,UAIpC;AAED,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,QAAQ,UAIpC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { eachValue, matrix, valuesToArray } from "../helpers";
|
|
2
|
-
import mean from '@stdlib/stats/base/mean';
|
|
3
|
-
import incrwmean from '@stdlib/stats/incr/wmean';
|
|
4
|
-
// import stdev from '@stdlib/stats/base/stdev';
|
|
5
|
-
// import dmeanstdev from '@stdlib/stats/base/dmeanstdev';
|
|
6
|
-
// export function average(...args: CellsAndRanges) {
|
|
7
|
-
// const data = valuesToArray(args) as number[];
|
|
8
|
-
// return mean(data.length, data, 1);
|
|
9
|
-
// }
|
|
10
|
-
export function average(...args) {
|
|
11
|
-
let sum = 0;
|
|
12
|
-
let cnt = 0;
|
|
13
|
-
eachValue(args, v => {
|
|
14
|
-
if (v != null && !isNaN(v)) {
|
|
15
|
-
sum += v || 0;
|
|
16
|
-
++cnt;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return sum / cnt;
|
|
20
|
-
}
|
|
21
|
-
export function average_weighted(values, weights) {
|
|
22
|
-
const acumulator = incrwmean();
|
|
23
|
-
const x = matrix(values);
|
|
24
|
-
const w = matrix(weights);
|
|
25
|
-
for (let r = 0; r < x.length; r++) {
|
|
26
|
-
for (let c = 0; c < x[r].length; c++) {
|
|
27
|
-
acumulator(x[r][c], (w[r] ? w[r][c] : 1) ?? 1);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return acumulator();
|
|
31
|
-
}
|
|
32
|
-
export function avedev(...args) {
|
|
33
|
-
const data = valuesToArray(args);
|
|
34
|
-
const m = mean(data.length, data, 1);
|
|
35
|
-
return data.reduce((res, v) => res + Math.abs(v - m), 0) / data.length;
|
|
36
|
-
}
|
|
37
|
-
export function min(...args) {
|
|
38
|
-
let min = Infinity;
|
|
39
|
-
eachValue(args, v => min = Math.min(min, v));
|
|
40
|
-
return min;
|
|
41
|
-
}
|
|
42
|
-
export function max(...args) {
|
|
43
|
-
let max = -Infinity;
|
|
44
|
-
eachValue(args, v => max = Math.max(max, v));
|
|
45
|
-
return max;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=statistical.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"statistical.js","sourceRoot":"","sources":["../../../src/calculations/functions/statistical.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,gDAAgD;AAChD,0DAA0D;AAE1D,qDAAqD;AACrD,iDAAiD;AACjD,sCAAsC;AACtC,IAAI;AAEJ,MAAM,UAAU,OAAO,CAAC,GAAG,IAAc;IACxC,IAAI,GAAG,GAAG,CAAC,CAAC;IAAC,IAAI,GAAG,GAAG,CAAC,CAA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AAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,GAAG,IAAc;IACpC,IAAI,GAAG,GAAG,QAAQ,CAAC;IACnB,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAW,CAAC,CAAC,CAAC;IACvD,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,GAAG,IAAc;IACpC,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;IACpB,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAW,CAAC,CAAC,CAAC;IACvD,OAAO,GAAG,CAAC;AACZ,CAAC","sourcesContent":["import { ArrayArg, eachValue, matrix, valuesToArray } from \"../helpers\";\nimport mean from '@stdlib/stats/base/mean';\nimport incrwmean from '@stdlib/stats/incr/wmean';\n// import stdev from '@stdlib/stats/base/stdev';\n// import dmeanstdev from '@stdlib/stats/base/dmeanstdev';\n\n// export function average(...args: CellsAndRanges) {\n// \tconst data = valuesToArray(args) as number[];\n// \treturn mean(data.length, data, 1);\n// }\n\nexport function average(...args: ArrayArg) {\n\tlet sum = 0; let cnt = 0\n\teachValue(args, v => {\n\t\tif (v != null && !isNaN(v as number)) {\n\t\t\tsum += (v as number) || 0\n\t\t\t++cnt;\n\t\t}\n\t});\n\treturn sum / cnt;\n}\n\nexport function average_weighted (values: ArrayArg<number>, weights: ArrayArg<number>) {\n\tconst acumulator = incrwmean();\n\tconst x = matrix<number>(values);\n\tconst w = matrix<number>(weights);\n\tfor (let r = 0; r < x.length; r++) {\n\t\tfor (let c = 0; c < x[r].length; c++) {\n\t\t\tacumulator(x[r][c], (w[r] ? w[r][c] : 1) ?? 1);\n\t\t}\t\n\t}\n\treturn acumulator();\n}\n\nexport function avedev(...args: ArrayArg<number>) {\n\tconst data = valuesToArray(args) as number[];\n\tconst m = mean(data.length, data, 1);\n\treturn data.reduce((res, v) => res + Math.abs(v - m), 0) / data.length;\n}\n\nexport function min(...args: ArrayArg) {\n\tlet min = Infinity;\n\teachValue(args, v => min = Math.min(min, v as number));\n\treturn min;\n}\n\nexport function max(...args: ArrayArg) {\n\tlet max = -Infinity;\n\teachValue(args, v => max = Math.max(max, v as number));\n\treturn max;\n}\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ArrayArg } from "../helpers";
|
|
2
|
-
export declare function text(v: unknown, format?: string): string;
|
|
3
|
-
/**
|
|
4
|
-
* Returns the leftmost characters from a text value.
|
|
5
|
-
*
|
|
6
|
-
* @link https://support.microsoft.com/en-us/office/left-leftb-functions-9203d2d2-7960-479b-84c6-1ea52b99640c
|
|
7
|
-
* @link https://support.google.com/docs/answer/3094079
|
|
8
|
-
* @param v string
|
|
9
|
-
* @param count number
|
|
10
|
-
* @returns string
|
|
11
|
-
*/
|
|
12
|
-
export declare function left(v: string, count?: number): string;
|
|
13
|
-
/**
|
|
14
|
-
* Returns the rightmost characters from a text value.
|
|
15
|
-
*
|
|
16
|
-
* @link https://support.microsoft.com/en-us/office/right-rightb-functions-240267ee-9afa-4639-a02b-f19e1786cf2f
|
|
17
|
-
* @link https://support.google.com/docs/answer/3094087
|
|
18
|
-
* @param v string
|
|
19
|
-
* @param count number
|
|
20
|
-
* @returns string
|
|
21
|
-
*/
|
|
22
|
-
export declare function right(v: string, count?: number): string;
|
|
23
|
-
export declare function mid(v: string, start: number, count: number): string;
|
|
24
|
-
export declare function concat(...args: ArrayArg): string;
|
|
25
|
-
export declare function concatenate(...args: ArrayArg): string;
|
|
26
|
-
export declare function len(v: string): number;
|
|
27
|
-
export declare function lower(v: string): string;
|
|
28
|
-
export declare function upper(v: string): string;
|
|
29
|
-
//# sourceMappingURL=text.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/calculations/functions/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AAEjD,wBAAgB,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,UAO/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAG7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,UAG9C;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAG1D;AAED,wBAAgB,MAAM,CAAC,GAAG,IAAI,EAAE,QAAQ,UAIvC;AAED,wBAAgB,WAAW,CAAC,GAAG,IAAI,EAAE,QAAQ,UAE5C;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,UAG5B;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,UAG9B;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,UAG9B"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { numbers } from "@omegagrid/core";
|
|
2
|
-
import { eachValue } from "../helpers";
|
|
3
|
-
export function text(v, format) {
|
|
4
|
-
if (format)
|
|
5
|
-
v = numbers.getNumberFormatter(this.cell.model.options.locale, numbers.fixNumberFormat(format, 'd'), false)(v);
|
|
6
|
-
return v == null ? '' : v.toString();
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Returns the leftmost characters from a text value.
|
|
10
|
-
*
|
|
11
|
-
* @link https://support.microsoft.com/en-us/office/left-leftb-functions-9203d2d2-7960-479b-84c6-1ea52b99640c
|
|
12
|
-
* @link https://support.google.com/docs/answer/3094079
|
|
13
|
-
* @param v string
|
|
14
|
-
* @param count number
|
|
15
|
-
* @returns string
|
|
16
|
-
*/
|
|
17
|
-
export function left(v, count) {
|
|
18
|
-
v = v == null ? '' : v.toString();
|
|
19
|
-
return v.substring(0, count);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Returns the rightmost characters from a text value.
|
|
23
|
-
*
|
|
24
|
-
* @link https://support.microsoft.com/en-us/office/right-rightb-functions-240267ee-9afa-4639-a02b-f19e1786cf2f
|
|
25
|
-
* @link https://support.google.com/docs/answer/3094087
|
|
26
|
-
* @param v string
|
|
27
|
-
* @param count number
|
|
28
|
-
* @returns string
|
|
29
|
-
*/
|
|
30
|
-
export function right(v, count) {
|
|
31
|
-
v = v == null ? '' : v.toString();
|
|
32
|
-
return v.substring(Math.max(0, v.length - count), v.length);
|
|
33
|
-
}
|
|
34
|
-
export function mid(v, start, count) {
|
|
35
|
-
v = v == null ? '' : v.toString();
|
|
36
|
-
return v.substring(start, start + count);
|
|
37
|
-
}
|
|
38
|
-
export function concat(...args) {
|
|
39
|
-
let res = '';
|
|
40
|
-
eachValue(args, (v) => res += v == null ? '' : v.toString());
|
|
41
|
-
return res;
|
|
42
|
-
}
|
|
43
|
-
export function concatenate(...args) {
|
|
44
|
-
return concat(...args);
|
|
45
|
-
}
|
|
46
|
-
export function len(v) {
|
|
47
|
-
v = v == null ? '' : v.toString();
|
|
48
|
-
return v.length;
|
|
49
|
-
}
|
|
50
|
-
export function lower(v) {
|
|
51
|
-
v = v == null ? '' : v.toString();
|
|
52
|
-
return v.toLowerCase();
|
|
53
|
-
}
|
|
54
|
-
export function upper(v) {
|
|
55
|
-
v = v == null ? '' : v.toString();
|
|
56
|
-
return v.toUpperCase();
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=text.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/cal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C,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClC,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAG,IAAc;IACvC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,SAAS,CAAC,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrE,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAG,IAAc;IAC5C,OAAO,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,CAAS;IAC5B,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClC,OAAO,CAAC,CAAC,MAAM,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,CAAS;IAC9B,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,CAAS;IAC9B,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACxB,CAAC","sourcesContent":["import { numbers } from \"@omegagrid/core\";\nimport { ArrayArg, eachValue } from \"../helpers\";\n\nexport function text(v: unknown, format?: string) {\n\tif (format) v = numbers.getNumberFormatter(\n\t\tthis.cell.model.options.locale,\n\t\tnumbers.fixNumberFormat(format, 'd'),\n\t\tfalse\n\t)(v as number);\n\treturn v == null ? '' : v.toString();\n}\n\n/**\n * Returns the leftmost characters from a text value.\n * \n * @link https://support.microsoft.com/en-us/office/left-leftb-functions-9203d2d2-7960-479b-84c6-1ea52b99640c\n * @link https://support.google.com/docs/answer/3094079\n * @param v string\n * @param count number\n * @returns string\n */\nexport function left(v: string, count?: number) {\n\tv = v == null ? '' : v.toString();\n\treturn v.substring(0, count);\n}\n\n/**\n * Returns the rightmost characters from a text value.\n * \n * @link https://support.microsoft.com/en-us/office/right-rightb-functions-240267ee-9afa-4639-a02b-f19e1786cf2f\n * @link https://support.google.com/docs/answer/3094087\n * @param v string\n * @param count number\n * @returns string\n */\nexport function right(v: string, count?: number) {\n\tv = v == null ? '' : v.toString();\n\treturn v.substring(Math.max(0, v.length - count), v.length);\n}\n\nexport function mid(v: string, start: number, count: number) {\n\tv = v == null ? '' : v.toString();\n\treturn v.substring(start, start + count);\n}\n\nexport function concat(...args: ArrayArg) {\n\tlet res = '';\n\teachValue(args, (v: string) => res += v == null ? '' : v.toString());\n\treturn res;\n}\n\nexport function concatenate(...args: ArrayArg) {\n\treturn concat(...args);\n}\n\nexport function len(v: string) {\n\tv = v == null ? '' : v.toString();\n\treturn v.length;\n}\n\nexport function lower(v: string) {\n\tv = v == null ? '' : v.toString();\n\treturn v.toLowerCase();\n}\n\nexport function upper(v: string) {\n\tv = v == null ? '' : v.toString();\n\treturn v.toUpperCase();\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Matrix } from "@omegagrid/core";
|
|
2
|
-
import { FormulaContext } from ".";
|
|
3
|
-
export type Value = number | string | boolean | null;
|
|
4
|
-
export type ArrayArg<T = Value> = Matrix<T> | Matrix<T>[];
|
|
5
|
-
export type Arg<T = Value> = T | ArrayArg<T>;
|
|
6
|
-
export type DateArg = number | string | Date;
|
|
7
|
-
export declare function getFormulaCells(ctx: FormulaContext): import("..").CellModel[];
|
|
8
|
-
export declare function scalar<T>(value: Arg<T>): T;
|
|
9
|
-
export declare function matrix<T>(value: Arg<T>): Matrix<T>;
|
|
10
|
-
export declare function eachValue<T>(values: Arg<T>, callback: (value: T, r: number, c: number) => unknown | undefined | boolean, r?: number, c?: number): unknown | undefined | boolean;
|
|
11
|
-
export declare function valuesToArray<T>(values: Arg<T>): T[];
|
|
12
|
-
export declare const isArrayFunction: (name: string) => boolean;
|
|
13
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/calculations/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AAEnC,MAAM,MAAM,KAAK,GAAG,MAAM,GAAC,MAAM,GAAC,OAAO,GAAC,IAAI,CAAC;AAC/C,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,GAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;AACxD,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,GAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC3C,MAAM,MAAM,OAAO,GAAG,MAAM,GAAC,MAAM,GAAC,IAAI,CAAC;AAEzC,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,4BAElD;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAM1C;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAElD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAC1B,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EACd,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,GAAC,SAAS,GAAC,OAAO,EACvE,CAAC,CAAC,EAAE,MAAM,EACV,CAAC,CAAC,EAAE,MAAM,GACR,OAAO,GAAC,SAAS,GAAC,OAAO,CAS3B;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,OAI9C;AAGD,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,YAA6B,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export function getFormulaCells(ctx) {
|
|
2
|
-
return ctx.formula.cells.map(item => ctx.cell.model.getCellByRange(item[1]));
|
|
3
|
-
}
|
|
4
|
-
export function scalar(value) {
|
|
5
|
-
let result = value;
|
|
6
|
-
while (Array.isArray(result)) {
|
|
7
|
-
result = result.length > 0 ? result[0] : null;
|
|
8
|
-
}
|
|
9
|
-
return result;
|
|
10
|
-
}
|
|
11
|
-
export function matrix(value) {
|
|
12
|
-
return (Array.isArray(value) ? value : [[value]]);
|
|
13
|
-
}
|
|
14
|
-
export function eachValue(values, callback, r, c) {
|
|
15
|
-
if (Array.isArray(values)) {
|
|
16
|
-
for (let i = 0; i < values.length; i++) {
|
|
17
|
-
if (eachValue(values[i], callback, r == null ? i : r, r == null ? undefined : i) === false)
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return callback(values, r, c);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export function valuesToArray(values) {
|
|
26
|
-
const arr = [];
|
|
27
|
-
eachValue(values, v => arr.push(v));
|
|
28
|
-
return arr;
|
|
29
|
-
}
|
|
30
|
-
const arrayFunctions = new Set(['SUMPRODUCT', 'FILTER']);
|
|
31
|
-
export const isArrayFunction = (name) => arrayFunctions.has(name);
|
|
32
|
-
//# sourceMappingURL=helpers.js.map
|
|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,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK;gBACnG,OAAO,KAAK,CAAC;QACf,CAAC;IACF,CAAC;SAAM,CAAC;QACP,OAAO,QAAQ,CAAC,MAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,CAAC;AACF,CAAC;AAED,MAAM,UAAU,aAAa,CAAI,MAAc;IAC9C,MAAM,GAAG,GAAQ,EAAE,CAAC;IACpB,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,MAAM,cAAc,GAAG,IAAI,GAAG,CAAS,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { Matrix } from \"@omegagrid/core\";\nimport { FormulaContext } from \".\";\n\nexport type Value = number|string|boolean|null;\nexport type ArrayArg<T = Value> = Matrix<T>|Matrix<T>[];\nexport type Arg<T = Value> = T|ArrayArg<T>;\nexport type DateArg = number|string|Date;\n\nexport function getFormulaCells(ctx: FormulaContext) {\n\treturn ctx.formula.cells.map(item => ctx.cell.model.getCellByRange(item[1]));\n}\n\nexport function scalar<T>(value: Arg<T>): T {\n\tlet result: unknown = value;\n\twhile (Array.isArray(result)) {\n\t\tresult = result.length > 0 ? result[0] : null;\n\t}\n\treturn result as T;\n}\n\nexport function matrix<T>(value: Arg<T>): Matrix<T> {\n\treturn (Array.isArray(value) ? value : [[value]]) as Matrix<T>;\n}\n\nexport function eachValue<T>(\n\tvalues: Arg<T>, \n\tcallback: (value: T, r: number, c: number) => unknown|undefined|boolean,\n\tr?: number,\n\tc?: number\n): unknown|undefined|boolean {\n\tif (Array.isArray(values)) {\n\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\tif (eachValue(values[i] as Arg<T>, callback, r == null ? i : r, r == null ? undefined : i) === false)\n\t\t\t\treturn false;\n\t\t}\n\t} else {\n\t\treturn callback(values as T, r, c);\n\t}\n}\n\nexport function valuesToArray<T>(values: Arg<T>) {\n\tconst arr: T[] = [];\n\teachValue(values, v => arr.push(v));\n\treturn arr;\n}\n\nconst arrayFunctions = new Set<string>(['SUMPRODUCT', 'FILTER']);\nexport const isArrayFunction = (name: string) => arrayFunctions.has(name);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/calculations/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/calculations/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC","sourcesContent":["export * from './formula';\nexport * from './context';\nexport * from './autofill';\nexport * from './tokenization';\nexport * from './operators';\nexport * as functions from './functions';"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Matrix, Scalar } from "@omegagrid/core";
|
|
2
|
-
export type ArythmeticOperator = '*' | '/' | '+' | '-';
|
|
3
|
-
export type LogicalOperataor = '=' | '>' | '<' | '>=' | '<=' | '<>';
|
|
4
|
-
export type Operator = ArythmeticOperator | LogicalOperataor;
|
|
5
|
-
/**
|
|
6
|
-
* [javascript operator, precedence, associativity]
|
|
7
|
-
*/
|
|
8
|
-
export type OperatorSpec = [string, number, number];
|
|
9
|
-
/**
|
|
10
|
-
* Operator precedence and associativity
|
|
11
|
-
* Map<operator_token, [operator, precedence, associativity]>
|
|
12
|
-
*/
|
|
13
|
-
export declare const operatorMap: Map<Operator, OperatorSpec>;
|
|
14
|
-
export declare const isLogicalOperator: (o: string) => o is LogicalOperataor;
|
|
15
|
-
export declare const isArythmeticOperator: (o: string) => o is ArythmeticOperator;
|
|
16
|
-
export declare const isOperator: (o: string) => o is Operator;
|
|
17
|
-
export declare function scalarOperation<T = number>(s1: Scalar<T>, s2: Scalar<T>, operator: Operator): Scalar;
|
|
18
|
-
export declare function matrixOperation<T>(m1: Matrix<T>, m2: Matrix<T>, operator: Operator): Matrix<T>;
|
|
19
|
-
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../../src/calculations/operators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,MAAM,kBAAkB,GAAG,GAAG,GAAC,GAAG,GAAC,GAAG,GAAC,GAAG,CAAC;AACjD,MAAM,MAAM,gBAAgB,GAAG,GAAG,GAAC,GAAG,GAAC,GAAG,GAAC,IAAI,GAAC,IAAI,GAAC,IAAI,CAAC;AAC1D,MAAM,MAAM,QAAQ,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,WAAW,6BAWtB,CAAC;AAEH,eAAO,MAAM,iBAAiB,GAAI,GAAG,MAAM,KAAG,CAAC,IAAI,gBAA2D,CAAC;AAC/G,eAAO,MAAM,oBAAoB,GAAI,GAAG,MAAM,KAAG,CAAC,IAAI,kBAAsD,CAAC;AAC7G,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,KAAG,CAAC,IAAI,QAA2D,CAAC;AAExG,wBAAgB,eAAe,CAAC,CAAC,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAI,MAAM,CAarG;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAI,MAAM,CAAC,CAAC,CAAC,CAwB/F"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { scalarCompare } from "./conditions";
|
|
3
|
-
/**
|
|
4
|
-
* Operator precedence and associativity
|
|
5
|
-
* Map<operator_token, [operator, precedence, associativity]>
|
|
6
|
-
*/
|
|
7
|
-
export const operatorMap = new Map([
|
|
8
|
-
['=', ['==', 1, 0]],
|
|
9
|
-
['<>', ['!=', 1, 0]],
|
|
10
|
-
['>', ['>', 1, 0]],
|
|
11
|
-
['<', ['<', 1, 0]],
|
|
12
|
-
['>=', ['>=', 1, 0]],
|
|
13
|
-
['<=', ['<=', 1, 0]],
|
|
14
|
-
['+', ['+', 2, 0]],
|
|
15
|
-
['-', ['-', 2, 0]],
|
|
16
|
-
['*', ['*', 3, 0]],
|
|
17
|
-
['/', ['/', 3, 0]],
|
|
18
|
-
]);
|
|
19
|
-
export const isLogicalOperator = (o) => ['=', '>', '<', '>=', '<='].includes(o);
|
|
20
|
-
export const isArythmeticOperator = (o) => ['+', '-', '*', '/'].includes(o);
|
|
21
|
-
export const isOperator = (o) => isArythmeticOperator(o) || isLogicalOperator(o);
|
|
22
|
-
export function scalarOperation(s1, s2, operator) {
|
|
23
|
-
switch (operator) {
|
|
24
|
-
case '+': return s1 + s2;
|
|
25
|
-
case '-': return s1 - s2;
|
|
26
|
-
case '*': return s1 * s2;
|
|
27
|
-
case '/': return s1 / s2;
|
|
28
|
-
case '=': return scalarCompare(s1, s2) == 0;
|
|
29
|
-
case '>': return scalarCompare(s1, s2) > 0;
|
|
30
|
-
case '<': return scalarCompare(s1, s2) < 0;
|
|
31
|
-
case '>=': return scalarCompare(s1, s2) >= 0;
|
|
32
|
-
case '<=': return scalarCompare(s1, s2) <= 0;
|
|
33
|
-
default: throw new Error(`Invalid operator: ${operator}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export function matrixOperation(m1, m2, operator) {
|
|
37
|
-
const a1 = Array.isArray(m1);
|
|
38
|
-
const a2 = Array.isArray(m2);
|
|
39
|
-
if (!a1 && !a2) {
|
|
40
|
-
return [[scalarOperation(m1, m2, operator)]];
|
|
41
|
-
}
|
|
42
|
-
const r = Math.max(a1 ? m1.length : 0, a2 ? m2.length : 0);
|
|
43
|
-
const c = Math.max(a1 ? m1[0].length : 0, a2 ? m2[0].length : 0);
|
|
44
|
-
const result = [];
|
|
45
|
-
for (let i = 0; i < r; i++) {
|
|
46
|
-
const row = [];
|
|
47
|
-
for (let j = 0; j < c; j++) {
|
|
48
|
-
const v1 = a1 ? m1[i]?.[j] : m1;
|
|
49
|
-
const v2 = a2 ? m2[i]?.[j] : m2;
|
|
50
|
-
const v = v1 == null && v2 == null ? null
|
|
51
|
-
: scalarOperation(v1, v2, operator);
|
|
52
|
-
row.push(v);
|
|
53
|
-
}
|
|
54
|
-
result.push(row);
|
|
55
|
-
}
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=operators.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operators.js","sourceRoot":"","sources":["../../src/calculations/operators.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAGvD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAW7C;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CA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,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { Matrix, Scalar } from \"@omegagrid/core\";\nimport { scalarCompare } from \"./conditions\";\n\nexport type ArythmeticOperator = '*'|'/'|'+'|'-';\nexport type LogicalOperataor = '='|'>'|'<'|'>='|'<='|'<>';\nexport type Operator = ArythmeticOperator | LogicalOperataor;\n\n/**\n * [javascript operator, precedence, associativity]\n */\nexport type OperatorSpec = [string, number, number];\n\n/**\n * Operator precedence and associativity\n * Map<operator_token, [operator, precedence, associativity]>\n */\nexport const operatorMap = new Map<Operator, OperatorSpec>([\n\t['=', ['==', 1, 0]],\n\t['<>', ['!=', 1, 0]],\n\t['>', ['>', 1, 0]],\n\t['<', ['<', 1, 0]],\n\t['>=', ['>=', 1, 0]],\n\t['<=', ['<=', 1, 0]],\n\t['+', ['+', 2, 0]],\n\t['-', ['-', 2, 0]],\n\t['*', ['*', 3, 0]],\n\t['/', ['/', 3, 0]],\n]);\n\nexport const isLogicalOperator = (o: string): o is LogicalOperataor => ['=', '>', '<', '>=', '<='].includes(o);\nexport const isArythmeticOperator = (o: string): o is ArythmeticOperator => ['+', '-', '*', '/'].includes(o);\nexport const isOperator = (o: string): o is Operator => isArythmeticOperator(o) || isLogicalOperator(o);\n\nexport function scalarOperation<T = number>(s1: Scalar<T>, s2: Scalar<T>, operator: Operator) : Scalar {\n\tswitch (operator) {\n\t\tcase '+': return (s1 as number) + (s2 as number);\n\t\tcase '-': return (s1 as number) - (s2 as number);\n\t\tcase '*': return (s1 as number) * (s2 as number);\n\t\tcase '/': return (s1 as number) / (s2 as number);\n\t\tcase '=': return scalarCompare(s1, s2) == 0;\n\t\tcase '>': return scalarCompare(s1, s2) > 0;\n\t\tcase '<': return scalarCompare(s1, s2) < 0;\n\t\tcase '>=': return scalarCompare(s1, s2) >= 0;\n\t\tcase '<=': return scalarCompare(s1, s2) <= 0;\n\t\tdefault: throw new Error(`Invalid operator: ${operator}`);\n\t}\n}\n\nexport function matrixOperation<T>(m1: Matrix<T>, m2: Matrix<T>, operator: Operator) : Matrix<T> {\n\tconst a1 = Array.isArray(m1);\n\tconst a2 = Array.isArray(m2);\n\tif (!a1 && !a2) {\n\t\treturn [[scalarOperation(m1 as Scalar<number>, m2 as Scalar<number>, operator) as Scalar<T>]];\n\t}\n\n\tconst r = Math.max(a1 ? m1.length : 0, a2 ? m2.length : 0);\n\tconst c = Math.max(a1 ? m1[0].length : 0, a2 ? m2[0].length : 0);\n\tconst result = [];\n\t\n\tfor (let i = 0; i < r; i++) {\n\t\tconst row: Scalar<T>[] = [];\n\t\tfor (let j = 0; j < c; j++) {\n\t\t\tconst v1 = a1 ? m1[i]?.[j] : m1;\n\t\t\tconst v2 = a2 ? m2[i]?.[j] : m2;\n\t\t\tconst v = v1 == null && v2 == null ? null\n\t\t\t\t: scalarOperation(v1 as Scalar<number>, v2 as Scalar<number>, operator) as Scalar<T>;\n\t\t\trow.push(v);\n\t\t}\n\t\tresult.push(row);\n\t}\n\n\treturn result;\n}"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export declare enum TokenType {
|
|
2
|
-
Number = 0,
|
|
3
|
-
Boolean = 1,
|
|
4
|
-
String = 2,
|
|
5
|
-
StringQuote = 3,
|
|
6
|
-
Function = 4,
|
|
7
|
-
ArgumentSeparator = 5,
|
|
8
|
-
OpenBracket = 6,
|
|
9
|
-
CloseBracket = 7,
|
|
10
|
-
Operator = 8,
|
|
11
|
-
Cell = 9,
|
|
12
|
-
Variable = 10,
|
|
13
|
-
Range = 11,
|
|
14
|
-
Sheet = 12,
|
|
15
|
-
SheetQuote = 13,
|
|
16
|
-
SheetSeparator = 14,
|
|
17
|
-
Unknown = 15,
|
|
18
|
-
Operand = 16
|
|
19
|
-
}
|
|
20
|
-
export type Token = [string, TokenType];
|
|
21
|
-
export declare const isOperand: (type: TokenType) => type is TokenType.Number | TokenType.Boolean | TokenType.String | TokenType.Cell | TokenType.Variable | TokenType.Range;
|
|
22
|
-
export declare const isNumber: (code: number) => boolean;
|
|
23
|
-
export declare const isBool: (value: string) => boolean;
|
|
24
|
-
export declare const isLetter: (code: number) => boolean;
|
|
25
|
-
export type TokenizationOptions = {
|
|
26
|
-
decimalPoint: string;
|
|
27
|
-
stringQuote: string;
|
|
28
|
-
sheetQuote: string;
|
|
29
|
-
argumentSeparator: string;
|
|
30
|
-
};
|
|
31
|
-
export declare class Tokenizer {
|
|
32
|
-
readonly options: TokenizationOptions;
|
|
33
|
-
constructor(options?: Partial<TokenizationOptions>);
|
|
34
|
-
tokenize(formula: string): Token[];
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=tokenization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokenization.d.ts","sourceRoot":"","sources":["../../src/calculations/tokenization.ts"],"names":[],"mappings":"AAEA,oBAAY,SAAS;IACpB,MAAM,IAAA;IACN,OAAO,IAAA;IACP,MAAM,IAAA;IACN,WAAW,IAAA;IACX,QAAQ,IAAA;IACR,iBAAiB,IAAA;IACjB,WAAW,IAAA;IACX,YAAY,IAAA;IACZ,QAAQ,IAAA;IACR,IAAI,IAAA;IACJ,QAAQ,KAAA;IACR,KAAK,KAAA;IACL,KAAK,KAAA;IACL,UAAU,KAAA;IACV,cAAc,KAAA;IACd,OAAO,KAAA;IACP,OAAO,KAAA;CACP;AAED,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAExC,eAAO,MAAM,SAAS,GAAI,MAAM,SAAS,4HAExC,CAAA;AAGD,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,YAA6B,CAAC;AAGnE,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,YAGnC,CAAA;AAGD,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,YAGR,CAAC;AAI9B,MAAM,MAAM,mBAAmB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,MAAM,CAAC;CAC1B,CAAA;AASD,qBAAa,SAAS;IACrB,SAAgB,OAAO,EAAE,mBAAmB,CAAC;gBAEjC,OAAO,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAIlD,QAAQ,CAAC,OAAO,EAAE,MAAM;CA8IxB"}
|