@lofcz/tinysheet-formula-parser 0.2.13 → 1.0.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.
Files changed (49) hide show
  1. package/dist/index.d.ts +46 -0
  2. package/dist/index.js +934 -0
  3. package/package.json +19 -41
  4. package/es/error.js +0 -45
  5. package/es/evaluate-by-operator/evaluate-by-operator.js +0 -70
  6. package/es/evaluate-by-operator/operator/add.js +0 -16
  7. package/es/evaluate-by-operator/operator/ampersand.js +0 -10
  8. package/es/evaluate-by-operator/operator/divide.js +0 -21
  9. package/es/evaluate-by-operator/operator/equal.js +0 -5
  10. package/es/evaluate-by-operator/operator/formula-function.js +0 -40
  11. package/es/evaluate-by-operator/operator/greater-than-or-equal.js +0 -5
  12. package/es/evaluate-by-operator/operator/greater-than.js +0 -5
  13. package/es/evaluate-by-operator/operator/less-than-or-equal.js +0 -5
  14. package/es/evaluate-by-operator/operator/less-than.js +0 -5
  15. package/es/evaluate-by-operator/operator/minus.js +0 -16
  16. package/es/evaluate-by-operator/operator/multiply.js +0 -16
  17. package/es/evaluate-by-operator/operator/not-equal.js +0 -5
  18. package/es/evaluate-by-operator/operator/power.js +0 -11
  19. package/es/grammar-parser/grammar-parser.jison +0 -230
  20. package/es/grammar-parser/grammar-parser.js +0 -1522
  21. package/es/helper/cell.js +0 -117
  22. package/es/helper/number.js +0 -25
  23. package/es/helper/string.js +0 -13
  24. package/es/index.js +0 -5
  25. package/es/parser.js +0 -306
  26. package/es/supported-formulas.js +0 -3
  27. package/lib/error.js +0 -53
  28. package/lib/evaluate-by-operator/evaluate-by-operator.js +0 -77
  29. package/lib/evaluate-by-operator/operator/add.js +0 -23
  30. package/lib/evaluate-by-operator/operator/ampersand.js +0 -17
  31. package/lib/evaluate-by-operator/operator/divide.js +0 -28
  32. package/lib/evaluate-by-operator/operator/equal.js +0 -12
  33. package/lib/evaluate-by-operator/operator/formula-function.js +0 -50
  34. package/lib/evaluate-by-operator/operator/greater-than-or-equal.js +0 -12
  35. package/lib/evaluate-by-operator/operator/greater-than.js +0 -12
  36. package/lib/evaluate-by-operator/operator/less-than-or-equal.js +0 -12
  37. package/lib/evaluate-by-operator/operator/less-than.js +0 -12
  38. package/lib/evaluate-by-operator/operator/minus.js +0 -23
  39. package/lib/evaluate-by-operator/operator/multiply.js +0 -23
  40. package/lib/evaluate-by-operator/operator/not-equal.js +0 -12
  41. package/lib/evaluate-by-operator/operator/power.js +0 -18
  42. package/lib/grammar-parser/grammar-parser.jison +0 -230
  43. package/lib/grammar-parser/grammar-parser.js +0 -1528
  44. package/lib/helper/cell.js +0 -128
  45. package/lib/helper/number.js +0 -32
  46. package/lib/helper/string.js +0 -19
  47. package/lib/index.js +0 -114
  48. package/lib/parser.js +0 -313
  49. package/lib/supported-formulas.js +0 -11
@@ -0,0 +1,46 @@
1
+ //#region packages/formula-parser/src/index.d.ts
2
+ declare const ERROR: "ERROR";
3
+ declare const ERROR_DIV_ZERO: "DIV/0";
4
+ declare const ERROR_NAME: "NAME";
5
+ declare const ERROR_NOT_AVAILABLE: "N/A";
6
+ declare const ERROR_NULL: "NULL";
7
+ declare const ERROR_NUM: "NUM";
8
+ declare const ERROR_REF: "REF";
9
+ declare const ERROR_VALUE: "VALUE";
10
+ declare const SUPPORTED_FORMULAS: string[];
11
+ declare function error(type: string): string | null;
12
+ type CellCoord = {
13
+ index: number;
14
+ label: string;
15
+ isAbsolute: boolean;
16
+ };
17
+ declare function extractLabel(label: string): [CellCoord, CellCoord, string | null] | [];
18
+ declare function toLabel(row: {
19
+ index: number;
20
+ isAbsolute?: boolean;
21
+ }, column: {
22
+ index: number;
23
+ isAbsolute?: boolean;
24
+ }): string;
25
+ declare function columnIndexToLabel(column: number): string;
26
+ declare function columnLabelToIndex(label: string): number;
27
+ declare function rowIndexToLabel(row: number): string;
28
+ declare function rowLabelToIndex(label: string): number;
29
+ type ParseResult = {
30
+ error: string | null;
31
+ result: unknown;
32
+ };
33
+ declare class Parser {
34
+ constructor();
35
+ parse(expression: string, options?: Record<string, unknown>): ParseResult;
36
+ setVariable(name: string, value: unknown): this;
37
+ getVariable(name: string): unknown;
38
+ setFunction(name: string, fn: (...args: unknown[]) => unknown): this;
39
+ getFunction(name: string): ((...args: unknown[]) => unknown) | undefined;
40
+ on(event: string, listener: (...args: unknown[]) => void): this;
41
+ once(event: string, listener: (...args: unknown[]) => void): this;
42
+ off(event: string, listener?: (...args: unknown[]) => void): this;
43
+ emit(event: string, ...args: unknown[]): this;
44
+ }
45
+ //#endregion
46
+ export { CellCoord, ERROR, ERROR_DIV_ZERO, ERROR_NAME, ERROR_NOT_AVAILABLE, ERROR_NULL, ERROR_NUM, ERROR_REF, ERROR_VALUE, ParseResult, Parser, Parser as default, SUPPORTED_FORMULAS, columnIndexToLabel, columnLabelToIndex, error, extractLabel, rowIndexToLabel, rowLabelToIndex, toLabel };