@syncfusion/ej2-calculate 35.1.37

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 (173) hide show
  1. package/.eslintrc.json +263 -0
  2. package/README.md +132 -0
  3. package/base.d.ts +4 -0
  4. package/base.js +4 -0
  5. package/common.d.ts +4 -0
  6. package/common.js +4 -0
  7. package/dist/ej2-calculate.umd.min.js +11 -0
  8. package/dist/ej2-calculate.umd.min.js.map +1 -0
  9. package/dist/es6/ej2-calculate.es2015.js +24801 -0
  10. package/dist/es6/ej2-calculate.es2015.js.map +1 -0
  11. package/dist/es6/ej2-calculate.es5.js +27229 -0
  12. package/dist/es6/ej2-calculate.es5.js.map +1 -0
  13. package/dist/global/ej2-calculate.min.js +11 -0
  14. package/dist/global/ej2-calculate.min.js.map +1 -0
  15. package/dist/global/index.d.ts +14 -0
  16. package/formulas.d.ts +4 -0
  17. package/formulas.js +4 -0
  18. package/index.d.ts +4 -0
  19. package/index.js +4 -0
  20. package/license +10 -0
  21. package/package.json +30 -0
  22. package/src/base/calculate-model.d.ts +4 -0
  23. package/src/base/calculate-model.js +0 -0
  24. package/src/base/calculate.d.ts +1105 -0
  25. package/src/base/calculate.js +4720 -0
  26. package/src/base/index.d.ts +8 -0
  27. package/src/base/index.js +7 -0
  28. package/src/base/parser.d.ts +208 -0
  29. package/src/base/parser.js +1512 -0
  30. package/src/common/address.d.ts +59 -0
  31. package/src/common/address.js +96 -0
  32. package/src/common/cell-ref.d.ts +32 -0
  33. package/src/common/cell-ref.js +112 -0
  34. package/src/common/common.d.ts +44 -0
  35. package/src/common/common.js +134 -0
  36. package/src/common/enum.d.ts +94 -0
  37. package/src/common/enum.js +97 -0
  38. package/src/common/index.d.ts +9 -0
  39. package/src/common/index.js +8 -0
  40. package/src/common/interface.d.ts +122 -0
  41. package/src/common/interface.js +0 -0
  42. package/src/common/l10n.d.ts +24 -0
  43. package/src/common/l10n.js +54 -0
  44. package/src/common/number-date.d.ts +26 -0
  45. package/src/common/number-date.js +38 -0
  46. package/src/common/sheet-info.d.ts +10 -0
  47. package/src/common/sheet-info.js +17 -0
  48. package/src/common/sort.d.ts +17 -0
  49. package/src/common/sort.js +44 -0
  50. package/src/formulas/array.d.ts +47 -0
  51. package/src/formulas/array.js +718 -0
  52. package/src/formulas/basic.d.ts +47 -0
  53. package/src/formulas/basic.js +181 -0
  54. package/src/formulas/complex-numbers.d.ts +207 -0
  55. package/src/formulas/complex-numbers.js +549 -0
  56. package/src/formulas/database.d.ts +152 -0
  57. package/src/formulas/database.js +579 -0
  58. package/src/formulas/date-time-extra.d.ts +97 -0
  59. package/src/formulas/date-time-extra.js +415 -0
  60. package/src/formulas/date-time-intl.d.ts +57 -0
  61. package/src/formulas/date-time-intl.js +309 -0
  62. package/src/formulas/date-time.d.ts +164 -0
  63. package/src/formulas/date-time.js +1021 -0
  64. package/src/formulas/engineering-base.d.ts +150 -0
  65. package/src/formulas/engineering-base.js +404 -0
  66. package/src/formulas/engineering-bessel.d.ts +65 -0
  67. package/src/formulas/engineering-bessel.js +167 -0
  68. package/src/formulas/engineering-convert.d.ts +35 -0
  69. package/src/formulas/engineering-convert.js +120 -0
  70. package/src/formulas/engineering-misc.d.ts +64 -0
  71. package/src/formulas/engineering-misc.js +168 -0
  72. package/src/formulas/financial-amortization-ecma.d.ts +87 -0
  73. package/src/formulas/financial-amortization-ecma.js +288 -0
  74. package/src/formulas/financial-annuity.d.ts +104 -0
  75. package/src/formulas/financial-annuity.js +419 -0
  76. package/src/formulas/financial-bond-helpers.d.ts +106 -0
  77. package/src/formulas/financial-bond-helpers.js +190 -0
  78. package/src/formulas/financial-cashflow.d.ts +47 -0
  79. package/src/formulas/financial-cashflow.js +203 -0
  80. package/src/formulas/financial-coupons.d.ts +227 -0
  81. package/src/formulas/financial-coupons.js +810 -0
  82. package/src/formulas/financial-depreciation.d.ts +64 -0
  83. package/src/formulas/financial-depreciation.js +247 -0
  84. package/src/formulas/financial-rates.d.ts +54 -0
  85. package/src/formulas/financial-rates.js +140 -0
  86. package/src/formulas/financial-securities.d.ts +126 -0
  87. package/src/formulas/financial-securities.js +488 -0
  88. package/src/formulas/formula-math-helpers.d.ts +212 -0
  89. package/src/formulas/formula-math-helpers.js +599 -0
  90. package/src/formulas/formula-module-base.d.ts +54 -0
  91. package/src/formulas/formula-module-base.js +125 -0
  92. package/src/formulas/formula-owner.d.ts +17 -0
  93. package/src/formulas/formula-owner.js +0 -0
  94. package/src/formulas/index.d.ts +68 -0
  95. package/src/formulas/index.js +67 -0
  96. package/src/formulas/information-advanced.d.ts +44 -0
  97. package/src/formulas/information-advanced.js +157 -0
  98. package/src/formulas/information-ecma.d.ts +33 -0
  99. package/src/formulas/information-ecma.js +88 -0
  100. package/src/formulas/information-extra.d.ts +146 -0
  101. package/src/formulas/information-extra.js +351 -0
  102. package/src/formulas/information.d.ts +34 -0
  103. package/src/formulas/information.js +78 -0
  104. package/src/formulas/logical-extra.d.ts +75 -0
  105. package/src/formulas/logical-extra.js +217 -0
  106. package/src/formulas/logical.d.ts +83 -0
  107. package/src/formulas/logical.js +296 -0
  108. package/src/formulas/lookup-array.d.ts +98 -0
  109. package/src/formulas/lookup-array.js +364 -0
  110. package/src/formulas/lookup-ref-extra.d.ts +64 -0
  111. package/src/formulas/lookup-ref-extra.js +180 -0
  112. package/src/formulas/lookup-ref.d.ts +84 -0
  113. package/src/formulas/lookup-ref.js +263 -0
  114. package/src/formulas/lookup.d.ts +114 -0
  115. package/src/formulas/lookup.js +881 -0
  116. package/src/formulas/math-aggregate.d.ts +74 -0
  117. package/src/formulas/math-aggregate.js +376 -0
  118. package/src/formulas/math-ceiling-ecma.d.ts +42 -0
  119. package/src/formulas/math-ceiling-ecma.js +123 -0
  120. package/src/formulas/math-combinatorics.d.ts +75 -0
  121. package/src/formulas/math-combinatorics.js +290 -0
  122. package/src/formulas/math-misc.d.ts +164 -0
  123. package/src/formulas/math-misc.js +889 -0
  124. package/src/formulas/math-number.d.ts +76 -0
  125. package/src/formulas/math-number.js +261 -0
  126. package/src/formulas/math-rounding.d.ts +115 -0
  127. package/src/formulas/math-rounding.js +728 -0
  128. package/src/formulas/math-trig-hyperbolic.d.ts +55 -0
  129. package/src/formulas/math-trig-hyperbolic.js +113 -0
  130. package/src/formulas/math-trig.d.ts +165 -0
  131. package/src/formulas/math-trig.js +334 -0
  132. package/src/formulas/matrix-base.d.ts +13 -0
  133. package/src/formulas/matrix-base.js +169 -0
  134. package/src/formulas/matrix.d.ts +64 -0
  135. package/src/formulas/matrix.js +161 -0
  136. package/src/formulas/regression-ecma.d.ts +66 -0
  137. package/src/formulas/regression-ecma.js +234 -0
  138. package/src/formulas/statistical-advanced.d.ts +125 -0
  139. package/src/formulas/statistical-advanced.js +756 -0
  140. package/src/formulas/statistical-correlation.d.ts +75 -0
  141. package/src/formulas/statistical-correlation.js +198 -0
  142. package/src/formulas/statistical-dispersion.d.ts +108 -0
  143. package/src/formulas/statistical-dispersion.js +337 -0
  144. package/src/formulas/statistical-distribution-extended.d.ts +176 -0
  145. package/src/formulas/statistical-distribution-extended.js +668 -0
  146. package/src/formulas/statistical-distribution.d.ts +104 -0
  147. package/src/formulas/statistical-distribution.js +368 -0
  148. package/src/formulas/statistical-ecma.d.ts +95 -0
  149. package/src/formulas/statistical-ecma.js +392 -0
  150. package/src/formulas/statistical-extended.d.ts +136 -0
  151. package/src/formulas/statistical-extended.js +340 -0
  152. package/src/formulas/statistical-ifs.d.ts +46 -0
  153. package/src/formulas/statistical-ifs.js +180 -0
  154. package/src/formulas/statistical-moments.d.ts +84 -0
  155. package/src/formulas/statistical-moments.js +269 -0
  156. package/src/formulas/statistical-percentile.d.ts +56 -0
  157. package/src/formulas/statistical-percentile.js +195 -0
  158. package/src/formulas/statistical-sample-base.d.ts +14 -0
  159. package/src/formulas/statistical-sample-base.js +124 -0
  160. package/src/formulas/statistical.d.ts +135 -0
  161. package/src/formulas/statistical.js +542 -0
  162. package/src/formulas/text-advanced.d.ts +64 -0
  163. package/src/formulas/text-advanced.js +222 -0
  164. package/src/formulas/text-ecma.d.ts +54 -0
  165. package/src/formulas/text-ecma.js +106 -0
  166. package/src/formulas/text-extra.d.ts +216 -0
  167. package/src/formulas/text-extra.js +657 -0
  168. package/src/formulas/text.d.ts +125 -0
  169. package/src/formulas/text.js +628 -0
  170. package/src/global.js +1 -0
  171. package/src/index.d.ts +14 -0
  172. package/src/index.js +14 -0
  173. package/tslint.json +111 -0
@@ -0,0 +1,167 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { FormulasErrorsStrings, CommonErrors } from '../common/index';
15
+ import { isNullOrUndefined } from '@syncfusion/ej2-base';
16
+ import { FormulaModuleBase } from './formula-module-base';
17
+ import { besselI, besselJ, besselK, besselY } from './formula-math-helpers';
18
+ /**
19
+ * Bessel function family (J, Y, I, K) for oscillatory and decaying physical models.
20
+ *
21
+ * Registered functions: BESSELI, BESSELJ, BESSELK, BESSELY.
22
+ *
23
+ * @hidden
24
+ */
25
+ var EngineeringBesselFormulas = /** @class */ (function (_super) {
26
+ __extends(EngineeringBesselFormulas, _super);
27
+ /**
28
+ * @hidden
29
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
30
+ */
31
+ function EngineeringBesselFormulas(owner) {
32
+ var _this = _super.call(this, owner) || this;
33
+ /** Formula definitions registered with {@link BasicFormulas}. */
34
+ _this.formulas = [
35
+ { formulaName: 'BESSELI', category: 'Engineering', description: 'Returns the modified Bessel function In(x).' },
36
+ { formulaName: 'BESSELJ', category: 'Engineering', description: 'Returns the Bessel function Jn(x).' },
37
+ { formulaName: 'BESSELK', category: 'Engineering', description: 'Returns the modified Bessel function Kn(x).' },
38
+ { formulaName: 'BESSELY', category: 'Engineering', description: 'Returns the Bessel function Yn(x).' }
39
+ ];
40
+ return _this;
41
+ }
42
+ EngineeringBesselFormulas.prototype.besselArgs = function (args) {
43
+ var errCollection = this.parent.getErrorStrings();
44
+ if (isNullOrUndefined(args) || args.length !== 2) {
45
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
46
+ }
47
+ var x = this.resolveNumberArg(args[0]);
48
+ var n = this.resolveNumberArg(args[1]);
49
+ if (typeof x === 'string') {
50
+ return x;
51
+ }
52
+ if (typeof n === 'string') {
53
+ return n;
54
+ }
55
+ if (n < 0) {
56
+ return errCollection[CommonErrors.Num];
57
+ }
58
+ return { x: x, n: Math.floor(n) };
59
+ };
60
+ /**
61
+ * Returns the modified Bessel function In(x).
62
+ *
63
+ * Excel: `BESSELI(...)`.
64
+ *
65
+ * @hidden
66
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
67
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * engine.computeFormula('=BESSELI(1)');
72
+ * ```
73
+ */
74
+ EngineeringBesselFormulas.prototype.ComputeBESSELI = function () {
75
+ var args = [];
76
+ for (var _i = 0; _i < arguments.length; _i++) {
77
+ args[_i] = arguments[_i];
78
+ }
79
+ var parsed = this.besselArgs(args);
80
+ if (typeof parsed === 'string') {
81
+ return parsed;
82
+ }
83
+ var result = besselI(parsed.n, parsed.x);
84
+ if (!isFinite(result)) {
85
+ return this.parent.getErrorStrings()[CommonErrors.Num];
86
+ }
87
+ return result.toString();
88
+ };
89
+ /**
90
+ * Returns the Bessel function Jn(x).
91
+ *
92
+ * Excel: `BESSELJ(...)`.
93
+ *
94
+ * @hidden
95
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
96
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
97
+ */
98
+ EngineeringBesselFormulas.prototype.ComputeBESSELJ = function () {
99
+ var args = [];
100
+ for (var _i = 0; _i < arguments.length; _i++) {
101
+ args[_i] = arguments[_i];
102
+ }
103
+ var parsed = this.besselArgs(args);
104
+ if (typeof parsed === 'string') {
105
+ return parsed;
106
+ }
107
+ return besselJ(parsed.n, parsed.x).toString();
108
+ };
109
+ /**
110
+ * Returns the modified Bessel function Kn(x).
111
+ *
112
+ * Excel: `BESSELK(...)`.
113
+ *
114
+ * @hidden
115
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
116
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
117
+ */
118
+ EngineeringBesselFormulas.prototype.ComputeBESSELK = function () {
119
+ var args = [];
120
+ for (var _i = 0; _i < arguments.length; _i++) {
121
+ args[_i] = arguments[_i];
122
+ }
123
+ var errCollection = this.parent.getErrorStrings();
124
+ var parsed = this.besselArgs(args);
125
+ if (typeof parsed === 'string') {
126
+ return parsed;
127
+ }
128
+ if (parsed.x <= 0) {
129
+ return errCollection[CommonErrors.Num];
130
+ }
131
+ var result = besselK(parsed.n, parsed.x);
132
+ if (!isFinite(result)) {
133
+ return errCollection[CommonErrors.Num];
134
+ }
135
+ return result.toString();
136
+ };
137
+ /**
138
+ * Returns the Bessel function Yn(x).
139
+ *
140
+ * Excel: `BESSELY(...)`.
141
+ *
142
+ * @hidden
143
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
144
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
145
+ */
146
+ EngineeringBesselFormulas.prototype.ComputeBESSELY = function () {
147
+ var args = [];
148
+ for (var _i = 0; _i < arguments.length; _i++) {
149
+ args[_i] = arguments[_i];
150
+ }
151
+ var errCollection = this.parent.getErrorStrings();
152
+ var parsed = this.besselArgs(args);
153
+ if (typeof parsed === 'string') {
154
+ return parsed;
155
+ }
156
+ if (parsed.x <= 0) {
157
+ return errCollection[CommonErrors.Num];
158
+ }
159
+ var result = besselY(parsed.n, parsed.x);
160
+ if (!isFinite(result)) {
161
+ return errCollection[CommonErrors.Num];
162
+ }
163
+ return result.toString();
164
+ };
165
+ return EngineeringBesselFormulas;
166
+ }(FormulaModuleBase));
167
+ export { EngineeringBesselFormulas };
@@ -0,0 +1,35 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { FormulaModuleBase } from './formula-module-base';
4
+ /**
5
+ * Unit conversion between engineering measurement systems via the CONVERT function.
6
+ *
7
+ * Registered functions: CONVERT.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class EngineeringConvertFormulas extends FormulaModuleBase {
12
+ private static readonly UNITS;
13
+ /** Formula definitions registered with {@link BasicFormulas}. */
14
+ formulas: IBasicFormula[];
15
+ /**
16
+ * @hidden
17
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
18
+ */
19
+ constructor(owner: FormulaOwner);
20
+ /**
21
+ * Converts a number from one measurement system to another.
22
+ *
23
+ * Excel: `CONVERT(...)`.
24
+ *
25
+ * @hidden
26
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
27
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * engine.computeFormula('=CONVERT(1)');
32
+ * ```
33
+ */
34
+ ComputeCONVERT(...args: string[]): string | number;
35
+ }
@@ -0,0 +1,120 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { FormulasErrorsStrings, CommonErrors } from '../common/index';
15
+ import { isNullOrUndefined } from '@syncfusion/ej2-base';
16
+ import { FormulaModuleBase } from './formula-module-base';
17
+ /**
18
+ * Unit conversion between engineering measurement systems via the CONVERT function.
19
+ *
20
+ * Registered functions: CONVERT.
21
+ *
22
+ * @hidden
23
+ */
24
+ var EngineeringConvertFormulas = /** @class */ (function (_super) {
25
+ __extends(EngineeringConvertFormulas, _super);
26
+ /**
27
+ * @hidden
28
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
29
+ */
30
+ function EngineeringConvertFormulas(owner) {
31
+ var _this = _super.call(this, owner) || this;
32
+ /** Formula definitions registered with {@link BasicFormulas}. */
33
+ _this.formulas = [
34
+ { formulaName: 'CONVERT', category: 'Engineering', description: 'Converts a number from one measurement system to another.' }
35
+ ];
36
+ return _this;
37
+ }
38
+ /**
39
+ * Converts a number from one measurement system to another.
40
+ *
41
+ * Excel: `CONVERT(...)`.
42
+ *
43
+ * @hidden
44
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
45
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * engine.computeFormula('=CONVERT(1)');
50
+ * ```
51
+ */
52
+ EngineeringConvertFormulas.prototype.ComputeCONVERT = function () {
53
+ var args = [];
54
+ for (var _i = 0; _i < arguments.length; _i++) {
55
+ args[_i] = arguments[_i];
56
+ }
57
+ var errCollection = this.parent.getErrorStrings();
58
+ if (isNullOrUndefined(args) || args.length !== 3) {
59
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
60
+ }
61
+ var num = this.resolveNumberArg(args[0]);
62
+ if (typeof num === 'string') {
63
+ return num;
64
+ }
65
+ var fromUnit = this.resolveTextArg(args[1]).toLowerCase();
66
+ var toUnit = this.resolveTextArg(args[2]).toLowerCase();
67
+ if (errCollection.indexOf(fromUnit) > -1) {
68
+ return fromUnit;
69
+ }
70
+ if (errCollection.indexOf(toUnit) > -1) {
71
+ return toUnit;
72
+ }
73
+ if (fromUnit === toUnit) {
74
+ return num.toString();
75
+ }
76
+ if (fromUnit === 'c' && toUnit === 'f') {
77
+ return (num * 9 / 5 + 32).toString();
78
+ }
79
+ if (fromUnit === 'f' && toUnit === 'c') {
80
+ return ((num - 32) * 5 / 9).toString();
81
+ }
82
+ for (var _a = 0, _b = EngineeringConvertFormulas.UNITS; _a < _b.length; _a++) {
83
+ var entry = _b[_a];
84
+ if (entry.from === fromUnit && entry.to === toUnit && !isNaN(entry.factor)) {
85
+ return (num * entry.factor).toString();
86
+ }
87
+ }
88
+ var viaBase = EngineeringConvertFormulas.UNITS.find(function (e) { return e.from === fromUnit && !isNaN(e.factor); });
89
+ var viaBaseTo = viaBase ? viaBase.to : undefined;
90
+ var toBase = EngineeringConvertFormulas.UNITS.find(function (e) { return e.to === toUnit && e.from === viaBaseTo && !isNaN(e.factor); });
91
+ if (viaBase && toBase) {
92
+ return (num * viaBase.factor * toBase.factor).toString();
93
+ }
94
+ return errCollection[CommonErrors.NA];
95
+ };
96
+ EngineeringConvertFormulas.UNITS = [
97
+ { from: 'g', to: 'kg', factor: 0.001 },
98
+ { from: 'kg', to: 'g', factor: 1000 },
99
+ { from: 'lbm', to: 'kg', factor: 0.45359237 },
100
+ { from: 'kg', to: 'lbm', factor: 2.2046226218 },
101
+ { from: 'm', to: 'ft', factor: 3.280839895 },
102
+ { from: 'ft', to: 'm', factor: 0.3048 },
103
+ { from: 'in', to: 'm', factor: 0.0254 },
104
+ { from: 'm', to: 'in', factor: 39.37007874 },
105
+ { from: 'mi', to: 'm', factor: 1609.344 },
106
+ { from: 'm', to: 'mi', factor: 1 / 1609.344 },
107
+ { from: 'yr', to: 'day', factor: 365.25 },
108
+ { from: 'day', to: 'yr', factor: 1 / 365.25 },
109
+ { from: 'hr', to: 'sec', factor: 3600 },
110
+ { from: 'sec', to: 'hr', factor: 1 / 3600 },
111
+ { from: 'C', to: 'F', factor: NaN },
112
+ { from: 'F', to: 'C', factor: NaN },
113
+ { from: 'l', to: 'm3', factor: 0.001 },
114
+ { from: 'm3', to: 'l', factor: 1000 },
115
+ { from: 'N', to: 'lbf', factor: 0.224808943 },
116
+ { from: 'lbf', to: 'N', factor: 4.4482216153 }
117
+ ];
118
+ return EngineeringConvertFormulas;
119
+ }(FormulaModuleBase));
120
+ export { EngineeringConvertFormulas };
@@ -0,0 +1,64 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { FormulaModuleBase } from './formula-module-base';
4
+ /**
5
+ * Miscellaneous engineering functions including delta, gestep, and related step/threshold helpers.
6
+ *
7
+ * Registered functions: DELTA, GESTEP, ERF, ERFC.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class EngineeringMiscFormulas extends FormulaModuleBase {
12
+ /** Formula definitions registered with {@link BasicFormulas}. */
13
+ formulas: IBasicFormula[];
14
+ /**
15
+ * @hidden
16
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
17
+ */
18
+ constructor(owner: FormulaOwner);
19
+ /**
20
+ * Tests whether two values are equal.
21
+ *
22
+ * Excel: `DELTA(...)`.
23
+ *
24
+ * @hidden
25
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
26
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * engine.computeFormula('=DELTA(1)');
31
+ * ```
32
+ */
33
+ ComputeDELTA(...args: string[]): string | number;
34
+ /**
35
+ * Tests whether a number is greater than a threshold.
36
+ *
37
+ * Excel: `GESTEP(...)`.
38
+ *
39
+ * @hidden
40
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
41
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
42
+ */
43
+ ComputeGESTEP(...args: string[]): string | number;
44
+ /**
45
+ * Returns the error function.
46
+ *
47
+ * Excel: `ERF(...)`.
48
+ *
49
+ * @hidden
50
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
51
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
52
+ */
53
+ ComputeERF(...args: string[]): string | number;
54
+ /**
55
+ * Returns the complementary error function.
56
+ *
57
+ * Excel: `ERFC(...)`.
58
+ *
59
+ * @hidden
60
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
61
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
62
+ */
63
+ ComputeERFC(...args: string[]): string | number;
64
+ }
@@ -0,0 +1,168 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { FormulasErrorsStrings } from '../common/index';
15
+ import { isNullOrUndefined } from '@syncfusion/ej2-base';
16
+ import { FormulaModuleBase } from './formula-module-base';
17
+ import { erf, erfc } from './formula-math-helpers';
18
+ /**
19
+ * Miscellaneous engineering functions including delta, gestep, and related step/threshold helpers.
20
+ *
21
+ * Registered functions: DELTA, GESTEP, ERF, ERFC.
22
+ *
23
+ * @hidden
24
+ */
25
+ var EngineeringMiscFormulas = /** @class */ (function (_super) {
26
+ __extends(EngineeringMiscFormulas, _super);
27
+ /**
28
+ * @hidden
29
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
30
+ */
31
+ function EngineeringMiscFormulas(owner) {
32
+ var _this = _super.call(this, owner) || this;
33
+ /** Formula definitions registered with {@link BasicFormulas}. */
34
+ _this.formulas = [
35
+ { formulaName: 'DELTA', category: 'Engineering', description: 'Tests whether two values are equal.' },
36
+ { formulaName: 'GESTEP', category: 'Engineering', description: 'Tests whether a number is greater than a threshold.' },
37
+ { formulaName: 'ERF', category: 'Engineering', description: 'Returns the error function.' },
38
+ { formulaName: 'ERFC', category: 'Engineering', description: 'Returns the complementary error function.' }
39
+ ];
40
+ return _this;
41
+ }
42
+ /**
43
+ * Tests whether two values are equal.
44
+ *
45
+ * Excel: `DELTA(...)`.
46
+ *
47
+ * @hidden
48
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
49
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * engine.computeFormula('=DELTA(1)');
54
+ * ```
55
+ */
56
+ EngineeringMiscFormulas.prototype.ComputeDELTA = function () {
57
+ var args = [];
58
+ for (var _i = 0; _i < arguments.length; _i++) {
59
+ args[_i] = arguments[_i];
60
+ }
61
+ if (isNullOrUndefined(args) || args.length < 1 || args.length > 2) {
62
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
63
+ }
64
+ var a = this.resolveNumberArg(args[0]);
65
+ if (typeof a === 'string') {
66
+ return a;
67
+ }
68
+ var b = 0;
69
+ if (args.length === 2) {
70
+ var bArg = this.resolveNumberArg(args[1]);
71
+ if (typeof bArg === 'string') {
72
+ return bArg;
73
+ }
74
+ b = bArg;
75
+ }
76
+ return (a === b ? 1 : 0).toString();
77
+ };
78
+ /**
79
+ * Tests whether a number is greater than a threshold.
80
+ *
81
+ * Excel: `GESTEP(...)`.
82
+ *
83
+ * @hidden
84
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
85
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
86
+ */
87
+ EngineeringMiscFormulas.prototype.ComputeGESTEP = function () {
88
+ var args = [];
89
+ for (var _i = 0; _i < arguments.length; _i++) {
90
+ args[_i] = arguments[_i];
91
+ }
92
+ if (isNullOrUndefined(args) || args.length < 1 || args.length > 2) {
93
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
94
+ }
95
+ var num = this.resolveNumberArg(args[0]);
96
+ if (typeof num === 'string') {
97
+ return num;
98
+ }
99
+ var step = 0;
100
+ if (args.length === 2) {
101
+ var stepArg = this.resolveNumberArg(args[1]);
102
+ if (typeof stepArg === 'string') {
103
+ return stepArg;
104
+ }
105
+ step = stepArg;
106
+ }
107
+ return (num >= step ? 1 : 0).toString();
108
+ };
109
+ /**
110
+ * Returns the error function.
111
+ *
112
+ * Excel: `ERF(...)`.
113
+ *
114
+ * @hidden
115
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
116
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
117
+ */
118
+ EngineeringMiscFormulas.prototype.ComputeERF = function () {
119
+ var args = [];
120
+ for (var _i = 0; _i < arguments.length; _i++) {
121
+ args[_i] = arguments[_i];
122
+ }
123
+ if (isNullOrUndefined(args) || args.length < 1 || args.length > 2) {
124
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
125
+ }
126
+ if (args.length === 1) {
127
+ var x = this.resolveNumberArg(args[0]);
128
+ if (typeof x === 'string') {
129
+ return x;
130
+ }
131
+ return erf(x).toString();
132
+ }
133
+ var lower = this.resolveNumberArg(args[0]);
134
+ var upper = this.resolveNumberArg(args[1]);
135
+ if (typeof lower === 'string') {
136
+ return lower;
137
+ }
138
+ if (typeof upper === 'string') {
139
+ return upper;
140
+ }
141
+ return (erf(upper) - erf(lower)).toString();
142
+ };
143
+ /**
144
+ * Returns the complementary error function.
145
+ *
146
+ * Excel: `ERFC(...)`.
147
+ *
148
+ * @hidden
149
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
150
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
151
+ */
152
+ EngineeringMiscFormulas.prototype.ComputeERFC = function () {
153
+ var args = [];
154
+ for (var _i = 0; _i < arguments.length; _i++) {
155
+ args[_i] = arguments[_i];
156
+ }
157
+ if (isNullOrUndefined(args) || args.length !== 1) {
158
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
159
+ }
160
+ var x = this.resolveNumberArg(args[0]);
161
+ if (typeof x === 'string') {
162
+ return x;
163
+ }
164
+ return erfc(x).toString();
165
+ };
166
+ return EngineeringMiscFormulas;
167
+ }(FormulaModuleBase));
168
+ export { EngineeringMiscFormulas };
@@ -0,0 +1,87 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { FormulaModuleBase } from './formula-module-base';
4
+ /**
5
+ * ECMA amortization and odd-period bond pricing/yield functions for European accounting conventions.
6
+ *
7
+ * Registered functions: AMORDEGRC, AMORLINC, ODDFPRICE, ODDFYIELD, ODDLPRICE, ODDLYIELD.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class FinancialAmortizationEcmaFormulas extends FormulaModuleBase {
12
+ private bond;
13
+ /** Formula definitions registered with {@link BasicFormulas}. */
14
+ formulas: IBasicFormula[];
15
+ /**
16
+ * @hidden
17
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
18
+ */
19
+ constructor(owner: FormulaOwner);
20
+ /**
21
+ * Returns the depreciation for each accounting period.
22
+ *
23
+ * Excel: `AMORLINC(...)`.
24
+ *
25
+ * @hidden
26
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
27
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * engine.computeFormula('=AMORLINC(1)');
32
+ * ```
33
+ */
34
+ ComputeAMORLINC(...args: string[]): string | number;
35
+ /**
36
+ * Returns the depreciation for each accounting period using a depreciation coefficient.
37
+ *
38
+ * Excel: `AMORDEGRC(...)`.
39
+ *
40
+ * @hidden
41
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
42
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
43
+ */
44
+ ComputeAMORDEGRC(...args: string[]): string | number;
45
+ private oddBondPrice;
46
+ /**
47
+ * Returns the price per $100 face value of a security with an odd first period.
48
+ *
49
+ * Excel: `ODDFPRICE(...)`.
50
+ *
51
+ * @hidden
52
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
53
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
54
+ */
55
+ ComputeODDFPRICE(...args: string[]): string | number;
56
+ /**
57
+ * Returns the price per $100 face value of a security with an odd last period.
58
+ *
59
+ * Excel: `ODDLPRICE(...)`.
60
+ *
61
+ * @hidden
62
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
63
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
64
+ */
65
+ ComputeODDLPRICE(...args: string[]): string | number;
66
+ private oddBondYield;
67
+ /**
68
+ * Returns the yield of a security with an odd first period.
69
+ *
70
+ * Excel: `ODDFYIELD(...)`.
71
+ *
72
+ * @hidden
73
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
74
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
75
+ */
76
+ ComputeODDFYIELD(...args: string[]): string | number;
77
+ /**
78
+ * Returns the yield of a security with an odd last period.
79
+ *
80
+ * Excel: `ODDLYIELD(...)`.
81
+ *
82
+ * @hidden
83
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
84
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
85
+ */
86
+ ComputeODDLYIELD(...args: string[]): string | number;
87
+ }