@leankylin-sheet/formula-parser 4.0.56 → 4.0.58

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 +137 -137
  3. package/dist/index.js +137 -137
  4. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -197,11 +197,11 @@ function _nonIterableRest() {
197
197
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
198
198
  }
199
199
 
200
- /**
201
- * Convert value into number.
202
- *
203
- * @param {String|Number} number
204
- * @returns {*}
200
+ /**
201
+ * Convert value into number.
202
+ *
203
+ * @param {String|Number} number
204
+ * @returns {*}
205
205
  */
206
206
  function toNumber(number) {
207
207
  var _result;
@@ -217,11 +217,11 @@ function toNumber(number) {
217
217
  return (_result = result) !== null && _result !== void 0 ? _result : 0;
218
218
  }
219
219
 
220
- /**
221
- * Invert provided number.
222
- *
223
- * @param {Number} number
224
- * @returns {Number} Returns inverted number.
220
+ /**
221
+ * Invert provided number.
222
+ *
223
+ * @param {Number} number
224
+ * @returns {Number} Returns inverted number.
225
225
  */
226
226
  function invertNumber(number) {
227
227
  return -1 * toNumber(number);
@@ -254,11 +254,11 @@ var ERROR_VALUE = 'VALUE';
254
254
  var errors_formula_map = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ERROR, formulajs.utils.errors.error), ERROR_DIV_ZERO, formulajs.utils.errors.div0), ERROR_NAME, formulajs.utils.errors.name), ERROR_NOT_AVAILABLE, formulajs.utils.errors.na), ERROR_NULL, formulajs.utils.errors.nil), ERROR_NUM, formulajs.utils.errors.num), ERROR_REF, formulajs.utils.errors.ref), ERROR_VALUE, formulajs.utils.errors.value);
255
255
  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!');
256
256
 
257
- /**
258
- * Return error type based on provided error id.
259
- *
260
- * @param {String} type Error type.
261
- * @returns {String|null} Returns error id.
257
+ /**
258
+ * Return error type based on provided error id.
259
+ *
260
+ * @param {String} type Error type.
261
+ * @returns {String|null} Returns error id.
262
262
  */
263
263
  function error(type) {
264
264
  var result;
@@ -269,11 +269,11 @@ function error(type) {
269
269
  return result ? result : null;
270
270
  }
271
271
 
272
- /**
273
- * Check if error type is strict valid with knows errors.
274
- *
275
- * @param {String} Error type.
276
- * @return {Boolean}
272
+ /**
273
+ * Check if error type is strict valid with knows errors.
274
+ *
275
+ * @param {String} Error type.
276
+ * @return {Boolean}
277
277
  */
278
278
  function isValidStrict(type) {
279
279
  var valid = false;
@@ -492,12 +492,12 @@ function func$9(first) {
492
492
  }
493
493
  func$9.SYMBOL = SYMBOL$9;
494
494
 
495
- /**
496
- * 解决js处理精度问题
497
- * 0.3 * 0.1 = 0.03
498
- * @param num1
499
- * @param num2
500
- * @returns
495
+ /**
496
+ * 解决js处理精度问题
497
+ * 0.3 * 0.1 = 0.03
498
+ * @param num1
499
+ * @param num2
500
+ * @returns
501
501
  */
502
502
  var multiplyNumber = function multiplyNumber() {
503
503
  var num1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
@@ -566,12 +566,12 @@ func$c.SYMBOL = SYMBOL$c;
566
566
 
567
567
  var availableOperators = Object.create(null);
568
568
 
569
- /**
570
- * Evaluate values by operator id.git
571
- *
572
- * @param {String} operator Operator id.
573
- * @param {Array} [params=[]] Arguments to evaluate.
574
- * @returns {*}
569
+ /**
570
+ * Evaluate values by operator id.git
571
+ *
572
+ * @param {String} operator Operator id.
573
+ * @param {Array} [params=[]] Arguments to evaluate.
574
+ * @returns {*}
575
575
  */
576
576
  function evaluateByOperator(operator) {
577
577
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -582,11 +582,11 @@ function evaluateByOperator(operator) {
582
582
  return availableOperators[operator].apply(availableOperators, _toConsumableArray(params));
583
583
  }
584
584
 
585
- /**
586
- * Register operator.
587
- *
588
- * @param {String|Array} symbol Symbol to register.
589
- * @param {Function} func Logic to register for this symbol.
585
+ /**
586
+ * Register operator.
587
+ *
588
+ * @param {String|Array} symbol Symbol to register.
589
+ * @param {Function} func Logic to register for this symbol.
590
590
  */
591
591
  function registerOperation(symbol, func) {
592
592
  if (!Array.isArray(symbol)) {
@@ -2022,12 +2022,12 @@ Parser.prototype = parser;
2022
2022
  parser.Parser = Parser;
2023
2023
 
2024
2024
  /* eslint-disable import/prefer-default-export */
2025
- /**
2026
- * Trim value by cutting character starting from the beginning and ending at the same time.
2027
- *
2028
- * @param {String} string String to trimming.
2029
- * @param {Number} [margin=1] Number of character to cut.
2030
- * @returns {String}
2025
+ /**
2026
+ * Trim value by cutting character starting from the beginning and ending at the same time.
2027
+ *
2028
+ * @param {String} string String to trimming.
2029
+ * @param {Number} [margin=1] Number of character to cut.
2030
+ * @returns {String}
2031
2031
  */
2032
2032
  function trimEdges(string) {
2033
2033
  var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
@@ -2035,11 +2035,11 @@ function trimEdges(string) {
2035
2035
  return string;
2036
2036
  }
2037
2037
 
2038
- /**
2039
- * Convert row label to index.
2040
- *
2041
- * @param {String} label Row label (eq. '1', '5')
2042
- * @returns {Number} Returns -1 if label is not recognized otherwise proper row index.
2038
+ /**
2039
+ * Convert row label to index.
2040
+ *
2041
+ * @param {String} label Row label (eq. '1', '5')
2042
+ * @returns {Number} Returns -1 if label is not recognized otherwise proper row index.
2043
2043
  */
2044
2044
  function rowLabelToIndex(label) {
2045
2045
  var result = parseInt(label, 10);
@@ -2051,11 +2051,11 @@ function rowLabelToIndex(label) {
2051
2051
  return result;
2052
2052
  }
2053
2053
 
2054
- /**
2055
- * Convert row index to label.
2056
- *
2057
- * @param {Number} row Row index.
2058
- * @returns {String} Returns row label (eq. '1', '7').
2054
+ /**
2055
+ * Convert row index to label.
2056
+ *
2057
+ * @param {Number} row Row index.
2058
+ * @returns {String} Returns row label (eq. '1', '7').
2059
2059
  */
2060
2060
  function rowIndexToLabel(row) {
2061
2061
  var result = "";
@@ -2067,11 +2067,11 @@ function rowIndexToLabel(row) {
2067
2067
  var COLUMN_LABEL_BASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
2068
2068
  var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
2069
2069
 
2070
- /**
2071
- * Convert column label to index.
2072
- *
2073
- * @param {String} label Column label (eq. 'ABB', 'CNQ')
2074
- * @returns {Number} Returns -1 if label is not recognized otherwise proper column index.
2070
+ /**
2071
+ * Convert column label to index.
2072
+ *
2073
+ * @param {String} label Column label (eq. 'ABB', 'CNQ')
2074
+ * @returns {Number} Returns -1 if label is not recognized otherwise proper column index.
2075
2075
  */
2076
2076
  function columnLabelToIndex(label) {
2077
2077
  var result = 0;
@@ -2085,11 +2085,11 @@ function columnLabelToIndex(label) {
2085
2085
  return result;
2086
2086
  }
2087
2087
 
2088
- /**
2089
- * Convert column index to label.
2090
- *
2091
- * @param {Number} column Column index.
2092
- * @returns {String} Returns column label (eq. 'ABB', 'CNQ').
2088
+ /**
2089
+ * Convert column index to label.
2090
+ *
2091
+ * @param {Number} column Column index.
2092
+ * @returns {String} Returns column label (eq. 'ABB', 'CNQ').
2093
2093
  */
2094
2094
  function columnIndexToLabel(column) {
2095
2095
  var result = "";
@@ -2104,11 +2104,11 @@ var quotedSheetName$1 = "'(?:(?!').|'')*'";
2104
2104
  var sheetNameRegexp$1 = "(".concat(simpleSheetName$1, "|").concat(quotedSheetName$1, ")!");
2105
2105
  var LABEL_EXTRACT_REGEXP = new RegExp("^(?:".concat(sheetNameRegexp$1, ")?([$])?([A-Za-z]*)([$])?([0-9]*)$"));
2106
2106
 
2107
- /**
2108
- * Extract cell coordinates.
2109
- *
2110
- * @param {String} label Cell coordinates (eq. 'A1', '$B6', '$N$98').
2111
- * @returns {Array} Returns an array of objects.
2107
+ /**
2108
+ * Extract cell coordinates.
2109
+ *
2110
+ * @param {String} label Cell coordinates (eq. 'A1', '$B6', '$N$98').
2111
+ * @returns {Array} Returns an array of objects.
2112
2112
  */
2113
2113
  function extractLabel(label) {
2114
2114
  if (typeof label !== "string" || !LABEL_EXTRACT_REGEXP.test(label)) {
@@ -2134,12 +2134,12 @@ function extractLabel(label) {
2134
2134
  }, sheetName];
2135
2135
  }
2136
2136
 
2137
- /**
2138
- * Convert row and column indexes into cell label.
2139
- *
2140
- * @param {Object} row Object with `index` and `isAbsolute` properties.
2141
- * @param {Object} column Object with `index` and `isAbsolute` properties.
2142
- * @returns {String} Returns cell label.
2137
+ /**
2138
+ * Convert row and column indexes into cell label.
2139
+ *
2140
+ * @param {Object} row Object with `index` and `isAbsolute` properties.
2141
+ * @param {Object} column Object with `index` and `isAbsolute` properties.
2142
+ * @returns {String} Returns cell label.
2143
2143
  */
2144
2144
  function toLabel(row, column) {
2145
2145
  var rowLabel = (row.isAbsolute ? "$" : "") + rowIndexToLabel(row.index);
@@ -2147,8 +2147,8 @@ function toLabel(row, column) {
2147
2147
  return columnLabel + rowLabel;
2148
2148
  }
2149
2149
 
2150
- /**
2151
- * @class Parser
2150
+ /**
2151
+ * @class Parser
2152
2152
  */
2153
2153
  var Parser$1 = /*#__PURE__*/function (_Emitter) {
2154
2154
  function Parser$1() {
@@ -2184,13 +2184,13 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2184
2184
  return _this;
2185
2185
  }
2186
2186
 
2187
- /**
2188
- * Parse formula expression.
2189
- *
2190
- * @param {string} expression to parse.
2191
- * @param {object} options additional params.
2192
- * @param {string} options.sheetId id of sheet which the formula expression belongs to.
2193
- * @return {*} Returns an object with tow properties `error` and `result`.
2187
+ /**
2188
+ * Parse formula expression.
2189
+ *
2190
+ * @param {string} expression to parse.
2191
+ * @param {object} options additional params.
2192
+ * @param {string} options.sheetId id of sheet which the formula expression belongs to.
2193
+ * @return {*} Returns an object with tow properties `error` and `result`.
2194
2194
  */
2195
2195
  _inherits(Parser$1, _Emitter);
2196
2196
  return _createClass(Parser$1, [{
@@ -2226,12 +2226,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2226
2226
  };
2227
2227
  }
2228
2228
 
2229
- /**
2230
- * Set predefined variable name which can be visible while parsing formula expression.
2231
- *
2232
- * @param {String} name Variable name.
2233
- * @param {*} value Variable value.
2234
- * @returns {Parser}
2229
+ /**
2230
+ * Set predefined variable name which can be visible while parsing formula expression.
2231
+ *
2232
+ * @param {String} name Variable name.
2233
+ * @param {*} value Variable value.
2234
+ * @returns {Parser}
2235
2235
  */
2236
2236
  }, {
2237
2237
  key: "setVariable",
@@ -2244,11 +2244,11 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2244
2244
  value: function replaceVariables(variables) {
2245
2245
  this.variables = variables;
2246
2246
  }
2247
- /**
2248
- * Get variable name.
2249
- *
2250
- * @param {String} name Variable name.
2251
- * @returns {*}
2247
+ /**
2248
+ * Get variable name.
2249
+ *
2250
+ * @param {String} name Variable name.
2251
+ * @returns {*}
2252
2252
  */
2253
2253
  }, {
2254
2254
  key: "getVariable",
@@ -2256,12 +2256,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2256
2256
  return this.variables[name];
2257
2257
  }
2258
2258
 
2259
- /**
2260
- * Retrieve variable value by its name.
2261
- *
2262
- * @param name Variable name.
2263
- * @returns {*}
2264
- * @private
2259
+ /**
2260
+ * Retrieve variable value by its name.
2261
+ *
2262
+ * @param name Variable name.
2263
+ * @returns {*}
2264
+ * @private
2265
2265
  */
2266
2266
  }, {
2267
2267
  key: "_callVariable",
@@ -2278,12 +2278,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2278
2278
  return value;
2279
2279
  }
2280
2280
 
2281
- /**
2282
- * Set custom function which can be visible while parsing formula expression.
2283
- *
2284
- * @param {String} name Custom function name.
2285
- * @param {Function} fn Custom function.
2286
- * @returns {Parser}
2281
+ /**
2282
+ * Set custom function which can be visible while parsing formula expression.
2283
+ *
2284
+ * @param {String} name Custom function name.
2285
+ * @param {Function} fn Custom function.
2286
+ * @returns {Parser}
2287
2287
  */
2288
2288
  }, {
2289
2289
  key: "setFunction",
@@ -2292,11 +2292,11 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2292
2292
  return this;
2293
2293
  }
2294
2294
 
2295
- /**
2296
- * Get custom function.
2297
- *
2298
- * @param {String} name Custom function name.
2299
- * @returns {*}
2295
+ /**
2296
+ * Get custom function.
2297
+ *
2298
+ * @param {String} name Custom function name.
2299
+ * @returns {*}
2300
2300
  */
2301
2301
  }, {
2302
2302
  key: "getFunction",
@@ -2304,13 +2304,13 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2304
2304
  return this.functions[name];
2305
2305
  }
2306
2306
 
2307
- /**
2308
- * Call function with provided params.
2309
- *
2310
- * @param name Function name.
2311
- * @param params Function params.
2312
- * @returns {*}
2313
- * @private
2307
+ /**
2308
+ * Call function with provided params.
2309
+ *
2310
+ * @param name Function name.
2311
+ * @param params Function params.
2312
+ * @returns {*}
2313
+ * @private
2314
2314
  */
2315
2315
  }, {
2316
2316
  key: "_callFunction",
@@ -2329,12 +2329,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2329
2329
  return value === void 0 ? evaluateByOperator(name, params) : value;
2330
2330
  }
2331
2331
 
2332
- /**
2333
- * Retrieve value by its label (`B3`, `B$3`, `B$3`, `$B$3`).
2334
- *
2335
- * @param {String} label Coordinates.
2336
- * @returns {*}
2337
- * @private
2332
+ /**
2333
+ * Retrieve value by its label (`B3`, `B$3`, `B$3`, `$B$3`).
2334
+ *
2335
+ * @param {String} label Coordinates.
2336
+ * @returns {*}
2337
+ * @private
2338
2338
  */
2339
2339
  }, {
2340
2340
  key: "_callCellValue",
@@ -2364,13 +2364,13 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2364
2364
  return value;
2365
2365
  }
2366
2366
 
2367
- /**
2368
- * Retrieve value by its label (`B3:A1`, `B$3:A1`, `B$3:$A1`, `$B$3:A$1`).
2369
- *
2370
- * @param {String} startLabel Coordinates of the first cell.
2371
- * @param {String} endLabel Coordinates of the last cell.
2372
- * @returns {Array} Returns an array of mixed values.
2373
- * @private
2367
+ /**
2368
+ * Retrieve value by its label (`B3:A1`, `B$3:A1`, `B$3:$A1`, `$B$3:A$1`).
2369
+ *
2370
+ * @param {String} startLabel Coordinates of the first cell.
2371
+ * @param {String} endLabel Coordinates of the last cell.
2372
+ * @returns {Array} Returns an array of mixed values.
2373
+ * @private
2374
2374
  */
2375
2375
  }, {
2376
2376
  key: "_callRangeValue",
@@ -2415,12 +2415,12 @@ var Parser$1 = /*#__PURE__*/function (_Emitter) {
2415
2415
  return value;
2416
2416
  }
2417
2417
 
2418
- /**
2419
- * Try to throw error by its name.
2420
- *
2421
- * @param {String} errorName Error name.
2422
- * @returns {String}
2423
- * @private
2418
+ /**
2419
+ * Try to throw error by its name.
2420
+ *
2421
+ * @param {String} errorName Error name.
2422
+ * @returns {String}
2423
+ * @private
2424
2424
  */
2425
2425
  }, {
2426
2426
  key: "_throwError",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leankylin-sheet/formula-parser",
3
- "version": "4.0.56",
3
+ "version": "4.0.58",
4
4
  "description": "Formula parser",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",