@leankylin-sheet/formula-parser 4.0.17 → 4.0.19

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 (4) hide show
  1. package/README.md +246 -246
  2. package/dist/index.esm.js +133 -132
  3. package/dist/index.js +133 -132
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -1,246 +1,246 @@
1
- :warning: This repository is deprecated. We've released new and improved [HyperFormula](https://github.com/handsontable/hyperformula/) engine.
2
-
3
-
4
- <details>
5
-
6
- Formula Parser [![Build Status](https://travis-ci.org/handsontable/formula-parser.png?branch=master)](https://travis-ci.org/handsontable/formula-parser) [![Test Coverage](https://codeclimate.com/github/handsontable/formula-parser/badges/coverage.svg)](https://codeclimate.com/github/handsontable/formula-parser/coverage) [![hot-formula-parser](https://img.shields.io/npm/v/hot-formula-parser.svg)](https://www.npmjs.com/package/hot-formula-parser)
7
- ==========
8
- Library provides a `Parser` class that evaluates excel and mathematical formulas.
9
-
10
- - - -
11
-
12
- ## Install
13
-
14
- A recommended way to install Formula Parser is through [NPM](https://www.npmjs.com/) using the following command:
15
-
16
- ```sh
17
- $ npm install hot-formula-parser --save
18
- ```
19
-
20
- Node.js:
21
- ```js
22
- var FormulaParser = require('hot-formula-parser').Parser;
23
- var parser = new FormulaParser();
24
-
25
- parser.parse('SUM(1, 6, 7)'); // It returns `Object {error: null, result: 14}`
26
- ```
27
-
28
- Browser:
29
- ```html
30
- <script src="/node_modules/hot-formula-parser/dist/formula-parser.min.js"></script>
31
- <script>
32
- var parser = new formulaParser.Parser();
33
-
34
- parser.parse('SUM(1, 6, 7)'); // It returns `Object {error: null, result: 14}`
35
- </script>
36
- ```
37
- ## Features
38
-
39
- It supports:
40
-
41
- * Any numbers, negative and positive as float or integer;
42
- * Arithmetic operations like `+`, `-`, `/`, `*`, `%`, `^`;
43
- * Logical operations like `AND()`, `OR()`, `NOT()`, `XOR()`;
44
- * Comparison operations like `=`, `>`, `>=`, `<`, `<=`, `<>`;
45
- * All JavaScript Math constants like `PI()`, `E()`, `LN10()`, `LN2()`, `LOG10E()`, `LOG2E()`, `SQRT1_2()`, `SQRT2()`;
46
- * String operations like `&` (concatenation eq. `parser.parse('-(2&5)');` will return `-25`);
47
- * All excel formulas defined in [formula.js](https://github.com/handsontable/formula.js);
48
- * Relative and absolute cell coordinates like `A1`, `$A1`, `A$1`, `$A$1`;
49
- * Build-in variables like `TRUE`, `FALSE`, `NULL`
50
- * Custom variables;
51
- * Custom functions/formulas;
52
- * Node and Browser environment.
53
-
54
- ## API (methods)
55
-
56
- ```js
57
- var parser = new formulaParser.Parser();
58
- ```
59
-
60
- ### .parse(expression)
61
-
62
- Parses and evaluates provided expression. It always returns an object with `result` and `error` properties. `result` property
63
- always keep evaluated value. If error occurs `error` property will be set as:
64
- * `#ERROR!` General error;
65
- * `#DIV/0!` Divide by zero error;
66
- * `#NAME?` Not recognised function name or variable name;
67
- * `#N/A` Indicates that a value is not available to a formula;
68
- * `#NUM!` Occurs when formula encounters an invalid number;
69
- * `#VALUE!` Occurs when one of formula arguments is of the wrong type.
70
-
71
- ```js
72
- parser.parse('(1 + 5 + (5 * 10)) / 10'); // returns `Object {error: null, result: 5.6}`
73
- parser.parse('SUM(MY_VAR)'); // returns `Object {error: "#NAME?", result: null}`
74
- parser.parse('1;;1'); // returns `Object {error: "#ERROR!", result: null}`
75
- ```
76
-
77
- ### .setVariable(name, value)
78
-
79
- Set predefined variable name which can be visible while parsing formula expression.
80
-
81
- ```js
82
- parser.setVariable('MY_VARIABLE', 5);
83
- parser.setVariable('fooBar', 10);
84
-
85
- parser.parse('(1 + MY_VARIABLE + (5 * fooBar)) / fooBar'); // returns `5.6`
86
- ```
87
-
88
- ### .getVariable(name)
89
-
90
- Get variable name.
91
-
92
- ```js
93
- parser.setVariable('fooBar', 10);
94
-
95
- parser.getVariable('fooBar'); // returns `10`
96
- ```
97
-
98
- ### .setFunction(name, fn)
99
-
100
- Set custom function which can be visible while parsing formula expression.
101
-
102
- ```js
103
- parser.setFunction('ADD_5', function(params) {
104
- return params[0] + 5;
105
- });
106
- parser.setFunction('GET_LETTER', function(params) {
107
- var string = params[0];
108
- var index = params[1] - 1;
109
-
110
- return string.charAt(index);
111
- });
112
-
113
- parser.parse('SUM(4, ADD_5(1))'); // returns `10`
114
- parser.parse('GET_LETTER("Some string", 3)'); // returns `m`
115
- ```
116
-
117
- ### .getFunction(name)
118
-
119
- Get custom function.
120
-
121
- ```js
122
- parser.setFunction('ADD_5', function(params) {
123
- return params[0] + 5;
124
- });
125
-
126
- parser.getFunction('ADD_5')([1]); // returns `6`
127
- ```
128
-
129
- ### .SUPPORTED_FORMULAS
130
-
131
- List of all supported formulas function.
132
-
133
- ```js
134
- require('hot-formula-parser').SUPPORTED_FORMULAS; // An array of formula names
135
- ```
136
-
137
- ## API (hooks)
138
-
139
- ### 'callVariable' (name, done)
140
-
141
- Fired while retrieving variable. If variable was defined earlier using `setVariable` you can overwrite it by this hook.
142
-
143
- ```js
144
- parser.on('callVariable', function(name, done) {
145
- if (name === 'foo') {
146
- done(Math.PI / 2);
147
- }
148
- });
149
-
150
- parser.parse('SUM(SIN(foo), COS(foo))'); // returns `1`
151
- ```
152
-
153
- ### 'callFunction' (name, params, done)
154
-
155
- Fired while calling function. If function was defined earlier using `setFunction` you can overwrite it's result by this hook.
156
- You can also use this to override result of build-in formulas.
157
-
158
- ```js
159
- parser.on('callFunction', function(name, params, done) {
160
- if (name === 'ADD_5') {
161
- done(params[0] + 5);
162
- }
163
- });
164
-
165
- parser.parse('ADD_5(3)'); // returns `8`
166
- ```
167
-
168
- ### 'callCellValue' (cellCoord, done)
169
-
170
- Fired while retrieving cell value by its label (eq: `B3`, `B$3`, `B$3`, `$B$3`).
171
-
172
- ```js
173
- parser.on('callCellValue', function(cellCoord, done) {
174
- // using label
175
- if (cellCoord.label === 'B$6') {
176
- done('hello');
177
- }
178
- // or using indexes
179
- if (cellCoord.row.index === 5 && cellCoord.row.isAbsolute && cellCoord.column.index === 1 && !cellCoord.column.isAbsolute) {
180
- done('hello');
181
- }
182
-
183
- if (cellCoord.label === 'C6') {
184
- done(0.75);
185
- }
186
- });
187
-
188
- parser.parse('B$6'); // returns `"hello"`
189
- parser.parse('B$6&" world"'); // returns `"hello world"`
190
- parser.parse('FISHER(C6)'); // returns `0.9729550745276566`
191
- ```
192
-
193
- ### 'callRangeValue' (startCellCoord, endCellCoord, done)
194
-
195
- Fired while retrieving cells range value (eq: `A1:B3`, `$A1:B$3`, `A$1:B$3`, `$A$1:$B$3`).
196
-
197
- ```js
198
- parser.on('callRangeValue', function(startCellCoord, endCellCoord, done) {
199
- var data = [
200
- [1, 2, 3, 4, 5],
201
- [6, 7, 8, 9, 10],
202
- [11, 12, 13, 14, 15],
203
- [16, 17, 18, 19, 20],
204
- ];
205
- var fragment = [];
206
-
207
- for (var row = startCellCoord.row.index; row <= endCellCoord.row.index; row++) {
208
- var rowData = data[row];
209
- var colFragment = [];
210
-
211
- for (var col = startCellCoord.column.index; col <= endCellCoord.column.index; col++) {
212
- colFragment.push(rowData[col]);
213
- }
214
- fragment.push(colFragment);
215
- }
216
-
217
- if (fragment) {
218
- done(fragment);
219
- }
220
- });
221
-
222
- parser.parse('JOIN(A1:E2)'); // returns `"1,2,3,4,5,6,7,8,9,10"`
223
- parser.parse('COLUMNS(A1:E2)'); // returns `5`
224
- parser.parse('ROWS(A1:E2)'); // returns `2`
225
- parser.parse('COUNT(A1:E2)'); // returns `10`
226
- parser.parse('COUNTIF(A1:E2, ">5")'); // returns `5`
227
- ```
228
-
229
- ### Want to help?
230
-
231
- Please see [CONTRIBUTING.md](CONTRIBUTING.md).
232
-
233
- ### Changelog
234
-
235
- To see the list of recent changes, see [Releases section](https://github.com/handsontable/formula-parser/releases).
236
-
237
- ### License
238
-
239
- The MIT License (see the [LICENSE](https://github.com/handsontable/formula-parser/blob/master/LICENSE) file for the full text).
240
-
241
- ### Contact
242
-
243
- You can contact us at hello@handsontable.com.
244
-
245
- </details>
246
-
1
+ :warning: This repository is deprecated. We've released new and improved [HyperFormula](https://github.com/handsontable/hyperformula/) engine.
2
+
3
+
4
+ <details>
5
+
6
+ Formula Parser [![Build Status](https://travis-ci.org/handsontable/formula-parser.png?branch=master)](https://travis-ci.org/handsontable/formula-parser) [![Test Coverage](https://codeclimate.com/github/handsontable/formula-parser/badges/coverage.svg)](https://codeclimate.com/github/handsontable/formula-parser/coverage) [![hot-formula-parser](https://img.shields.io/npm/v/hot-formula-parser.svg)](https://www.npmjs.com/package/hot-formula-parser)
7
+ ==========
8
+ Library provides a `Parser` class that evaluates excel and mathematical formulas.
9
+
10
+ - - -
11
+
12
+ ## Install
13
+
14
+ A recommended way to install Formula Parser is through [NPM](https://www.npmjs.com/) using the following command:
15
+
16
+ ```sh
17
+ $ npm install hot-formula-parser --save
18
+ ```
19
+
20
+ Node.js:
21
+ ```js
22
+ var FormulaParser = require('hot-formula-parser').Parser;
23
+ var parser = new FormulaParser();
24
+
25
+ parser.parse('SUM(1, 6, 7)'); // It returns `Object {error: null, result: 14}`
26
+ ```
27
+
28
+ Browser:
29
+ ```html
30
+ <script src="/node_modules/hot-formula-parser/dist/formula-parser.min.js"></script>
31
+ <script>
32
+ var parser = new formulaParser.Parser();
33
+
34
+ parser.parse('SUM(1, 6, 7)'); // It returns `Object {error: null, result: 14}`
35
+ </script>
36
+ ```
37
+ ## Features
38
+
39
+ It supports:
40
+
41
+ * Any numbers, negative and positive as float or integer;
42
+ * Arithmetic operations like `+`, `-`, `/`, `*`, `%`, `^`;
43
+ * Logical operations like `AND()`, `OR()`, `NOT()`, `XOR()`;
44
+ * Comparison operations like `=`, `>`, `>=`, `<`, `<=`, `<>`;
45
+ * All JavaScript Math constants like `PI()`, `E()`, `LN10()`, `LN2()`, `LOG10E()`, `LOG2E()`, `SQRT1_2()`, `SQRT2()`;
46
+ * String operations like `&` (concatenation eq. `parser.parse('-(2&5)');` will return `-25`);
47
+ * All excel formulas defined in [formula.js](https://github.com/handsontable/formula.js);
48
+ * Relative and absolute cell coordinates like `A1`, `$A1`, `A$1`, `$A$1`;
49
+ * Build-in variables like `TRUE`, `FALSE`, `NULL`
50
+ * Custom variables;
51
+ * Custom functions/formulas;
52
+ * Node and Browser environment.
53
+
54
+ ## API (methods)
55
+
56
+ ```js
57
+ var parser = new formulaParser.Parser();
58
+ ```
59
+
60
+ ### .parse(expression)
61
+
62
+ Parses and evaluates provided expression. It always returns an object with `result` and `error` properties. `result` property
63
+ always keep evaluated value. If error occurs `error` property will be set as:
64
+ * `#ERROR!` General error;
65
+ * `#DIV/0!` Divide by zero error;
66
+ * `#NAME?` Not recognised function name or variable name;
67
+ * `#N/A` Indicates that a value is not available to a formula;
68
+ * `#NUM!` Occurs when formula encounters an invalid number;
69
+ * `#VALUE!` Occurs when one of formula arguments is of the wrong type.
70
+
71
+ ```js
72
+ parser.parse('(1 + 5 + (5 * 10)) / 10'); // returns `Object {error: null, result: 5.6}`
73
+ parser.parse('SUM(MY_VAR)'); // returns `Object {error: "#NAME?", result: null}`
74
+ parser.parse('1;;1'); // returns `Object {error: "#ERROR!", result: null}`
75
+ ```
76
+
77
+ ### .setVariable(name, value)
78
+
79
+ Set predefined variable name which can be visible while parsing formula expression.
80
+
81
+ ```js
82
+ parser.setVariable('MY_VARIABLE', 5);
83
+ parser.setVariable('fooBar', 10);
84
+
85
+ parser.parse('(1 + MY_VARIABLE + (5 * fooBar)) / fooBar'); // returns `5.6`
86
+ ```
87
+
88
+ ### .getVariable(name)
89
+
90
+ Get variable name.
91
+
92
+ ```js
93
+ parser.setVariable('fooBar', 10);
94
+
95
+ parser.getVariable('fooBar'); // returns `10`
96
+ ```
97
+
98
+ ### .setFunction(name, fn)
99
+
100
+ Set custom function which can be visible while parsing formula expression.
101
+
102
+ ```js
103
+ parser.setFunction('ADD_5', function(params) {
104
+ return params[0] + 5;
105
+ });
106
+ parser.setFunction('GET_LETTER', function(params) {
107
+ var string = params[0];
108
+ var index = params[1] - 1;
109
+
110
+ return string.charAt(index);
111
+ });
112
+
113
+ parser.parse('SUM(4, ADD_5(1))'); // returns `10`
114
+ parser.parse('GET_LETTER("Some string", 3)'); // returns `m`
115
+ ```
116
+
117
+ ### .getFunction(name)
118
+
119
+ Get custom function.
120
+
121
+ ```js
122
+ parser.setFunction('ADD_5', function(params) {
123
+ return params[0] + 5;
124
+ });
125
+
126
+ parser.getFunction('ADD_5')([1]); // returns `6`
127
+ ```
128
+
129
+ ### .SUPPORTED_FORMULAS
130
+
131
+ List of all supported formulas function.
132
+
133
+ ```js
134
+ require('hot-formula-parser').SUPPORTED_FORMULAS; // An array of formula names
135
+ ```
136
+
137
+ ## API (hooks)
138
+
139
+ ### 'callVariable' (name, done)
140
+
141
+ Fired while retrieving variable. If variable was defined earlier using `setVariable` you can overwrite it by this hook.
142
+
143
+ ```js
144
+ parser.on('callVariable', function(name, done) {
145
+ if (name === 'foo') {
146
+ done(Math.PI / 2);
147
+ }
148
+ });
149
+
150
+ parser.parse('SUM(SIN(foo), COS(foo))'); // returns `1`
151
+ ```
152
+
153
+ ### 'callFunction' (name, params, done)
154
+
155
+ Fired while calling function. If function was defined earlier using `setFunction` you can overwrite it's result by this hook.
156
+ You can also use this to override result of build-in formulas.
157
+
158
+ ```js
159
+ parser.on('callFunction', function(name, params, done) {
160
+ if (name === 'ADD_5') {
161
+ done(params[0] + 5);
162
+ }
163
+ });
164
+
165
+ parser.parse('ADD_5(3)'); // returns `8`
166
+ ```
167
+
168
+ ### 'callCellValue' (cellCoord, done)
169
+
170
+ Fired while retrieving cell value by its label (eq: `B3`, `B$3`, `B$3`, `$B$3`).
171
+
172
+ ```js
173
+ parser.on('callCellValue', function(cellCoord, done) {
174
+ // using label
175
+ if (cellCoord.label === 'B$6') {
176
+ done('hello');
177
+ }
178
+ // or using indexes
179
+ if (cellCoord.row.index === 5 && cellCoord.row.isAbsolute && cellCoord.column.index === 1 && !cellCoord.column.isAbsolute) {
180
+ done('hello');
181
+ }
182
+
183
+ if (cellCoord.label === 'C6') {
184
+ done(0.75);
185
+ }
186
+ });
187
+
188
+ parser.parse('B$6'); // returns `"hello"`
189
+ parser.parse('B$6&" world"'); // returns `"hello world"`
190
+ parser.parse('FISHER(C6)'); // returns `0.9729550745276566`
191
+ ```
192
+
193
+ ### 'callRangeValue' (startCellCoord, endCellCoord, done)
194
+
195
+ Fired while retrieving cells range value (eq: `A1:B3`, `$A1:B$3`, `A$1:B$3`, `$A$1:$B$3`).
196
+
197
+ ```js
198
+ parser.on('callRangeValue', function(startCellCoord, endCellCoord, done) {
199
+ var data = [
200
+ [1, 2, 3, 4, 5],
201
+ [6, 7, 8, 9, 10],
202
+ [11, 12, 13, 14, 15],
203
+ [16, 17, 18, 19, 20],
204
+ ];
205
+ var fragment = [];
206
+
207
+ for (var row = startCellCoord.row.index; row <= endCellCoord.row.index; row++) {
208
+ var rowData = data[row];
209
+ var colFragment = [];
210
+
211
+ for (var col = startCellCoord.column.index; col <= endCellCoord.column.index; col++) {
212
+ colFragment.push(rowData[col]);
213
+ }
214
+ fragment.push(colFragment);
215
+ }
216
+
217
+ if (fragment) {
218
+ done(fragment);
219
+ }
220
+ });
221
+
222
+ parser.parse('JOIN(A1:E2)'); // returns `"1,2,3,4,5,6,7,8,9,10"`
223
+ parser.parse('COLUMNS(A1:E2)'); // returns `5`
224
+ parser.parse('ROWS(A1:E2)'); // returns `2`
225
+ parser.parse('COUNT(A1:E2)'); // returns `10`
226
+ parser.parse('COUNTIF(A1:E2, ">5")'); // returns `5`
227
+ ```
228
+
229
+ ### Want to help?
230
+
231
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md).
232
+
233
+ ### Changelog
234
+
235
+ To see the list of recent changes, see [Releases section](https://github.com/handsontable/formula-parser/releases).
236
+
237
+ ### License
238
+
239
+ The MIT License (see the [LICENSE](https://github.com/handsontable/formula-parser/blob/master/LICENSE) file for the full text).
240
+
241
+ ### Contact
242
+
243
+ You can contact us at hello@handsontable.com.
244
+
245
+ </details>
246
+
package/dist/index.esm.js CHANGED
@@ -167,11 +167,11 @@ function _nonIterableRest() {
167
167
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
168
168
  }
169
169
 
170
- /**
171
- * Convert value into number.
172
- *
173
- * @param {String|Number} number
174
- * @returns {*}
170
+ /**
171
+ * Convert value into number.
172
+ *
173
+ * @param {String|Number} number
174
+ * @returns {*}
175
175
  */
176
176
  function toNumber(number) {
177
177
  var result;
@@ -183,11 +183,11 @@ function toNumber(number) {
183
183
  return result;
184
184
  }
185
185
 
186
- /**
187
- * Invert provided number.
188
- *
189
- * @param {Number} number
190
- * @returns {Number} Returns inverted number.
186
+ /**
187
+ * Invert provided number.
188
+ *
189
+ * @param {Number} number
190
+ * @returns {Number} Returns inverted number.
191
191
  */
192
192
  function invertNumber(number) {
193
193
  return -1 * toNumber(number);
@@ -203,11 +203,11 @@ var ERROR_REF = 'REF';
203
203
  var ERROR_VALUE = 'VALUE';
204
204
  var errors = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ERROR, '#ERROR!'), ERROR_DIV_ZERO, '#DIV/0!'), ERROR_NAME, '#NAME?'), ERROR_NOT_AVAILABLE, '#N/A'), ERROR_NULL, '#NULL!'), ERROR_NUM, '#NUM!'), ERROR_REF, '#REF!'), ERROR_VALUE, '#VALUE!');
205
205
 
206
- /**
207
- * Return error type based on provided error id.
208
- *
209
- * @param {String} type Error type.
210
- * @returns {String|null} Returns error id.
206
+ /**
207
+ * Return error type based on provided error id.
208
+ *
209
+ * @param {String} type Error type.
210
+ * @returns {String|null} Returns error id.
211
211
  */
212
212
  function error(type) {
213
213
  var result;
@@ -218,11 +218,11 @@ function error(type) {
218
218
  return result ? result : null;
219
219
  }
220
220
 
221
- /**
222
- * Check if error type is strict valid with knows errors.
223
- *
224
- * @param {String} Error type.
225
- * @return {Boolean}
221
+ /**
222
+ * Check if error type is strict valid with knows errors.
223
+ *
224
+ * @param {String} Error type.
225
+ * @return {Boolean}
226
226
  */
227
227
  function isValidStrict(type) {
228
228
  var valid = false;
@@ -399,12 +399,12 @@ func$c.SYMBOL = SYMBOL$c;
399
399
 
400
400
  var availableOperators = Object.create(null);
401
401
 
402
- /**
403
- * Evaluate values by operator id.git
404
- *
405
- * @param {String} operator Operator id.
406
- * @param {Array} [params=[]] Arguments to evaluate.
407
- * @returns {*}
402
+ /**
403
+ * Evaluate values by operator id.git
404
+ *
405
+ * @param {String} operator Operator id.
406
+ * @param {Array} [params=[]] Arguments to evaluate.
407
+ * @returns {*}
408
408
  */
409
409
  function evaluateByOperator(operator) {
410
410
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -415,11 +415,11 @@ function evaluateByOperator(operator) {
415
415
  return availableOperators[operator].apply(availableOperators, _toConsumableArray(params));
416
416
  }
417
417
 
418
- /**
419
- * Register operator.
420
- *
421
- * @param {String|Array} symbol Symbol to register.
422
- * @param {Function} func Logic to register for this symbol.
418
+ /**
419
+ * Register operator.
420
+ *
421
+ * @param {String|Array} symbol Symbol to register.
422
+ * @param {Function} func Logic to register for this symbol.
423
423
  */
424
424
  function registerOperation(symbol, func) {
425
425
  if (!Array.isArray(symbol)) {
@@ -1855,12 +1855,12 @@ Parser.prototype = parser;
1855
1855
  parser.Parser = Parser;
1856
1856
 
1857
1857
  /* eslint-disable import/prefer-default-export */
1858
- /**
1859
- * Trim value by cutting character starting from the beginning and ending at the same time.
1860
- *
1861
- * @param {String} string String to trimming.
1862
- * @param {Number} [margin=1] Number of character to cut.
1863
- * @returns {String}
1858
+ /**
1859
+ * Trim value by cutting character starting from the beginning and ending at the same time.
1860
+ *
1861
+ * @param {String} string String to trimming.
1862
+ * @param {Number} [margin=1] Number of character to cut.
1863
+ * @returns {String}
1864
1864
  */
1865
1865
  function trimEdges(string) {
1866
1866
  var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
@@ -1868,11 +1868,11 @@ function trimEdges(string) {
1868
1868
  return string;
1869
1869
  }
1870
1870
 
1871
- /**
1872
- * Convert row label to index.
1873
- *
1874
- * @param {String} label Row label (eq. '1', '5')
1875
- * @returns {Number} Returns -1 if label is not recognized otherwise proper row index.
1871
+ /**
1872
+ * Convert row label to index.
1873
+ *
1874
+ * @param {String} label Row label (eq. '1', '5')
1875
+ * @returns {Number} Returns -1 if label is not recognized otherwise proper row index.
1876
1876
  */
1877
1877
  function rowLabelToIndex(label) {
1878
1878
  var result = parseInt(label, 10);
@@ -1884,11 +1884,11 @@ function rowLabelToIndex(label) {
1884
1884
  return result;
1885
1885
  }
1886
1886
 
1887
- /**
1888
- * Convert row index to label.
1889
- *
1890
- * @param {Number} row Row index.
1891
- * @returns {String} Returns row label (eq. '1', '7').
1887
+ /**
1888
+ * Convert row index to label.
1889
+ *
1890
+ * @param {Number} row Row index.
1891
+ * @returns {String} Returns row label (eq. '1', '7').
1892
1892
  */
1893
1893
  function rowIndexToLabel(row) {
1894
1894
  var result = "";
@@ -1900,11 +1900,11 @@ function rowIndexToLabel(row) {
1900
1900
  var COLUMN_LABEL_BASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1901
1901
  var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
1902
1902
 
1903
- /**
1904
- * Convert column label to index.
1905
- *
1906
- * @param {String} label Column label (eq. 'ABB', 'CNQ')
1907
- * @returns {Number} Returns -1 if label is not recognized otherwise proper column index.
1903
+ /**
1904
+ * Convert column label to index.
1905
+ *
1906
+ * @param {String} label Column label (eq. 'ABB', 'CNQ')
1907
+ * @returns {Number} Returns -1 if label is not recognized otherwise proper column index.
1908
1908
  */
1909
1909
  function columnLabelToIndex(label) {
1910
1910
  var result = 0;
@@ -1918,11 +1918,11 @@ function columnLabelToIndex(label) {
1918
1918
  return result;
1919
1919
  }
1920
1920
 
1921
- /**
1922
- * Convert column index to label.
1923
- *
1924
- * @param {Number} column Column index.
1925
- * @returns {String} Returns column label (eq. 'ABB', 'CNQ').
1921
+ /**
1922
+ * Convert column index to label.
1923
+ *
1924
+ * @param {Number} column Column index.
1925
+ * @returns {String} Returns column label (eq. 'ABB', 'CNQ').
1926
1926
  */
1927
1927
  function columnIndexToLabel(column) {
1928
1928
  var result = "";
@@ -1937,11 +1937,11 @@ var quotedSheetName$1 = "'(?:(?!').|'')*'";
1937
1937
  var sheetNameRegexp$1 = "(".concat(simpleSheetName$1, "|").concat(quotedSheetName$1, ")!");
1938
1938
  var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?([A-Za-z]*)([$])?([0-9]*)$"));
1939
1939
 
1940
- /**
1941
- * Extract cell coordinates.
1942
- *
1943
- * @param {String} label Cell coordinates (eq. 'A1', '$B6', '$N$98').
1944
- * @returns {Array} Returns an array of objects.
1940
+ /**
1941
+ * Extract cell coordinates.
1942
+ *
1943
+ * @param {String} label Cell coordinates (eq. 'A1', '$B6', '$N$98').
1944
+ * @returns {Array} Returns an array of objects.
1945
1945
  */
1946
1946
  function extractLabel(label) {
1947
1947
  if (typeof label !== "string" || !LABEL_EXTRACT_REGEXP.test(label)) {
@@ -1967,12 +1967,12 @@ function extractLabel(label) {
1967
1967
  }, sheetName];
1968
1968
  }
1969
1969
 
1970
- /**
1971
- * Convert row and column indexes into cell label.
1972
- *
1973
- * @param {Object} row Object with `index` and `isAbsolute` properties.
1974
- * @param {Object} column Object with `index` and `isAbsolute` properties.
1975
- * @returns {String} Returns cell label.
1970
+ /**
1971
+ * Convert row and column indexes into cell label.
1972
+ *
1973
+ * @param {Object} row Object with `index` and `isAbsolute` properties.
1974
+ * @param {Object} column Object with `index` and `isAbsolute` properties.
1975
+ * @returns {String} Returns cell label.
1976
1976
  */
1977
1977
  function toLabel(row, column) {
1978
1978
  var rowLabel = (row.isAbsolute ? "$" : "") + rowIndexToLabel(row.index);
@@ -1980,8 +1980,8 @@ function toLabel(row, column) {
1980
1980
  return columnLabel + rowLabel;
1981
1981
  }
1982
1982
 
1983
- /**
1984
- * @class Parser
1983
+ /**
1984
+ * @class Parser
1985
1985
  */
1986
1986
  var Parser$1 = /*#__PURE__*/function (_Emitter) {
1987
1987
  function Parser$1() {
@@ -2017,13 +2017,13 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2017
2017
  return _this;
2018
2018
  }
2019
2019
 
2020
- /**
2021
- * Parse formula expression.
2022
- *
2023
- * @param {string} expression to parse.
2024
- * @param {object} options additional params.
2025
- * @param {string} options.sheetId id of sheet which the formula expression belongs to.
2026
- * @return {*} Returns an object with tow properties `error` and `result`.
2020
+ /**
2021
+ * Parse formula expression.
2022
+ *
2023
+ * @param {string} expression to parse.
2024
+ * @param {object} options additional params.
2025
+ * @param {string} options.sheetId id of sheet which the formula expression belongs to.
2026
+ * @return {*} Returns an object with tow properties `error` and `result`.
2027
2027
  */
2028
2028
  _inherits(Parser$1, _Emitter);
2029
2029
  return _createClass(Parser$1, [{
@@ -2056,12 +2056,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2056
2056
  };
2057
2057
  }
2058
2058
 
2059
- /**
2060
- * Set predefined variable name which can be visible while parsing formula expression.
2061
- *
2062
- * @param {String} name Variable name.
2063
- * @param {*} value Variable value.
2064
- * @returns {Parser}
2059
+ /**
2060
+ * Set predefined variable name which can be visible while parsing formula expression.
2061
+ *
2062
+ * @param {String} name Variable name.
2063
+ * @param {*} value Variable value.
2064
+ * @returns {Parser}
2065
2065
  */
2066
2066
  }, {
2067
2067
  key: "setVariable",
@@ -2074,11 +2074,11 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2074
2074
  value: function replaceVariables(variables) {
2075
2075
  this.variables = variables;
2076
2076
  }
2077
- /**
2078
- * Get variable name.
2079
- *
2080
- * @param {String} name Variable name.
2081
- * @returns {*}
2077
+ /**
2078
+ * Get variable name.
2079
+ *
2080
+ * @param {String} name Variable name.
2081
+ * @returns {*}
2082
2082
  */
2083
2083
  }, {
2084
2084
  key: "getVariable",
@@ -2086,12 +2086,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2086
2086
  return this.variables[name];
2087
2087
  }
2088
2088
 
2089
- /**
2090
- * Retrieve variable value by its name.
2091
- *
2092
- * @param name Variable name.
2093
- * @returns {*}
2094
- * @private
2089
+ /**
2090
+ * Retrieve variable value by its name.
2091
+ *
2092
+ * @param name Variable name.
2093
+ * @returns {*}
2094
+ * @private
2095
2095
  */
2096
2096
  }, {
2097
2097
  key: "_callVariable",
@@ -2108,12 +2108,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2108
2108
  return value;
2109
2109
  }
2110
2110
 
2111
- /**
2112
- * Set custom function which can be visible while parsing formula expression.
2113
- *
2114
- * @param {String} name Custom function name.
2115
- * @param {Function} fn Custom function.
2116
- * @returns {Parser}
2111
+ /**
2112
+ * Set custom function which can be visible while parsing formula expression.
2113
+ *
2114
+ * @param {String} name Custom function name.
2115
+ * @param {Function} fn Custom function.
2116
+ * @returns {Parser}
2117
2117
  */
2118
2118
  }, {
2119
2119
  key: "setFunction",
@@ -2122,11 +2122,11 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2122
2122
  return this;
2123
2123
  }
2124
2124
 
2125
- /**
2126
- * Get custom function.
2127
- *
2128
- * @param {String} name Custom function name.
2129
- * @returns {*}
2125
+ /**
2126
+ * Get custom function.
2127
+ *
2128
+ * @param {String} name Custom function name.
2129
+ * @returns {*}
2130
2130
  */
2131
2131
  }, {
2132
2132
  key: "getFunction",
@@ -2134,13 +2134,13 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2134
2134
  return this.functions[name];
2135
2135
  }
2136
2136
 
2137
- /**
2138
- * Call function with provided params.
2139
- *
2140
- * @param name Function name.
2141
- * @param params Function params.
2142
- * @returns {*}
2143
- * @private
2137
+ /**
2138
+ * Call function with provided params.
2139
+ *
2140
+ * @param name Function name.
2141
+ * @param params Function params.
2142
+ * @returns {*}
2143
+ * @private
2144
2144
  */
2145
2145
  }, {
2146
2146
  key: "_callFunction",
@@ -2159,16 +2159,17 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2159
2159
  return value === void 0 ? evaluateByOperator(name, params) : value;
2160
2160
  }
2161
2161
 
2162
- /**
2163
- * Retrieve value by its label (`B3`, `B$3`, `B$3`, `$B$3`).
2164
- *
2165
- * @param {String} label Coordinates.
2166
- * @returns {*}
2167
- * @private
2162
+ /**
2163
+ * Retrieve value by its label (`B3`, `B$3`, `B$3`, `$B$3`).
2164
+ *
2165
+ * @param {String} label Coordinates.
2166
+ * @returns {*}
2167
+ * @private
2168
2168
  */
2169
2169
  }, {
2170
2170
  key: "_callCellValue",
2171
2171
  value: function _callCellValue(label) {
2172
+ var _value2;
2172
2173
  var _extractLabel = extractLabel(label),
2173
2174
  _extractLabel2 = _slicedToArray(_extractLabel, 3),
2174
2175
  row = _extractLabel2[0],
@@ -2191,16 +2192,16 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2191
2192
  }, this.options, function (_value) {
2192
2193
  value = _value;
2193
2194
  });
2194
- return value;
2195
+ return (_value2 = value) !== null && _value2 !== void 0 ? _value2 : 0;
2195
2196
  }
2196
2197
 
2197
- /**
2198
- * Retrieve value by its label (`B3:A1`, `B$3:A1`, `B$3:$A1`, `$B$3:A$1`).
2199
- *
2200
- * @param {String} startLabel Coordinates of the first cell.
2201
- * @param {String} endLabel Coordinates of the last cell.
2202
- * @returns {Array} Returns an array of mixed values.
2203
- * @private
2198
+ /**
2199
+ * Retrieve value by its label (`B3:A1`, `B$3:A1`, `B$3:$A1`, `$B$3:A$1`).
2200
+ *
2201
+ * @param {String} startLabel Coordinates of the first cell.
2202
+ * @param {String} endLabel Coordinates of the last cell.
2203
+ * @returns {Array} Returns an array of mixed values.
2204
+ * @private
2204
2205
  */
2205
2206
  }, {
2206
2207
  key: "_callRangeValue",
@@ -2245,12 +2246,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2245
2246
  return value;
2246
2247
  }
2247
2248
 
2248
- /**
2249
- * Try to throw error by its name.
2250
- *
2251
- * @param {String} errorName Error name.
2252
- * @returns {String}
2253
- * @private
2249
+ /**
2250
+ * Try to throw error by its name.
2251
+ *
2252
+ * @param {String} errorName Error name.
2253
+ * @returns {String}
2254
+ * @private
2254
2255
  */
2255
2256
  }, {
2256
2257
  key: "_throwError",
package/dist/index.js CHANGED
@@ -196,11 +196,11 @@ function _nonIterableRest() {
196
196
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
197
197
  }
198
198
 
199
- /**
200
- * Convert value into number.
201
- *
202
- * @param {String|Number} number
203
- * @returns {*}
199
+ /**
200
+ * Convert value into number.
201
+ *
202
+ * @param {String|Number} number
203
+ * @returns {*}
204
204
  */
205
205
  function toNumber(number) {
206
206
  var result;
@@ -212,11 +212,11 @@ function toNumber(number) {
212
212
  return result;
213
213
  }
214
214
 
215
- /**
216
- * Invert provided number.
217
- *
218
- * @param {Number} number
219
- * @returns {Number} Returns inverted number.
215
+ /**
216
+ * Invert provided number.
217
+ *
218
+ * @param {Number} number
219
+ * @returns {Number} Returns inverted number.
220
220
  */
221
221
  function invertNumber(number) {
222
222
  return -1 * toNumber(number);
@@ -232,11 +232,11 @@ var ERROR_REF = 'REF';
232
232
  var ERROR_VALUE = 'VALUE';
233
233
  var errors = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ERROR, '#ERROR!'), ERROR_DIV_ZERO, '#DIV/0!'), ERROR_NAME, '#NAME?'), ERROR_NOT_AVAILABLE, '#N/A'), ERROR_NULL, '#NULL!'), ERROR_NUM, '#NUM!'), ERROR_REF, '#REF!'), ERROR_VALUE, '#VALUE!');
234
234
 
235
- /**
236
- * Return error type based on provided error id.
237
- *
238
- * @param {String} type Error type.
239
- * @returns {String|null} Returns error id.
235
+ /**
236
+ * Return error type based on provided error id.
237
+ *
238
+ * @param {String} type Error type.
239
+ * @returns {String|null} Returns error id.
240
240
  */
241
241
  function error(type) {
242
242
  var result;
@@ -247,11 +247,11 @@ function error(type) {
247
247
  return result ? result : null;
248
248
  }
249
249
 
250
- /**
251
- * Check if error type is strict valid with knows errors.
252
- *
253
- * @param {String} Error type.
254
- * @return {Boolean}
250
+ /**
251
+ * Check if error type is strict valid with knows errors.
252
+ *
253
+ * @param {String} Error type.
254
+ * @return {Boolean}
255
255
  */
256
256
  function isValidStrict(type) {
257
257
  var valid = false;
@@ -428,12 +428,12 @@ func$c.SYMBOL = SYMBOL$c;
428
428
 
429
429
  var availableOperators = Object.create(null);
430
430
 
431
- /**
432
- * Evaluate values by operator id.git
433
- *
434
- * @param {String} operator Operator id.
435
- * @param {Array} [params=[]] Arguments to evaluate.
436
- * @returns {*}
431
+ /**
432
+ * Evaluate values by operator id.git
433
+ *
434
+ * @param {String} operator Operator id.
435
+ * @param {Array} [params=[]] Arguments to evaluate.
436
+ * @returns {*}
437
437
  */
438
438
  function evaluateByOperator(operator) {
439
439
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -444,11 +444,11 @@ function evaluateByOperator(operator) {
444
444
  return availableOperators[operator].apply(availableOperators, _toConsumableArray(params));
445
445
  }
446
446
 
447
- /**
448
- * Register operator.
449
- *
450
- * @param {String|Array} symbol Symbol to register.
451
- * @param {Function} func Logic to register for this symbol.
447
+ /**
448
+ * Register operator.
449
+ *
450
+ * @param {String|Array} symbol Symbol to register.
451
+ * @param {Function} func Logic to register for this symbol.
452
452
  */
453
453
  function registerOperation(symbol, func) {
454
454
  if (!Array.isArray(symbol)) {
@@ -1884,12 +1884,12 @@ Parser.prototype = parser;
1884
1884
  parser.Parser = Parser;
1885
1885
 
1886
1886
  /* eslint-disable import/prefer-default-export */
1887
- /**
1888
- * Trim value by cutting character starting from the beginning and ending at the same time.
1889
- *
1890
- * @param {String} string String to trimming.
1891
- * @param {Number} [margin=1] Number of character to cut.
1892
- * @returns {String}
1887
+ /**
1888
+ * Trim value by cutting character starting from the beginning and ending at the same time.
1889
+ *
1890
+ * @param {String} string String to trimming.
1891
+ * @param {Number} [margin=1] Number of character to cut.
1892
+ * @returns {String}
1893
1893
  */
1894
1894
  function trimEdges(string) {
1895
1895
  var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
@@ -1897,11 +1897,11 @@ function trimEdges(string) {
1897
1897
  return string;
1898
1898
  }
1899
1899
 
1900
- /**
1901
- * Convert row label to index.
1902
- *
1903
- * @param {String} label Row label (eq. '1', '5')
1904
- * @returns {Number} Returns -1 if label is not recognized otherwise proper row index.
1900
+ /**
1901
+ * Convert row label to index.
1902
+ *
1903
+ * @param {String} label Row label (eq. '1', '5')
1904
+ * @returns {Number} Returns -1 if label is not recognized otherwise proper row index.
1905
1905
  */
1906
1906
  function rowLabelToIndex(label) {
1907
1907
  var result = parseInt(label, 10);
@@ -1913,11 +1913,11 @@ function rowLabelToIndex(label) {
1913
1913
  return result;
1914
1914
  }
1915
1915
 
1916
- /**
1917
- * Convert row index to label.
1918
- *
1919
- * @param {Number} row Row index.
1920
- * @returns {String} Returns row label (eq. '1', '7').
1916
+ /**
1917
+ * Convert row index to label.
1918
+ *
1919
+ * @param {Number} row Row index.
1920
+ * @returns {String} Returns row label (eq. '1', '7').
1921
1921
  */
1922
1922
  function rowIndexToLabel(row) {
1923
1923
  var result = "";
@@ -1929,11 +1929,11 @@ function rowIndexToLabel(row) {
1929
1929
  var COLUMN_LABEL_BASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1930
1930
  var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
1931
1931
 
1932
- /**
1933
- * Convert column label to index.
1934
- *
1935
- * @param {String} label Column label (eq. 'ABB', 'CNQ')
1936
- * @returns {Number} Returns -1 if label is not recognized otherwise proper column index.
1932
+ /**
1933
+ * Convert column label to index.
1934
+ *
1935
+ * @param {String} label Column label (eq. 'ABB', 'CNQ')
1936
+ * @returns {Number} Returns -1 if label is not recognized otherwise proper column index.
1937
1937
  */
1938
1938
  function columnLabelToIndex(label) {
1939
1939
  var result = 0;
@@ -1947,11 +1947,11 @@ function columnLabelToIndex(label) {
1947
1947
  return result;
1948
1948
  }
1949
1949
 
1950
- /**
1951
- * Convert column index to label.
1952
- *
1953
- * @param {Number} column Column index.
1954
- * @returns {String} Returns column label (eq. 'ABB', 'CNQ').
1950
+ /**
1951
+ * Convert column index to label.
1952
+ *
1953
+ * @param {Number} column Column index.
1954
+ * @returns {String} Returns column label (eq. 'ABB', 'CNQ').
1955
1955
  */
1956
1956
  function columnIndexToLabel(column) {
1957
1957
  var result = "";
@@ -1966,11 +1966,11 @@ var quotedSheetName$1 = "'(?:(?!').|'')*'";
1966
1966
  var sheetNameRegexp$1 = "(".concat(simpleSheetName$1, "|").concat(quotedSheetName$1, ")!");
1967
1967
  var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?([A-Za-z]*)([$])?([0-9]*)$"));
1968
1968
 
1969
- /**
1970
- * Extract cell coordinates.
1971
- *
1972
- * @param {String} label Cell coordinates (eq. 'A1', '$B6', '$N$98').
1973
- * @returns {Array} Returns an array of objects.
1969
+ /**
1970
+ * Extract cell coordinates.
1971
+ *
1972
+ * @param {String} label Cell coordinates (eq. 'A1', '$B6', '$N$98').
1973
+ * @returns {Array} Returns an array of objects.
1974
1974
  */
1975
1975
  function extractLabel(label) {
1976
1976
  if (typeof label !== "string" || !LABEL_EXTRACT_REGEXP.test(label)) {
@@ -1996,12 +1996,12 @@ function extractLabel(label) {
1996
1996
  }, sheetName];
1997
1997
  }
1998
1998
 
1999
- /**
2000
- * Convert row and column indexes into cell label.
2001
- *
2002
- * @param {Object} row Object with `index` and `isAbsolute` properties.
2003
- * @param {Object} column Object with `index` and `isAbsolute` properties.
2004
- * @returns {String} Returns cell label.
1999
+ /**
2000
+ * Convert row and column indexes into cell label.
2001
+ *
2002
+ * @param {Object} row Object with `index` and `isAbsolute` properties.
2003
+ * @param {Object} column Object with `index` and `isAbsolute` properties.
2004
+ * @returns {String} Returns cell label.
2005
2005
  */
2006
2006
  function toLabel(row, column) {
2007
2007
  var rowLabel = (row.isAbsolute ? "$" : "") + rowIndexToLabel(row.index);
@@ -2009,8 +2009,8 @@ function toLabel(row, column) {
2009
2009
  return columnLabel + rowLabel;
2010
2010
  }
2011
2011
 
2012
- /**
2013
- * @class Parser
2012
+ /**
2013
+ * @class Parser
2014
2014
  */
2015
2015
  var Parser$1 = /*#__PURE__*/function (_Emitter) {
2016
2016
  function Parser$1() {
@@ -2046,13 +2046,13 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2046
2046
  return _this;
2047
2047
  }
2048
2048
 
2049
- /**
2050
- * Parse formula expression.
2051
- *
2052
- * @param {string} expression to parse.
2053
- * @param {object} options additional params.
2054
- * @param {string} options.sheetId id of sheet which the formula expression belongs to.
2055
- * @return {*} Returns an object with tow properties `error` and `result`.
2049
+ /**
2050
+ * Parse formula expression.
2051
+ *
2052
+ * @param {string} expression to parse.
2053
+ * @param {object} options additional params.
2054
+ * @param {string} options.sheetId id of sheet which the formula expression belongs to.
2055
+ * @return {*} Returns an object with tow properties `error` and `result`.
2056
2056
  */
2057
2057
  _inherits(Parser$1, _Emitter);
2058
2058
  return _createClass(Parser$1, [{
@@ -2085,12 +2085,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2085
2085
  };
2086
2086
  }
2087
2087
 
2088
- /**
2089
- * Set predefined variable name which can be visible while parsing formula expression.
2090
- *
2091
- * @param {String} name Variable name.
2092
- * @param {*} value Variable value.
2093
- * @returns {Parser}
2088
+ /**
2089
+ * Set predefined variable name which can be visible while parsing formula expression.
2090
+ *
2091
+ * @param {String} name Variable name.
2092
+ * @param {*} value Variable value.
2093
+ * @returns {Parser}
2094
2094
  */
2095
2095
  }, {
2096
2096
  key: "setVariable",
@@ -2103,11 +2103,11 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2103
2103
  value: function replaceVariables(variables) {
2104
2104
  this.variables = variables;
2105
2105
  }
2106
- /**
2107
- * Get variable name.
2108
- *
2109
- * @param {String} name Variable name.
2110
- * @returns {*}
2106
+ /**
2107
+ * Get variable name.
2108
+ *
2109
+ * @param {String} name Variable name.
2110
+ * @returns {*}
2111
2111
  */
2112
2112
  }, {
2113
2113
  key: "getVariable",
@@ -2115,12 +2115,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2115
2115
  return this.variables[name];
2116
2116
  }
2117
2117
 
2118
- /**
2119
- * Retrieve variable value by its name.
2120
- *
2121
- * @param name Variable name.
2122
- * @returns {*}
2123
- * @private
2118
+ /**
2119
+ * Retrieve variable value by its name.
2120
+ *
2121
+ * @param name Variable name.
2122
+ * @returns {*}
2123
+ * @private
2124
2124
  */
2125
2125
  }, {
2126
2126
  key: "_callVariable",
@@ -2137,12 +2137,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2137
2137
  return value;
2138
2138
  }
2139
2139
 
2140
- /**
2141
- * Set custom function which can be visible while parsing formula expression.
2142
- *
2143
- * @param {String} name Custom function name.
2144
- * @param {Function} fn Custom function.
2145
- * @returns {Parser}
2140
+ /**
2141
+ * Set custom function which can be visible while parsing formula expression.
2142
+ *
2143
+ * @param {String} name Custom function name.
2144
+ * @param {Function} fn Custom function.
2145
+ * @returns {Parser}
2146
2146
  */
2147
2147
  }, {
2148
2148
  key: "setFunction",
@@ -2151,11 +2151,11 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2151
2151
  return this;
2152
2152
  }
2153
2153
 
2154
- /**
2155
- * Get custom function.
2156
- *
2157
- * @param {String} name Custom function name.
2158
- * @returns {*}
2154
+ /**
2155
+ * Get custom function.
2156
+ *
2157
+ * @param {String} name Custom function name.
2158
+ * @returns {*}
2159
2159
  */
2160
2160
  }, {
2161
2161
  key: "getFunction",
@@ -2163,13 +2163,13 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2163
2163
  return this.functions[name];
2164
2164
  }
2165
2165
 
2166
- /**
2167
- * Call function with provided params.
2168
- *
2169
- * @param name Function name.
2170
- * @param params Function params.
2171
- * @returns {*}
2172
- * @private
2166
+ /**
2167
+ * Call function with provided params.
2168
+ *
2169
+ * @param name Function name.
2170
+ * @param params Function params.
2171
+ * @returns {*}
2172
+ * @private
2173
2173
  */
2174
2174
  }, {
2175
2175
  key: "_callFunction",
@@ -2188,16 +2188,17 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2188
2188
  return value === void 0 ? evaluateByOperator(name, params) : value;
2189
2189
  }
2190
2190
 
2191
- /**
2192
- * Retrieve value by its label (`B3`, `B$3`, `B$3`, `$B$3`).
2193
- *
2194
- * @param {String} label Coordinates.
2195
- * @returns {*}
2196
- * @private
2191
+ /**
2192
+ * Retrieve value by its label (`B3`, `B$3`, `B$3`, `$B$3`).
2193
+ *
2194
+ * @param {String} label Coordinates.
2195
+ * @returns {*}
2196
+ * @private
2197
2197
  */
2198
2198
  }, {
2199
2199
  key: "_callCellValue",
2200
2200
  value: function _callCellValue(label) {
2201
+ var _value2;
2201
2202
  var _extractLabel = extractLabel(label),
2202
2203
  _extractLabel2 = _slicedToArray(_extractLabel, 3),
2203
2204
  row = _extractLabel2[0],
@@ -2220,16 +2221,16 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2220
2221
  }, this.options, function (_value) {
2221
2222
  value = _value;
2222
2223
  });
2223
- return value;
2224
+ return (_value2 = value) !== null && _value2 !== void 0 ? _value2 : 0;
2224
2225
  }
2225
2226
 
2226
- /**
2227
- * Retrieve value by its label (`B3:A1`, `B$3:A1`, `B$3:$A1`, `$B$3:A$1`).
2228
- *
2229
- * @param {String} startLabel Coordinates of the first cell.
2230
- * @param {String} endLabel Coordinates of the last cell.
2231
- * @returns {Array} Returns an array of mixed values.
2232
- * @private
2227
+ /**
2228
+ * Retrieve value by its label (`B3:A1`, `B$3:A1`, `B$3:$A1`, `$B$3:A$1`).
2229
+ *
2230
+ * @param {String} startLabel Coordinates of the first cell.
2231
+ * @param {String} endLabel Coordinates of the last cell.
2232
+ * @returns {Array} Returns an array of mixed values.
2233
+ * @private
2233
2234
  */
2234
2235
  }, {
2235
2236
  key: "_callRangeValue",
@@ -2274,12 +2275,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2274
2275
  return value;
2275
2276
  }
2276
2277
 
2277
- /**
2278
- * Try to throw error by its name.
2279
- *
2280
- * @param {String} errorName Error name.
2281
- * @returns {String}
2282
- * @private
2278
+ /**
2279
+ * Try to throw error by its name.
2280
+ *
2281
+ * @param {String} errorName Error name.
2282
+ * @returns {String}
2283
+ * @private
2283
2284
  */
2284
2285
  }, {
2285
2286
  key: "_throwError",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/formula-parser",
3
- "version": "4.0.17",
3
+ "version": "4.0.19",
4
4
  "description": "Formula parser",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",