amis-formula 1.2.4 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/doc.js +302 -51
- package/dist/doc.md +216 -56
- package/dist/evalutor.d.ts +211 -50
- package/dist/index.js +1468 -52
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* amis-formula v1.2.
|
|
2
|
+
* amis-formula v1.2.8
|
|
3
3
|
* Copyright 2021 fex
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -24,6 +24,1160 @@ var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
|
|
|
24
24
|
var uniq__default = /*#__PURE__*/_interopDefaultLegacy(uniq);
|
|
25
25
|
var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* The base implementation of `_.slice` without an iteratee call guard.
|
|
29
|
+
*
|
|
30
|
+
* @private
|
|
31
|
+
* @param {Array} array The array to slice.
|
|
32
|
+
* @param {number} [start=0] The start position.
|
|
33
|
+
* @param {number} [end=array.length] The end position.
|
|
34
|
+
* @returns {Array} Returns the slice of `array`.
|
|
35
|
+
*/
|
|
36
|
+
function baseSlice(array, start, end) {
|
|
37
|
+
var index = -1,
|
|
38
|
+
length = array.length;
|
|
39
|
+
|
|
40
|
+
if (start < 0) {
|
|
41
|
+
start = -start > length ? 0 : (length + start);
|
|
42
|
+
}
|
|
43
|
+
end = end > length ? length : end;
|
|
44
|
+
if (end < 0) {
|
|
45
|
+
end += length;
|
|
46
|
+
}
|
|
47
|
+
length = start > end ? 0 : ((end - start) >>> 0);
|
|
48
|
+
start >>>= 0;
|
|
49
|
+
|
|
50
|
+
var result = Array(length);
|
|
51
|
+
while (++index < length) {
|
|
52
|
+
result[index] = array[index + start];
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var _baseSlice = baseSlice;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Casts `array` to a slice if it's needed.
|
|
61
|
+
*
|
|
62
|
+
* @private
|
|
63
|
+
* @param {Array} array The array to inspect.
|
|
64
|
+
* @param {number} start The start position.
|
|
65
|
+
* @param {number} [end=array.length] The end position.
|
|
66
|
+
* @returns {Array} Returns the cast slice.
|
|
67
|
+
*/
|
|
68
|
+
function castSlice(array, start, end) {
|
|
69
|
+
var length = array.length;
|
|
70
|
+
end = end === undefined ? length : end;
|
|
71
|
+
return (!start && end >= length) ? array : _baseSlice(array, start, end);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var _castSlice = castSlice;
|
|
75
|
+
|
|
76
|
+
/** Used to compose unicode character classes. */
|
|
77
|
+
var rsAstralRange$2 = '\\ud800-\\udfff',
|
|
78
|
+
rsComboMarksRange$2 = '\\u0300-\\u036f',
|
|
79
|
+
reComboHalfMarksRange$2 = '\\ufe20-\\ufe2f',
|
|
80
|
+
rsComboSymbolsRange$2 = '\\u20d0-\\u20ff',
|
|
81
|
+
rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2,
|
|
82
|
+
rsVarRange$2 = '\\ufe0e\\ufe0f';
|
|
83
|
+
|
|
84
|
+
/** Used to compose unicode capture groups. */
|
|
85
|
+
var rsZWJ$2 = '\\u200d';
|
|
86
|
+
|
|
87
|
+
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
|
88
|
+
var reHasUnicode = RegExp('[' + rsZWJ$2 + rsAstralRange$2 + rsComboRange$2 + rsVarRange$2 + ']');
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Checks if `string` contains Unicode symbols.
|
|
92
|
+
*
|
|
93
|
+
* @private
|
|
94
|
+
* @param {string} string The string to inspect.
|
|
95
|
+
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
|
|
96
|
+
*/
|
|
97
|
+
function hasUnicode(string) {
|
|
98
|
+
return reHasUnicode.test(string);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
var _hasUnicode = hasUnicode;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Converts an ASCII `string` to an array.
|
|
105
|
+
*
|
|
106
|
+
* @private
|
|
107
|
+
* @param {string} string The string to convert.
|
|
108
|
+
* @returns {Array} Returns the converted array.
|
|
109
|
+
*/
|
|
110
|
+
function asciiToArray(string) {
|
|
111
|
+
return string.split('');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var _asciiToArray = asciiToArray;
|
|
115
|
+
|
|
116
|
+
/** Used to compose unicode character classes. */
|
|
117
|
+
var rsAstralRange$1 = '\\ud800-\\udfff',
|
|
118
|
+
rsComboMarksRange$1 = '\\u0300-\\u036f',
|
|
119
|
+
reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
|
|
120
|
+
rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
|
|
121
|
+
rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1,
|
|
122
|
+
rsVarRange$1 = '\\ufe0e\\ufe0f';
|
|
123
|
+
|
|
124
|
+
/** Used to compose unicode capture groups. */
|
|
125
|
+
var rsAstral$1 = '[' + rsAstralRange$1 + ']',
|
|
126
|
+
rsCombo$1 = '[' + rsComboRange$1 + ']',
|
|
127
|
+
rsFitz$1 = '\\ud83c[\\udffb-\\udfff]',
|
|
128
|
+
rsModifier$1 = '(?:' + rsCombo$1 + '|' + rsFitz$1 + ')',
|
|
129
|
+
rsNonAstral$1 = '[^' + rsAstralRange$1 + ']',
|
|
130
|
+
rsRegional$1 = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
|
131
|
+
rsSurrPair$1 = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
|
132
|
+
rsZWJ$1 = '\\u200d';
|
|
133
|
+
|
|
134
|
+
/** Used to compose unicode regexes. */
|
|
135
|
+
var reOptMod$1 = rsModifier$1 + '?',
|
|
136
|
+
rsOptVar$1 = '[' + rsVarRange$1 + ']?',
|
|
137
|
+
rsOptJoin$1 = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsOptVar$1 + reOptMod$1 + ')*',
|
|
138
|
+
rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1,
|
|
139
|
+
rsSymbol$1 = '(?:' + [rsNonAstral$1 + rsCombo$1 + '?', rsCombo$1, rsRegional$1, rsSurrPair$1, rsAstral$1].join('|') + ')';
|
|
140
|
+
|
|
141
|
+
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
|
142
|
+
var reUnicode$1 = RegExp(rsFitz$1 + '(?=' + rsFitz$1 + ')|' + rsSymbol$1 + rsSeq$1, 'g');
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Converts a Unicode `string` to an array.
|
|
146
|
+
*
|
|
147
|
+
* @private
|
|
148
|
+
* @param {string} string The string to convert.
|
|
149
|
+
* @returns {Array} Returns the converted array.
|
|
150
|
+
*/
|
|
151
|
+
function unicodeToArray(string) {
|
|
152
|
+
return string.match(reUnicode$1) || [];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
var _unicodeToArray = unicodeToArray;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Converts `string` to an array.
|
|
159
|
+
*
|
|
160
|
+
* @private
|
|
161
|
+
* @param {string} string The string to convert.
|
|
162
|
+
* @returns {Array} Returns the converted array.
|
|
163
|
+
*/
|
|
164
|
+
function stringToArray(string) {
|
|
165
|
+
return _hasUnicode(string)
|
|
166
|
+
? _unicodeToArray(string)
|
|
167
|
+
: _asciiToArray(string);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
var _stringToArray = stringToArray;
|
|
171
|
+
|
|
172
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
173
|
+
|
|
174
|
+
function createCommonjsModule(fn, module) {
|
|
175
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Detect free variable `global` from Node.js. */
|
|
179
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
180
|
+
|
|
181
|
+
var _freeGlobal = freeGlobal;
|
|
182
|
+
|
|
183
|
+
/** Detect free variable `self`. */
|
|
184
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
185
|
+
|
|
186
|
+
/** Used as a reference to the global object. */
|
|
187
|
+
var root = _freeGlobal || freeSelf || Function('return this')();
|
|
188
|
+
|
|
189
|
+
var _root = root;
|
|
190
|
+
|
|
191
|
+
/** Built-in value references. */
|
|
192
|
+
var Symbol = _root.Symbol;
|
|
193
|
+
|
|
194
|
+
var _Symbol = Symbol;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
198
|
+
* shorthands.
|
|
199
|
+
*
|
|
200
|
+
* @private
|
|
201
|
+
* @param {Array} [array] The array to iterate over.
|
|
202
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
203
|
+
* @returns {Array} Returns the new mapped array.
|
|
204
|
+
*/
|
|
205
|
+
function arrayMap(array, iteratee) {
|
|
206
|
+
var index = -1,
|
|
207
|
+
length = array == null ? 0 : array.length,
|
|
208
|
+
result = Array(length);
|
|
209
|
+
|
|
210
|
+
while (++index < length) {
|
|
211
|
+
result[index] = iteratee(array[index], index, array);
|
|
212
|
+
}
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
var _arrayMap = arrayMap;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Checks if `value` is classified as an `Array` object.
|
|
220
|
+
*
|
|
221
|
+
* @static
|
|
222
|
+
* @memberOf _
|
|
223
|
+
* @since 0.1.0
|
|
224
|
+
* @category Lang
|
|
225
|
+
* @param {*} value The value to check.
|
|
226
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
227
|
+
* @example
|
|
228
|
+
*
|
|
229
|
+
* _.isArray([1, 2, 3]);
|
|
230
|
+
* // => true
|
|
231
|
+
*
|
|
232
|
+
* _.isArray(document.body.children);
|
|
233
|
+
* // => false
|
|
234
|
+
*
|
|
235
|
+
* _.isArray('abc');
|
|
236
|
+
* // => false
|
|
237
|
+
*
|
|
238
|
+
* _.isArray(_.noop);
|
|
239
|
+
* // => false
|
|
240
|
+
*/
|
|
241
|
+
var isArray = Array.isArray;
|
|
242
|
+
|
|
243
|
+
var isArray_1 = isArray;
|
|
244
|
+
|
|
245
|
+
/** Used for built-in method references. */
|
|
246
|
+
var objectProto$1 = Object.prototype;
|
|
247
|
+
|
|
248
|
+
/** Used to check objects for own properties. */
|
|
249
|
+
var hasOwnProperty = objectProto$1.hasOwnProperty;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Used to resolve the
|
|
253
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
254
|
+
* of values.
|
|
255
|
+
*/
|
|
256
|
+
var nativeObjectToString$1 = objectProto$1.toString;
|
|
257
|
+
|
|
258
|
+
/** Built-in value references. */
|
|
259
|
+
var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
263
|
+
*
|
|
264
|
+
* @private
|
|
265
|
+
* @param {*} value The value to query.
|
|
266
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
267
|
+
*/
|
|
268
|
+
function getRawTag(value) {
|
|
269
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag$1),
|
|
270
|
+
tag = value[symToStringTag$1];
|
|
271
|
+
|
|
272
|
+
try {
|
|
273
|
+
value[symToStringTag$1] = undefined;
|
|
274
|
+
var unmasked = true;
|
|
275
|
+
} catch (e) {}
|
|
276
|
+
|
|
277
|
+
var result = nativeObjectToString$1.call(value);
|
|
278
|
+
if (unmasked) {
|
|
279
|
+
if (isOwn) {
|
|
280
|
+
value[symToStringTag$1] = tag;
|
|
281
|
+
} else {
|
|
282
|
+
delete value[symToStringTag$1];
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
var _getRawTag = getRawTag;
|
|
289
|
+
|
|
290
|
+
/** Used for built-in method references. */
|
|
291
|
+
var objectProto = Object.prototype;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Used to resolve the
|
|
295
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
296
|
+
* of values.
|
|
297
|
+
*/
|
|
298
|
+
var nativeObjectToString = objectProto.toString;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
302
|
+
*
|
|
303
|
+
* @private
|
|
304
|
+
* @param {*} value The value to convert.
|
|
305
|
+
* @returns {string} Returns the converted string.
|
|
306
|
+
*/
|
|
307
|
+
function objectToString(value) {
|
|
308
|
+
return nativeObjectToString.call(value);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
var _objectToString = objectToString;
|
|
312
|
+
|
|
313
|
+
/** `Object#toString` result references. */
|
|
314
|
+
var nullTag = '[object Null]',
|
|
315
|
+
undefinedTag = '[object Undefined]';
|
|
316
|
+
|
|
317
|
+
/** Built-in value references. */
|
|
318
|
+
var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
322
|
+
*
|
|
323
|
+
* @private
|
|
324
|
+
* @param {*} value The value to query.
|
|
325
|
+
* @returns {string} Returns the `toStringTag`.
|
|
326
|
+
*/
|
|
327
|
+
function baseGetTag(value) {
|
|
328
|
+
if (value == null) {
|
|
329
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
330
|
+
}
|
|
331
|
+
return (symToStringTag && symToStringTag in Object(value))
|
|
332
|
+
? _getRawTag(value)
|
|
333
|
+
: _objectToString(value);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
var _baseGetTag = baseGetTag;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
340
|
+
* and has a `typeof` result of "object".
|
|
341
|
+
*
|
|
342
|
+
* @static
|
|
343
|
+
* @memberOf _
|
|
344
|
+
* @since 4.0.0
|
|
345
|
+
* @category Lang
|
|
346
|
+
* @param {*} value The value to check.
|
|
347
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
348
|
+
* @example
|
|
349
|
+
*
|
|
350
|
+
* _.isObjectLike({});
|
|
351
|
+
* // => true
|
|
352
|
+
*
|
|
353
|
+
* _.isObjectLike([1, 2, 3]);
|
|
354
|
+
* // => true
|
|
355
|
+
*
|
|
356
|
+
* _.isObjectLike(_.noop);
|
|
357
|
+
* // => false
|
|
358
|
+
*
|
|
359
|
+
* _.isObjectLike(null);
|
|
360
|
+
* // => false
|
|
361
|
+
*/
|
|
362
|
+
function isObjectLike(value) {
|
|
363
|
+
return value != null && typeof value == 'object';
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
var isObjectLike_1 = isObjectLike;
|
|
367
|
+
|
|
368
|
+
/** `Object#toString` result references. */
|
|
369
|
+
var symbolTag = '[object Symbol]';
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
373
|
+
*
|
|
374
|
+
* @static
|
|
375
|
+
* @memberOf _
|
|
376
|
+
* @since 4.0.0
|
|
377
|
+
* @category Lang
|
|
378
|
+
* @param {*} value The value to check.
|
|
379
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
380
|
+
* @example
|
|
381
|
+
*
|
|
382
|
+
* _.isSymbol(Symbol.iterator);
|
|
383
|
+
* // => true
|
|
384
|
+
*
|
|
385
|
+
* _.isSymbol('abc');
|
|
386
|
+
* // => false
|
|
387
|
+
*/
|
|
388
|
+
function isSymbol(value) {
|
|
389
|
+
return typeof value == 'symbol' ||
|
|
390
|
+
(isObjectLike_1(value) && _baseGetTag(value) == symbolTag);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
var isSymbol_1 = isSymbol;
|
|
394
|
+
|
|
395
|
+
/** Used as references for various `Number` constants. */
|
|
396
|
+
var INFINITY$1 = 1 / 0;
|
|
397
|
+
|
|
398
|
+
/** Used to convert symbols to primitives and strings. */
|
|
399
|
+
var symbolProto = _Symbol ? _Symbol.prototype : undefined,
|
|
400
|
+
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The base implementation of `_.toString` which doesn't convert nullish
|
|
404
|
+
* values to empty strings.
|
|
405
|
+
*
|
|
406
|
+
* @private
|
|
407
|
+
* @param {*} value The value to process.
|
|
408
|
+
* @returns {string} Returns the string.
|
|
409
|
+
*/
|
|
410
|
+
function baseToString(value) {
|
|
411
|
+
// Exit early for strings to avoid a performance hit in some environments.
|
|
412
|
+
if (typeof value == 'string') {
|
|
413
|
+
return value;
|
|
414
|
+
}
|
|
415
|
+
if (isArray_1(value)) {
|
|
416
|
+
// Recursively convert values (susceptible to call stack limits).
|
|
417
|
+
return _arrayMap(value, baseToString) + '';
|
|
418
|
+
}
|
|
419
|
+
if (isSymbol_1(value)) {
|
|
420
|
+
return symbolToString ? symbolToString.call(value) : '';
|
|
421
|
+
}
|
|
422
|
+
var result = (value + '');
|
|
423
|
+
return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
var _baseToString = baseToString;
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Converts `value` to a string. An empty string is returned for `null`
|
|
430
|
+
* and `undefined` values. The sign of `-0` is preserved.
|
|
431
|
+
*
|
|
432
|
+
* @static
|
|
433
|
+
* @memberOf _
|
|
434
|
+
* @since 4.0.0
|
|
435
|
+
* @category Lang
|
|
436
|
+
* @param {*} value The value to convert.
|
|
437
|
+
* @returns {string} Returns the converted string.
|
|
438
|
+
* @example
|
|
439
|
+
*
|
|
440
|
+
* _.toString(null);
|
|
441
|
+
* // => ''
|
|
442
|
+
*
|
|
443
|
+
* _.toString(-0);
|
|
444
|
+
* // => '-0'
|
|
445
|
+
*
|
|
446
|
+
* _.toString([1, 2, 3]);
|
|
447
|
+
* // => '1,2,3'
|
|
448
|
+
*/
|
|
449
|
+
function toString(value) {
|
|
450
|
+
return value == null ? '' : _baseToString(value);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
var toString_1 = toString;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Creates a function like `_.lowerFirst`.
|
|
457
|
+
*
|
|
458
|
+
* @private
|
|
459
|
+
* @param {string} methodName The name of the `String` case method to use.
|
|
460
|
+
* @returns {Function} Returns the new case function.
|
|
461
|
+
*/
|
|
462
|
+
function createCaseFirst(methodName) {
|
|
463
|
+
return function(string) {
|
|
464
|
+
string = toString_1(string);
|
|
465
|
+
|
|
466
|
+
var strSymbols = _hasUnicode(string)
|
|
467
|
+
? _stringToArray(string)
|
|
468
|
+
: undefined;
|
|
469
|
+
|
|
470
|
+
var chr = strSymbols
|
|
471
|
+
? strSymbols[0]
|
|
472
|
+
: string.charAt(0);
|
|
473
|
+
|
|
474
|
+
var trailing = strSymbols
|
|
475
|
+
? _castSlice(strSymbols, 1).join('')
|
|
476
|
+
: string.slice(1);
|
|
477
|
+
|
|
478
|
+
return chr[methodName]() + trailing;
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
var _createCaseFirst = createCaseFirst;
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Converts the first character of `string` to upper case.
|
|
486
|
+
*
|
|
487
|
+
* @static
|
|
488
|
+
* @memberOf _
|
|
489
|
+
* @since 4.0.0
|
|
490
|
+
* @category String
|
|
491
|
+
* @param {string} [string=''] The string to convert.
|
|
492
|
+
* @returns {string} Returns the converted string.
|
|
493
|
+
* @example
|
|
494
|
+
*
|
|
495
|
+
* _.upperFirst('fred');
|
|
496
|
+
* // => 'Fred'
|
|
497
|
+
*
|
|
498
|
+
* _.upperFirst('FRED');
|
|
499
|
+
* // => 'FRED'
|
|
500
|
+
*/
|
|
501
|
+
var upperFirst = _createCaseFirst('toUpperCase');
|
|
502
|
+
|
|
503
|
+
var upperFirst_1 = upperFirst;
|
|
504
|
+
|
|
505
|
+
/** Used as references for various `Number` constants. */
|
|
506
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
507
|
+
|
|
508
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
509
|
+
var nativeFloor = Math.floor;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* The base implementation of `_.repeat` which doesn't coerce arguments.
|
|
513
|
+
*
|
|
514
|
+
* @private
|
|
515
|
+
* @param {string} string The string to repeat.
|
|
516
|
+
* @param {number} n The number of times to repeat the string.
|
|
517
|
+
* @returns {string} Returns the repeated string.
|
|
518
|
+
*/
|
|
519
|
+
function baseRepeat(string, n) {
|
|
520
|
+
var result = '';
|
|
521
|
+
if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
|
|
522
|
+
return result;
|
|
523
|
+
}
|
|
524
|
+
// Leverage the exponentiation by squaring algorithm for a faster repeat.
|
|
525
|
+
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
|
|
526
|
+
do {
|
|
527
|
+
if (n % 2) {
|
|
528
|
+
result += string;
|
|
529
|
+
}
|
|
530
|
+
n = nativeFloor(n / 2);
|
|
531
|
+
if (n) {
|
|
532
|
+
string += string;
|
|
533
|
+
}
|
|
534
|
+
} while (n);
|
|
535
|
+
|
|
536
|
+
return result;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
var _baseRepeat = baseRepeat;
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* The base implementation of `_.property` without support for deep paths.
|
|
543
|
+
*
|
|
544
|
+
* @private
|
|
545
|
+
* @param {string} key The key of the property to get.
|
|
546
|
+
* @returns {Function} Returns the new accessor function.
|
|
547
|
+
*/
|
|
548
|
+
function baseProperty(key) {
|
|
549
|
+
return function(object) {
|
|
550
|
+
return object == null ? undefined : object[key];
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
var _baseProperty = baseProperty;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Gets the size of an ASCII `string`.
|
|
558
|
+
*
|
|
559
|
+
* @private
|
|
560
|
+
* @param {string} string The string inspect.
|
|
561
|
+
* @returns {number} Returns the string size.
|
|
562
|
+
*/
|
|
563
|
+
var asciiSize = _baseProperty('length');
|
|
564
|
+
|
|
565
|
+
var _asciiSize = asciiSize;
|
|
566
|
+
|
|
567
|
+
/** Used to compose unicode character classes. */
|
|
568
|
+
var rsAstralRange = '\\ud800-\\udfff',
|
|
569
|
+
rsComboMarksRange = '\\u0300-\\u036f',
|
|
570
|
+
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
|
571
|
+
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
|
572
|
+
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
|
573
|
+
rsVarRange = '\\ufe0e\\ufe0f';
|
|
574
|
+
|
|
575
|
+
/** Used to compose unicode capture groups. */
|
|
576
|
+
var rsAstral = '[' + rsAstralRange + ']',
|
|
577
|
+
rsCombo = '[' + rsComboRange + ']',
|
|
578
|
+
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
|
579
|
+
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
|
580
|
+
rsNonAstral = '[^' + rsAstralRange + ']',
|
|
581
|
+
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
|
582
|
+
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
|
583
|
+
rsZWJ = '\\u200d';
|
|
584
|
+
|
|
585
|
+
/** Used to compose unicode regexes. */
|
|
586
|
+
var reOptMod = rsModifier + '?',
|
|
587
|
+
rsOptVar = '[' + rsVarRange + ']?',
|
|
588
|
+
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
|
589
|
+
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
|
590
|
+
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
|
591
|
+
|
|
592
|
+
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
|
593
|
+
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Gets the size of a Unicode `string`.
|
|
597
|
+
*
|
|
598
|
+
* @private
|
|
599
|
+
* @param {string} string The string inspect.
|
|
600
|
+
* @returns {number} Returns the string size.
|
|
601
|
+
*/
|
|
602
|
+
function unicodeSize(string) {
|
|
603
|
+
var result = reUnicode.lastIndex = 0;
|
|
604
|
+
while (reUnicode.test(string)) {
|
|
605
|
+
++result;
|
|
606
|
+
}
|
|
607
|
+
return result;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
var _unicodeSize = unicodeSize;
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Gets the number of symbols in `string`.
|
|
614
|
+
*
|
|
615
|
+
* @private
|
|
616
|
+
* @param {string} string The string to inspect.
|
|
617
|
+
* @returns {number} Returns the string size.
|
|
618
|
+
*/
|
|
619
|
+
function stringSize(string) {
|
|
620
|
+
return _hasUnicode(string)
|
|
621
|
+
? _unicodeSize(string)
|
|
622
|
+
: _asciiSize(string);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
var _stringSize = stringSize;
|
|
626
|
+
|
|
627
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
628
|
+
var nativeCeil = Math.ceil;
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Creates the padding for `string` based on `length`. The `chars` string
|
|
632
|
+
* is truncated if the number of characters exceeds `length`.
|
|
633
|
+
*
|
|
634
|
+
* @private
|
|
635
|
+
* @param {number} length The padding length.
|
|
636
|
+
* @param {string} [chars=' '] The string used as padding.
|
|
637
|
+
* @returns {string} Returns the padding for `string`.
|
|
638
|
+
*/
|
|
639
|
+
function createPadding(length, chars) {
|
|
640
|
+
chars = chars === undefined ? ' ' : _baseToString(chars);
|
|
641
|
+
|
|
642
|
+
var charsLength = chars.length;
|
|
643
|
+
if (charsLength < 2) {
|
|
644
|
+
return charsLength ? _baseRepeat(chars, length) : chars;
|
|
645
|
+
}
|
|
646
|
+
var result = _baseRepeat(chars, nativeCeil(length / _stringSize(chars)));
|
|
647
|
+
return _hasUnicode(chars)
|
|
648
|
+
? _castSlice(_stringToArray(result), 0, length).join('')
|
|
649
|
+
: result.slice(0, length);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
var _createPadding = createPadding;
|
|
653
|
+
|
|
654
|
+
/** Used to match a single whitespace character. */
|
|
655
|
+
var reWhitespace = /\s/;
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
|
|
659
|
+
* character of `string`.
|
|
660
|
+
*
|
|
661
|
+
* @private
|
|
662
|
+
* @param {string} string The string to inspect.
|
|
663
|
+
* @returns {number} Returns the index of the last non-whitespace character.
|
|
664
|
+
*/
|
|
665
|
+
function trimmedEndIndex(string) {
|
|
666
|
+
var index = string.length;
|
|
667
|
+
|
|
668
|
+
while (index-- && reWhitespace.test(string.charAt(index))) {}
|
|
669
|
+
return index;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
var _trimmedEndIndex = trimmedEndIndex;
|
|
673
|
+
|
|
674
|
+
/** Used to match leading whitespace. */
|
|
675
|
+
var reTrimStart = /^\s+/;
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* The base implementation of `_.trim`.
|
|
679
|
+
*
|
|
680
|
+
* @private
|
|
681
|
+
* @param {string} string The string to trim.
|
|
682
|
+
* @returns {string} Returns the trimmed string.
|
|
683
|
+
*/
|
|
684
|
+
function baseTrim(string) {
|
|
685
|
+
return string
|
|
686
|
+
? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '')
|
|
687
|
+
: string;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
var _baseTrim = baseTrim;
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Checks if `value` is the
|
|
694
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
695
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
696
|
+
*
|
|
697
|
+
* @static
|
|
698
|
+
* @memberOf _
|
|
699
|
+
* @since 0.1.0
|
|
700
|
+
* @category Lang
|
|
701
|
+
* @param {*} value The value to check.
|
|
702
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
703
|
+
* @example
|
|
704
|
+
*
|
|
705
|
+
* _.isObject({});
|
|
706
|
+
* // => true
|
|
707
|
+
*
|
|
708
|
+
* _.isObject([1, 2, 3]);
|
|
709
|
+
* // => true
|
|
710
|
+
*
|
|
711
|
+
* _.isObject(_.noop);
|
|
712
|
+
* // => true
|
|
713
|
+
*
|
|
714
|
+
* _.isObject(null);
|
|
715
|
+
* // => false
|
|
716
|
+
*/
|
|
717
|
+
function isObject$1(value) {
|
|
718
|
+
var type = typeof value;
|
|
719
|
+
return value != null && (type == 'object' || type == 'function');
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
var isObject_1 = isObject$1;
|
|
723
|
+
|
|
724
|
+
/** Used as references for various `Number` constants. */
|
|
725
|
+
var NAN = 0 / 0;
|
|
726
|
+
|
|
727
|
+
/** Used to detect bad signed hexadecimal string values. */
|
|
728
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
729
|
+
|
|
730
|
+
/** Used to detect binary string values. */
|
|
731
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
732
|
+
|
|
733
|
+
/** Used to detect octal string values. */
|
|
734
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
735
|
+
|
|
736
|
+
/** Built-in method references without a dependency on `root`. */
|
|
737
|
+
var freeParseInt = parseInt;
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Converts `value` to a number.
|
|
741
|
+
*
|
|
742
|
+
* @static
|
|
743
|
+
* @memberOf _
|
|
744
|
+
* @since 4.0.0
|
|
745
|
+
* @category Lang
|
|
746
|
+
* @param {*} value The value to process.
|
|
747
|
+
* @returns {number} Returns the number.
|
|
748
|
+
* @example
|
|
749
|
+
*
|
|
750
|
+
* _.toNumber(3.2);
|
|
751
|
+
* // => 3.2
|
|
752
|
+
*
|
|
753
|
+
* _.toNumber(Number.MIN_VALUE);
|
|
754
|
+
* // => 5e-324
|
|
755
|
+
*
|
|
756
|
+
* _.toNumber(Infinity);
|
|
757
|
+
* // => Infinity
|
|
758
|
+
*
|
|
759
|
+
* _.toNumber('3.2');
|
|
760
|
+
* // => 3.2
|
|
761
|
+
*/
|
|
762
|
+
function toNumber(value) {
|
|
763
|
+
if (typeof value == 'number') {
|
|
764
|
+
return value;
|
|
765
|
+
}
|
|
766
|
+
if (isSymbol_1(value)) {
|
|
767
|
+
return NAN;
|
|
768
|
+
}
|
|
769
|
+
if (isObject_1(value)) {
|
|
770
|
+
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
771
|
+
value = isObject_1(other) ? (other + '') : other;
|
|
772
|
+
}
|
|
773
|
+
if (typeof value != 'string') {
|
|
774
|
+
return value === 0 ? value : +value;
|
|
775
|
+
}
|
|
776
|
+
value = _baseTrim(value);
|
|
777
|
+
var isBinary = reIsBinary.test(value);
|
|
778
|
+
return (isBinary || reIsOctal.test(value))
|
|
779
|
+
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
780
|
+
: (reIsBadHex.test(value) ? NAN : +value);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
var toNumber_1 = toNumber;
|
|
784
|
+
|
|
785
|
+
/** Used as references for various `Number` constants. */
|
|
786
|
+
var INFINITY = 1 / 0,
|
|
787
|
+
MAX_INTEGER = 1.7976931348623157e+308;
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Converts `value` to a finite number.
|
|
791
|
+
*
|
|
792
|
+
* @static
|
|
793
|
+
* @memberOf _
|
|
794
|
+
* @since 4.12.0
|
|
795
|
+
* @category Lang
|
|
796
|
+
* @param {*} value The value to convert.
|
|
797
|
+
* @returns {number} Returns the converted number.
|
|
798
|
+
* @example
|
|
799
|
+
*
|
|
800
|
+
* _.toFinite(3.2);
|
|
801
|
+
* // => 3.2
|
|
802
|
+
*
|
|
803
|
+
* _.toFinite(Number.MIN_VALUE);
|
|
804
|
+
* // => 5e-324
|
|
805
|
+
*
|
|
806
|
+
* _.toFinite(Infinity);
|
|
807
|
+
* // => 1.7976931348623157e+308
|
|
808
|
+
*
|
|
809
|
+
* _.toFinite('3.2');
|
|
810
|
+
* // => 3.2
|
|
811
|
+
*/
|
|
812
|
+
function toFinite(value) {
|
|
813
|
+
if (!value) {
|
|
814
|
+
return value === 0 ? value : 0;
|
|
815
|
+
}
|
|
816
|
+
value = toNumber_1(value);
|
|
817
|
+
if (value === INFINITY || value === -INFINITY) {
|
|
818
|
+
var sign = (value < 0 ? -1 : 1);
|
|
819
|
+
return sign * MAX_INTEGER;
|
|
820
|
+
}
|
|
821
|
+
return value === value ? value : 0;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
var toFinite_1 = toFinite;
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Converts `value` to an integer.
|
|
828
|
+
*
|
|
829
|
+
* **Note:** This method is loosely based on
|
|
830
|
+
* [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
|
|
831
|
+
*
|
|
832
|
+
* @static
|
|
833
|
+
* @memberOf _
|
|
834
|
+
* @since 4.0.0
|
|
835
|
+
* @category Lang
|
|
836
|
+
* @param {*} value The value to convert.
|
|
837
|
+
* @returns {number} Returns the converted integer.
|
|
838
|
+
* @example
|
|
839
|
+
*
|
|
840
|
+
* _.toInteger(3.2);
|
|
841
|
+
* // => 3
|
|
842
|
+
*
|
|
843
|
+
* _.toInteger(Number.MIN_VALUE);
|
|
844
|
+
* // => 0
|
|
845
|
+
*
|
|
846
|
+
* _.toInteger(Infinity);
|
|
847
|
+
* // => 1.7976931348623157e+308
|
|
848
|
+
*
|
|
849
|
+
* _.toInteger('3.2');
|
|
850
|
+
* // => 3
|
|
851
|
+
*/
|
|
852
|
+
function toInteger(value) {
|
|
853
|
+
var result = toFinite_1(value),
|
|
854
|
+
remainder = result % 1;
|
|
855
|
+
|
|
856
|
+
return result === result ? (remainder ? result - remainder : result) : 0;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
var toInteger_1 = toInteger;
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* Pads `string` on the left side if it's shorter than `length`. Padding
|
|
863
|
+
* characters are truncated if they exceed `length`.
|
|
864
|
+
*
|
|
865
|
+
* @static
|
|
866
|
+
* @memberOf _
|
|
867
|
+
* @since 4.0.0
|
|
868
|
+
* @category String
|
|
869
|
+
* @param {string} [string=''] The string to pad.
|
|
870
|
+
* @param {number} [length=0] The padding length.
|
|
871
|
+
* @param {string} [chars=' '] The string used as padding.
|
|
872
|
+
* @returns {string} Returns the padded string.
|
|
873
|
+
* @example
|
|
874
|
+
*
|
|
875
|
+
* _.padStart('abc', 6);
|
|
876
|
+
* // => ' abc'
|
|
877
|
+
*
|
|
878
|
+
* _.padStart('abc', 6, '_-');
|
|
879
|
+
* // => '_-_abc'
|
|
880
|
+
*
|
|
881
|
+
* _.padStart('abc', 3);
|
|
882
|
+
* // => 'abc'
|
|
883
|
+
*/
|
|
884
|
+
function padStart(string, length, chars) {
|
|
885
|
+
string = toString_1(string);
|
|
886
|
+
length = toInteger_1(length);
|
|
887
|
+
|
|
888
|
+
var strLength = length ? _stringSize(string) : 0;
|
|
889
|
+
return (length && strLength < length)
|
|
890
|
+
? (_createPadding(length - strLength, chars) + string)
|
|
891
|
+
: string;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
var padStart_1 = padStart;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Converts the first character of `string` to upper case and the remaining
|
|
898
|
+
* to lower case.
|
|
899
|
+
*
|
|
900
|
+
* @static
|
|
901
|
+
* @memberOf _
|
|
902
|
+
* @since 3.0.0
|
|
903
|
+
* @category String
|
|
904
|
+
* @param {string} [string=''] The string to capitalize.
|
|
905
|
+
* @returns {string} Returns the capitalized string.
|
|
906
|
+
* @example
|
|
907
|
+
*
|
|
908
|
+
* _.capitalize('FRED');
|
|
909
|
+
* // => 'Fred'
|
|
910
|
+
*/
|
|
911
|
+
function capitalize(string) {
|
|
912
|
+
return upperFirst_1(toString_1(string).toLowerCase());
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
var capitalize_1 = capitalize;
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* The base implementation of `_.propertyOf` without support for deep paths.
|
|
919
|
+
*
|
|
920
|
+
* @private
|
|
921
|
+
* @param {Object} object The object to query.
|
|
922
|
+
* @returns {Function} Returns the new accessor function.
|
|
923
|
+
*/
|
|
924
|
+
function basePropertyOf(object) {
|
|
925
|
+
return function(key) {
|
|
926
|
+
return object == null ? undefined : object[key];
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
var _basePropertyOf = basePropertyOf;
|
|
931
|
+
|
|
932
|
+
/** Used to map characters to HTML entities. */
|
|
933
|
+
var htmlEscapes = {
|
|
934
|
+
'&': '&',
|
|
935
|
+
'<': '<',
|
|
936
|
+
'>': '>',
|
|
937
|
+
'"': '"',
|
|
938
|
+
"'": '''
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Used by `_.escape` to convert characters to HTML entities.
|
|
943
|
+
*
|
|
944
|
+
* @private
|
|
945
|
+
* @param {string} chr The matched character to escape.
|
|
946
|
+
* @returns {string} Returns the escaped character.
|
|
947
|
+
*/
|
|
948
|
+
var escapeHtmlChar = _basePropertyOf(htmlEscapes);
|
|
949
|
+
|
|
950
|
+
var _escapeHtmlChar = escapeHtmlChar;
|
|
951
|
+
|
|
952
|
+
/** Used to match HTML entities and HTML characters. */
|
|
953
|
+
var reUnescapedHtml = /[&<>"']/g,
|
|
954
|
+
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
|
958
|
+
* corresponding HTML entities.
|
|
959
|
+
*
|
|
960
|
+
* **Note:** No other characters are escaped. To escape additional
|
|
961
|
+
* characters use a third-party library like [_he_](https://mths.be/he).
|
|
962
|
+
*
|
|
963
|
+
* Though the ">" character is escaped for symmetry, characters like
|
|
964
|
+
* ">" and "/" don't need escaping in HTML and have no special meaning
|
|
965
|
+
* unless they're part of a tag or unquoted attribute value. See
|
|
966
|
+
* [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
|
|
967
|
+
* (under "semi-related fun fact") for more details.
|
|
968
|
+
*
|
|
969
|
+
* When working with HTML you should always
|
|
970
|
+
* [quote attribute values](http://wonko.com/post/html-escaping) to reduce
|
|
971
|
+
* XSS vectors.
|
|
972
|
+
*
|
|
973
|
+
* @static
|
|
974
|
+
* @since 0.1.0
|
|
975
|
+
* @memberOf _
|
|
976
|
+
* @category String
|
|
977
|
+
* @param {string} [string=''] The string to escape.
|
|
978
|
+
* @returns {string} Returns the escaped string.
|
|
979
|
+
* @example
|
|
980
|
+
*
|
|
981
|
+
* _.escape('fred, barney, & pebbles');
|
|
982
|
+
* // => 'fred, barney, & pebbles'
|
|
983
|
+
*/
|
|
984
|
+
function escape(string) {
|
|
985
|
+
string = toString_1(string);
|
|
986
|
+
return (string && reHasUnescapedHtml.test(string))
|
|
987
|
+
? string.replace(reUnescapedHtml, _escapeHtmlChar)
|
|
988
|
+
: string;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
var _escape = escape;
|
|
992
|
+
|
|
993
|
+
/** `Object#toString` result references. */
|
|
994
|
+
var regexpTag = '[object RegExp]';
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* The base implementation of `_.isRegExp` without Node.js optimizations.
|
|
998
|
+
*
|
|
999
|
+
* @private
|
|
1000
|
+
* @param {*} value The value to check.
|
|
1001
|
+
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
|
|
1002
|
+
*/
|
|
1003
|
+
function baseIsRegExp(value) {
|
|
1004
|
+
return isObjectLike_1(value) && _baseGetTag(value) == regexpTag;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
var _baseIsRegExp = baseIsRegExp;
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* The base implementation of `_.unary` without support for storing metadata.
|
|
1011
|
+
*
|
|
1012
|
+
* @private
|
|
1013
|
+
* @param {Function} func The function to cap arguments for.
|
|
1014
|
+
* @returns {Function} Returns the new capped function.
|
|
1015
|
+
*/
|
|
1016
|
+
function baseUnary(func) {
|
|
1017
|
+
return function(value) {
|
|
1018
|
+
return func(value);
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
var _baseUnary = baseUnary;
|
|
1023
|
+
|
|
1024
|
+
var _nodeUtil = createCommonjsModule(function (module, exports) {
|
|
1025
|
+
/** Detect free variable `exports`. */
|
|
1026
|
+
var freeExports = exports && !exports.nodeType && exports;
|
|
1027
|
+
|
|
1028
|
+
/** Detect free variable `module`. */
|
|
1029
|
+
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
1030
|
+
|
|
1031
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1032
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
1033
|
+
|
|
1034
|
+
/** Detect free variable `process` from Node.js. */
|
|
1035
|
+
var freeProcess = moduleExports && _freeGlobal.process;
|
|
1036
|
+
|
|
1037
|
+
/** Used to access faster Node.js helpers. */
|
|
1038
|
+
var nodeUtil = (function() {
|
|
1039
|
+
try {
|
|
1040
|
+
// Use `util.types` for Node.js 10+.
|
|
1041
|
+
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
1042
|
+
|
|
1043
|
+
if (types) {
|
|
1044
|
+
return types;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
// Legacy `process.binding('util')` for Node.js < 10.
|
|
1048
|
+
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
1049
|
+
} catch (e) {}
|
|
1050
|
+
}());
|
|
1051
|
+
|
|
1052
|
+
module.exports = nodeUtil;
|
|
1053
|
+
});
|
|
1054
|
+
|
|
1055
|
+
/* Node.js helper references. */
|
|
1056
|
+
var nodeIsRegExp = _nodeUtil && _nodeUtil.isRegExp;
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Checks if `value` is classified as a `RegExp` object.
|
|
1060
|
+
*
|
|
1061
|
+
* @static
|
|
1062
|
+
* @memberOf _
|
|
1063
|
+
* @since 0.1.0
|
|
1064
|
+
* @category Lang
|
|
1065
|
+
* @param {*} value The value to check.
|
|
1066
|
+
* @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
|
|
1067
|
+
* @example
|
|
1068
|
+
*
|
|
1069
|
+
* _.isRegExp(/abc/);
|
|
1070
|
+
* // => true
|
|
1071
|
+
*
|
|
1072
|
+
* _.isRegExp('/abc/');
|
|
1073
|
+
* // => false
|
|
1074
|
+
*/
|
|
1075
|
+
var isRegExp = nodeIsRegExp ? _baseUnary(nodeIsRegExp) : _baseIsRegExp;
|
|
1076
|
+
|
|
1077
|
+
var isRegExp_1 = isRegExp;
|
|
1078
|
+
|
|
1079
|
+
/** Used as default options for `_.truncate`. */
|
|
1080
|
+
var DEFAULT_TRUNC_LENGTH = 30,
|
|
1081
|
+
DEFAULT_TRUNC_OMISSION = '...';
|
|
1082
|
+
|
|
1083
|
+
/** Used to match `RegExp` flags from their coerced string values. */
|
|
1084
|
+
var reFlags = /\w*$/;
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* Truncates `string` if it's longer than the given maximum string length.
|
|
1088
|
+
* The last characters of the truncated string are replaced with the omission
|
|
1089
|
+
* string which defaults to "...".
|
|
1090
|
+
*
|
|
1091
|
+
* @static
|
|
1092
|
+
* @memberOf _
|
|
1093
|
+
* @since 4.0.0
|
|
1094
|
+
* @category String
|
|
1095
|
+
* @param {string} [string=''] The string to truncate.
|
|
1096
|
+
* @param {Object} [options={}] The options object.
|
|
1097
|
+
* @param {number} [options.length=30] The maximum string length.
|
|
1098
|
+
* @param {string} [options.omission='...'] The string to indicate text is omitted.
|
|
1099
|
+
* @param {RegExp|string} [options.separator] The separator pattern to truncate to.
|
|
1100
|
+
* @returns {string} Returns the truncated string.
|
|
1101
|
+
* @example
|
|
1102
|
+
*
|
|
1103
|
+
* _.truncate('hi-diddly-ho there, neighborino');
|
|
1104
|
+
* // => 'hi-diddly-ho there, neighbo...'
|
|
1105
|
+
*
|
|
1106
|
+
* _.truncate('hi-diddly-ho there, neighborino', {
|
|
1107
|
+
* 'length': 24,
|
|
1108
|
+
* 'separator': ' '
|
|
1109
|
+
* });
|
|
1110
|
+
* // => 'hi-diddly-ho there,...'
|
|
1111
|
+
*
|
|
1112
|
+
* _.truncate('hi-diddly-ho there, neighborino', {
|
|
1113
|
+
* 'length': 24,
|
|
1114
|
+
* 'separator': /,? +/
|
|
1115
|
+
* });
|
|
1116
|
+
* // => 'hi-diddly-ho there...'
|
|
1117
|
+
*
|
|
1118
|
+
* _.truncate('hi-diddly-ho there, neighborino', {
|
|
1119
|
+
* 'omission': ' [...]'
|
|
1120
|
+
* });
|
|
1121
|
+
* // => 'hi-diddly-ho there, neig [...]'
|
|
1122
|
+
*/
|
|
1123
|
+
function truncate(string, options) {
|
|
1124
|
+
var length = DEFAULT_TRUNC_LENGTH,
|
|
1125
|
+
omission = DEFAULT_TRUNC_OMISSION;
|
|
1126
|
+
|
|
1127
|
+
if (isObject_1(options)) {
|
|
1128
|
+
var separator = 'separator' in options ? options.separator : separator;
|
|
1129
|
+
length = 'length' in options ? toInteger_1(options.length) : length;
|
|
1130
|
+
omission = 'omission' in options ? _baseToString(options.omission) : omission;
|
|
1131
|
+
}
|
|
1132
|
+
string = toString_1(string);
|
|
1133
|
+
|
|
1134
|
+
var strLength = string.length;
|
|
1135
|
+
if (_hasUnicode(string)) {
|
|
1136
|
+
var strSymbols = _stringToArray(string);
|
|
1137
|
+
strLength = strSymbols.length;
|
|
1138
|
+
}
|
|
1139
|
+
if (length >= strLength) {
|
|
1140
|
+
return string;
|
|
1141
|
+
}
|
|
1142
|
+
var end = length - _stringSize(omission);
|
|
1143
|
+
if (end < 1) {
|
|
1144
|
+
return omission;
|
|
1145
|
+
}
|
|
1146
|
+
var result = strSymbols
|
|
1147
|
+
? _castSlice(strSymbols, 0, end).join('')
|
|
1148
|
+
: string.slice(0, end);
|
|
1149
|
+
|
|
1150
|
+
if (separator === undefined) {
|
|
1151
|
+
return result + omission;
|
|
1152
|
+
}
|
|
1153
|
+
if (strSymbols) {
|
|
1154
|
+
end += (result.length - end);
|
|
1155
|
+
}
|
|
1156
|
+
if (isRegExp_1(separator)) {
|
|
1157
|
+
if (string.slice(end).search(separator)) {
|
|
1158
|
+
var match,
|
|
1159
|
+
substring = result;
|
|
1160
|
+
|
|
1161
|
+
if (!separator.global) {
|
|
1162
|
+
separator = RegExp(separator.source, toString_1(reFlags.exec(separator)) + 'g');
|
|
1163
|
+
}
|
|
1164
|
+
separator.lastIndex = 0;
|
|
1165
|
+
while ((match = separator.exec(substring))) {
|
|
1166
|
+
var newEnd = match.index;
|
|
1167
|
+
}
|
|
1168
|
+
result = result.slice(0, newEnd === undefined ? end : newEnd);
|
|
1169
|
+
}
|
|
1170
|
+
} else if (string.indexOf(_baseToString(separator), end) != end) {
|
|
1171
|
+
var index = result.lastIndexOf(separator);
|
|
1172
|
+
if (index > -1) {
|
|
1173
|
+
result = result.slice(0, index);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
return result + omission;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
var truncate_1 = truncate;
|
|
1180
|
+
|
|
27
1181
|
/**
|
|
28
1182
|
* @file 公式内置函数
|
|
29
1183
|
*/
|
|
@@ -451,7 +1605,8 @@ var Evaluator = /** @class */ (function () {
|
|
|
451
1605
|
*
|
|
452
1606
|
* @example IFS(condition1, result1, condition2, result2,...conditionN, resultN)
|
|
453
1607
|
* @param {...any} args - 条件,返回值集合
|
|
454
|
-
* @
|
|
1608
|
+
* @namespace 逻辑函数
|
|
1609
|
+
* @returns {any} 第一个满足条件的结果,没有命中的返回 false。
|
|
455
1610
|
*/
|
|
456
1611
|
Evaluator.prototype.fnIFS = function () {
|
|
457
1612
|
var args = [];
|
|
@@ -477,7 +1632,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
477
1632
|
* @param {number} num - 数值
|
|
478
1633
|
* @namespace 数学函数
|
|
479
1634
|
*
|
|
480
|
-
* @returns {number}
|
|
1635
|
+
* @returns {number} 传入数值的绝对值
|
|
481
1636
|
*/
|
|
482
1637
|
Evaluator.prototype.fnABS = function (a) {
|
|
483
1638
|
a = this.formatNumber(a);
|
|
@@ -490,7 +1645,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
490
1645
|
* @param {...number} num - 数值
|
|
491
1646
|
* @namespace 数学函数
|
|
492
1647
|
*
|
|
493
|
-
* @returns {number}
|
|
1648
|
+
* @returns {number} 所有传入值中最大的那个
|
|
494
1649
|
*/
|
|
495
1650
|
Evaluator.prototype.fnMAX = function () {
|
|
496
1651
|
var _this = this;
|
|
@@ -507,7 +1662,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
507
1662
|
* @param {...number} num - 数值
|
|
508
1663
|
* @namespace 数学函数
|
|
509
1664
|
*
|
|
510
|
-
* @returns {number}
|
|
1665
|
+
* @returns {number} 所有传入值中最小的那个
|
|
511
1666
|
*/
|
|
512
1667
|
Evaluator.prototype.fnMIN = function () {
|
|
513
1668
|
var _this = this;
|
|
@@ -524,7 +1679,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
524
1679
|
* @param {...number} num - 数值
|
|
525
1680
|
* @namespace 数学函数
|
|
526
1681
|
*
|
|
527
|
-
* @returns {number}
|
|
1682
|
+
* @returns {number} 所有传入数值的总和
|
|
528
1683
|
*/
|
|
529
1684
|
Evaluator.prototype.fnSUM = function () {
|
|
530
1685
|
var _this = this;
|
|
@@ -541,7 +1696,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
541
1696
|
* @param {number} num - 数值
|
|
542
1697
|
* @namespace 数学函数
|
|
543
1698
|
*
|
|
544
|
-
* @returns {number}
|
|
1699
|
+
* @returns {number} 数值对应的整形
|
|
545
1700
|
*/
|
|
546
1701
|
Evaluator.prototype.fnINT = function (n) {
|
|
547
1702
|
return Math.floor(this.formatNumber(n));
|
|
@@ -554,7 +1709,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
554
1709
|
* @param {number} divisor - 除数
|
|
555
1710
|
* @namespace 数学函数
|
|
556
1711
|
*
|
|
557
|
-
* @returns {number}
|
|
1712
|
+
* @returns {number} 两数相除的余数
|
|
558
1713
|
*/
|
|
559
1714
|
Evaluator.prototype.fnMOD = function (a, b) {
|
|
560
1715
|
return this.formatNumber(a) % this.formatNumber(b);
|
|
@@ -565,7 +1720,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
565
1720
|
* @example PI()
|
|
566
1721
|
* @namespace 数学函数
|
|
567
1722
|
*
|
|
568
|
-
* @returns {number}
|
|
1723
|
+
* @returns {number} 圆周率数值
|
|
569
1724
|
*/
|
|
570
1725
|
Evaluator.prototype.fnPI = function () {
|
|
571
1726
|
return Math.PI;
|
|
@@ -578,7 +1733,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
578
1733
|
* @param {number} numDigits - 小数位数
|
|
579
1734
|
* @namespace 数学函数
|
|
580
1735
|
*
|
|
581
|
-
* @returns {number}
|
|
1736
|
+
* @returns {number} 传入数值四舍五入后的结果
|
|
582
1737
|
*/
|
|
583
1738
|
Evaluator.prototype.fnROUND = function (a, b) {
|
|
584
1739
|
a = this.formatNumber(a);
|
|
@@ -598,7 +1753,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
598
1753
|
* @param {number} numDigits - 小数位数
|
|
599
1754
|
* @namespace 数学函数
|
|
600
1755
|
*
|
|
601
|
-
* @returns {number}
|
|
1756
|
+
* @returns {number} 传入数值向下取整后的结果
|
|
602
1757
|
*/
|
|
603
1758
|
Evaluator.prototype.fnFLOOR = function (a, b) {
|
|
604
1759
|
a = this.formatNumber(a);
|
|
@@ -618,7 +1773,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
618
1773
|
* @param {number} numDigits - 小数位数
|
|
619
1774
|
* @namespace 数学函数
|
|
620
1775
|
*
|
|
621
|
-
* @returns {number}
|
|
1776
|
+
* @returns {number} 传入数值向上取整后的结果
|
|
622
1777
|
*/
|
|
623
1778
|
Evaluator.prototype.fnCEIL = function (a, b) {
|
|
624
1779
|
a = this.formatNumber(a);
|
|
@@ -637,7 +1792,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
637
1792
|
* @param {number} num - 要处理的数字
|
|
638
1793
|
* @namespace 数学函数
|
|
639
1794
|
*
|
|
640
|
-
* @returns {number}
|
|
1795
|
+
* @returns {number} 开平方的结果
|
|
641
1796
|
*/
|
|
642
1797
|
Evaluator.prototype.fnSQRT = function (n) {
|
|
643
1798
|
return Math.sqrt(this.formatNumber(n));
|
|
@@ -649,7 +1804,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
649
1804
|
* @param {...number} num - 要处理的数字
|
|
650
1805
|
* @namespace 数学函数
|
|
651
1806
|
*
|
|
652
|
-
* @returns {number}
|
|
1807
|
+
* @returns {number} 所有数值的平均值
|
|
653
1808
|
*/
|
|
654
1809
|
Evaluator.prototype.fnAVG = function () {
|
|
655
1810
|
var _this = this;
|
|
@@ -659,6 +1814,111 @@ var Evaluator = /** @class */ (function () {
|
|
|
659
1814
|
}
|
|
660
1815
|
return (this.fnSUM.apply(this, args.map(function (item) { return _this.formatNumber(item); })) / args.length);
|
|
661
1816
|
};
|
|
1817
|
+
/**
|
|
1818
|
+
* 返回数据点与数据均值点之差(数据偏差)的平方和
|
|
1819
|
+
*
|
|
1820
|
+
* @example DEVSQ(num1, num2, ...numN)
|
|
1821
|
+
* @param {...number} num - 要处理的数字
|
|
1822
|
+
* @namespace 数学函数
|
|
1823
|
+
*
|
|
1824
|
+
* @returns {number} 所有数值的平均值
|
|
1825
|
+
*/
|
|
1826
|
+
Evaluator.prototype.fnDEVSQ = function () {
|
|
1827
|
+
var _this = this;
|
|
1828
|
+
var args = [];
|
|
1829
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1830
|
+
args[_i] = arguments[_i];
|
|
1831
|
+
}
|
|
1832
|
+
if (args.length === 0) {
|
|
1833
|
+
return null;
|
|
1834
|
+
}
|
|
1835
|
+
var nums = args.map(function (item) { return _this.formatNumber(item); });
|
|
1836
|
+
var sum = nums.reduce(function (sum, a) { return sum + a || 0; }, 0);
|
|
1837
|
+
var mean = sum / nums.length;
|
|
1838
|
+
var result = 0;
|
|
1839
|
+
for (var _a = 0, nums_1 = nums; _a < nums_1.length; _a++) {
|
|
1840
|
+
var num = nums_1[_a];
|
|
1841
|
+
result += Math.pow(num - mean, 2);
|
|
1842
|
+
}
|
|
1843
|
+
return result;
|
|
1844
|
+
};
|
|
1845
|
+
/**
|
|
1846
|
+
* 数据点到其算术平均值的绝对偏差的平均值
|
|
1847
|
+
*
|
|
1848
|
+
* @example AVEDEV(num1, num2, ...numN)
|
|
1849
|
+
* @param {...number} num - 要处理的数字
|
|
1850
|
+
* @namespace 数学函数
|
|
1851
|
+
*
|
|
1852
|
+
* @returns {number} 所有数值的平均值
|
|
1853
|
+
*/
|
|
1854
|
+
Evaluator.prototype.fnAVEDEV = function () {
|
|
1855
|
+
var _this = this;
|
|
1856
|
+
var args = [];
|
|
1857
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1858
|
+
args[_i] = arguments[_i];
|
|
1859
|
+
}
|
|
1860
|
+
if (args.length === 0) {
|
|
1861
|
+
return null;
|
|
1862
|
+
}
|
|
1863
|
+
var nums = args.map(function (item) { return _this.formatNumber(item); });
|
|
1864
|
+
var sum = nums.reduce(function (sum, a) { return sum + a || 0; }, 0);
|
|
1865
|
+
var mean = sum / nums.length;
|
|
1866
|
+
var result = 0;
|
|
1867
|
+
for (var _a = 0, nums_2 = nums; _a < nums_2.length; _a++) {
|
|
1868
|
+
var num = nums_2[_a];
|
|
1869
|
+
result += Math.abs(num - mean);
|
|
1870
|
+
}
|
|
1871
|
+
return result / nums.length;
|
|
1872
|
+
};
|
|
1873
|
+
/**
|
|
1874
|
+
* 数据点的调和平均值
|
|
1875
|
+
*
|
|
1876
|
+
* @example HARMEAN(num1, num2, ...numN)
|
|
1877
|
+
* @param {...number} num - 要处理的数字
|
|
1878
|
+
* @namespace 数学函数
|
|
1879
|
+
*
|
|
1880
|
+
* @returns {number} 所有数值的平均值
|
|
1881
|
+
*/
|
|
1882
|
+
Evaluator.prototype.fnHARMEAN = function () {
|
|
1883
|
+
var _this = this;
|
|
1884
|
+
var args = [];
|
|
1885
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1886
|
+
args[_i] = arguments[_i];
|
|
1887
|
+
}
|
|
1888
|
+
if (args.length === 0) {
|
|
1889
|
+
return null;
|
|
1890
|
+
}
|
|
1891
|
+
var nums = args.map(function (item) { return _this.formatNumber(item); });
|
|
1892
|
+
var den = 0;
|
|
1893
|
+
for (var _a = 0, nums_3 = nums; _a < nums_3.length; _a++) {
|
|
1894
|
+
var num = nums_3[_a];
|
|
1895
|
+
den += 1 / num;
|
|
1896
|
+
}
|
|
1897
|
+
return nums.length / den;
|
|
1898
|
+
};
|
|
1899
|
+
/**
|
|
1900
|
+
* 数据集中第 k 个最大值
|
|
1901
|
+
*
|
|
1902
|
+
* @example LARGE(array, k)
|
|
1903
|
+
* @param {array} nums - 要处理的数字
|
|
1904
|
+
* @param {number} k - 第几大
|
|
1905
|
+
* @namespace 数学函数
|
|
1906
|
+
*
|
|
1907
|
+
* @returns {number} 所有数值的平均值
|
|
1908
|
+
*/
|
|
1909
|
+
Evaluator.prototype.fnLARGE = function (nums, k) {
|
|
1910
|
+
var _this = this;
|
|
1911
|
+
if (nums.length === 0) {
|
|
1912
|
+
return null;
|
|
1913
|
+
}
|
|
1914
|
+
var numsFormat = nums.map(function (item) { return _this.formatNumber(item); });
|
|
1915
|
+
if (k < 0 || numsFormat.length < k) {
|
|
1916
|
+
return null;
|
|
1917
|
+
}
|
|
1918
|
+
return numsFormat.sort(function (a, b) {
|
|
1919
|
+
return b - a;
|
|
1920
|
+
})[k - 1];
|
|
1921
|
+
};
|
|
662
1922
|
/**
|
|
663
1923
|
* 将数值转为中文大写金额
|
|
664
1924
|
*
|
|
@@ -666,7 +1926,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
666
1926
|
* @param {number} num - 要处理的数字
|
|
667
1927
|
* @namespace 数学函数
|
|
668
1928
|
*
|
|
669
|
-
* @returns {string}
|
|
1929
|
+
* @returns {string} 数值中文大写字符
|
|
670
1930
|
*/
|
|
671
1931
|
Evaluator.prototype.fnUPPERMONEY = function (n) {
|
|
672
1932
|
n = this.formatNumber(n);
|
|
@@ -708,7 +1968,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
708
1968
|
* @example RAND()
|
|
709
1969
|
* @namespace 数学函数
|
|
710
1970
|
*
|
|
711
|
-
* @returns {number}
|
|
1971
|
+
* @returns {number} 随机数
|
|
712
1972
|
*/
|
|
713
1973
|
Evaluator.prototype.fnRAND = function () {
|
|
714
1974
|
return Math.random();
|
|
@@ -768,7 +2028,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
768
2028
|
* @param {string[]} textArr - 要处理的文本集合
|
|
769
2029
|
* @namespace 文本函数
|
|
770
2030
|
*
|
|
771
|
-
* @returns {number[]}
|
|
2031
|
+
* @returns {number[]} 长度集合
|
|
772
2032
|
*/
|
|
773
2033
|
Evaluator.prototype.fnLENGTH = function () {
|
|
774
2034
|
var args = [];
|
|
@@ -784,7 +2044,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
784
2044
|
* @param {string} text - 要处理的文本
|
|
785
2045
|
* @namespace 文本函数
|
|
786
2046
|
*
|
|
787
|
-
* @returns {boolean}
|
|
2047
|
+
* @returns {boolean} 判断结果
|
|
788
2048
|
*/
|
|
789
2049
|
Evaluator.prototype.fnISEMPTY = function (text) {
|
|
790
2050
|
return !text || !String(text).trim();
|
|
@@ -796,7 +2056,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
796
2056
|
* @param {...string} text - 文本集合
|
|
797
2057
|
* @namespace 文本函数
|
|
798
2058
|
*
|
|
799
|
-
* @returns {string}
|
|
2059
|
+
* @returns {string} 连接后的文本
|
|
800
2060
|
*/
|
|
801
2061
|
Evaluator.prototype.fnCONCATENATE = function () {
|
|
802
2062
|
var args = [];
|
|
@@ -814,7 +2074,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
814
2074
|
* @param {number} code - 编码值
|
|
815
2075
|
* @namespace 文本函数
|
|
816
2076
|
*
|
|
817
|
-
* @returns {string}
|
|
2077
|
+
* @returns {string} 指定位置的字符
|
|
818
2078
|
*/
|
|
819
2079
|
Evaluator.prototype.fnCHAR = function (code) {
|
|
820
2080
|
return String.fromCharCode(code);
|
|
@@ -826,7 +2086,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
826
2086
|
* @param {string} text - 文本
|
|
827
2087
|
* @namespace 文本函数
|
|
828
2088
|
*
|
|
829
|
-
* @returns {string}
|
|
2089
|
+
* @returns {string} 结果文本
|
|
830
2090
|
*/
|
|
831
2091
|
Evaluator.prototype.fnLOWER = function (text) {
|
|
832
2092
|
text = this.normalizeText(text);
|
|
@@ -839,12 +2099,111 @@ var Evaluator = /** @class */ (function () {
|
|
|
839
2099
|
* @param {string} text - 文本
|
|
840
2100
|
* @namespace 文本函数
|
|
841
2101
|
*
|
|
842
|
-
* @returns {string}
|
|
2102
|
+
* @returns {string} 结果文本
|
|
843
2103
|
*/
|
|
844
2104
|
Evaluator.prototype.fnUPPER = function (text) {
|
|
845
2105
|
text = this.normalizeText(text);
|
|
846
2106
|
return text.toUpperCase();
|
|
847
2107
|
};
|
|
2108
|
+
/**
|
|
2109
|
+
* 将传入文本首字母转成大写
|
|
2110
|
+
*
|
|
2111
|
+
* @example UPPERFIRST(text)
|
|
2112
|
+
* @param {string} text - 文本
|
|
2113
|
+
* @namespace 文本函数
|
|
2114
|
+
*
|
|
2115
|
+
* @returns {string} 结果文本
|
|
2116
|
+
*/
|
|
2117
|
+
Evaluator.prototype.fnUPPERFIRST = function (text) {
|
|
2118
|
+
text = this.normalizeText(text);
|
|
2119
|
+
return upperFirst_1(text);
|
|
2120
|
+
};
|
|
2121
|
+
/**
|
|
2122
|
+
* 向前补齐文本长度
|
|
2123
|
+
*
|
|
2124
|
+
* 示例 `PADSTART("6", 2, "0")`
|
|
2125
|
+
*
|
|
2126
|
+
* 返回 `06`
|
|
2127
|
+
*
|
|
2128
|
+
* @example PADSTART(text)
|
|
2129
|
+
* @param {string} text - 文本
|
|
2130
|
+
* @param {number} num - 目标长度
|
|
2131
|
+
* @param {string} pad - 用于补齐的文本
|
|
2132
|
+
* @namespace 文本函数
|
|
2133
|
+
*
|
|
2134
|
+
* @returns {string} 结果文本
|
|
2135
|
+
*/
|
|
2136
|
+
Evaluator.prototype.fnPADSTART = function (text, num, pad) {
|
|
2137
|
+
text = this.normalizeText(text);
|
|
2138
|
+
return padStart_1(text, num, pad);
|
|
2139
|
+
};
|
|
2140
|
+
/**
|
|
2141
|
+
* 将文本转成标题
|
|
2142
|
+
*
|
|
2143
|
+
* 示例 `CAPITALIZE("star")`
|
|
2144
|
+
*
|
|
2145
|
+
* 返回 `Star`
|
|
2146
|
+
*
|
|
2147
|
+
* @example CAPITALIZE(text)
|
|
2148
|
+
* @param {string} text - 文本
|
|
2149
|
+
* @namespace 文本函数
|
|
2150
|
+
*
|
|
2151
|
+
* @returns {string} 结果文本
|
|
2152
|
+
*/
|
|
2153
|
+
Evaluator.prototype.fnCAPITALIZE = function (text) {
|
|
2154
|
+
text = this.normalizeText(text);
|
|
2155
|
+
return capitalize_1(text);
|
|
2156
|
+
};
|
|
2157
|
+
/**
|
|
2158
|
+
* 对文本进行 HTML 转义
|
|
2159
|
+
*
|
|
2160
|
+
* 示例 `ESCAPE("star")`
|
|
2161
|
+
*
|
|
2162
|
+
* 返回 `Star`
|
|
2163
|
+
*
|
|
2164
|
+
* @example ESCAPE(text)
|
|
2165
|
+
* @param {string} text - 文本
|
|
2166
|
+
* @namespace 文本函数
|
|
2167
|
+
*
|
|
2168
|
+
* @returns {string} 结果文本
|
|
2169
|
+
*/
|
|
2170
|
+
Evaluator.prototype.fnESCAPE = function (text) {
|
|
2171
|
+
text = this.normalizeText(text);
|
|
2172
|
+
return _escape(text);
|
|
2173
|
+
};
|
|
2174
|
+
/**
|
|
2175
|
+
* 对文本长度进行截断
|
|
2176
|
+
*
|
|
2177
|
+
* 示例 `TRUNCATE("amis.baidu.com", 6)`
|
|
2178
|
+
*
|
|
2179
|
+
* 返回 `amis...`
|
|
2180
|
+
*
|
|
2181
|
+
* @example TRUNCATE(text, 6)
|
|
2182
|
+
* @param {string} text - 文本
|
|
2183
|
+
* @param {number} text - 最长长度
|
|
2184
|
+
* @namespace 文本函数
|
|
2185
|
+
*
|
|
2186
|
+
* @returns {string} 结果文本
|
|
2187
|
+
*/
|
|
2188
|
+
Evaluator.prototype.fnTRUNCATE = function (text, length) {
|
|
2189
|
+
text = this.normalizeText(text);
|
|
2190
|
+
return truncate_1(text, { length: length });
|
|
2191
|
+
};
|
|
2192
|
+
/**
|
|
2193
|
+
* 取在某个分隔符之前的所有字符串
|
|
2194
|
+
*
|
|
2195
|
+
* @example BEFORELAST(text, '.')
|
|
2196
|
+
* @param {string} text - 文本
|
|
2197
|
+
* @param {string} delimiter - 结束文本
|
|
2198
|
+
* @namespace 文本函数
|
|
2199
|
+
*
|
|
2200
|
+
* @returns {string} 判断结果
|
|
2201
|
+
*/
|
|
2202
|
+
Evaluator.prototype.fnBEFORELAST = function (text, delimiter) {
|
|
2203
|
+
if (delimiter === void 0) { delimiter = '.'; }
|
|
2204
|
+
text = this.normalizeText(text);
|
|
2205
|
+
return text.split(delimiter).slice(0, -1).join(delimiter) || text + '';
|
|
2206
|
+
};
|
|
848
2207
|
/**
|
|
849
2208
|
* 将文本根据指定片段分割成数组
|
|
850
2209
|
*
|
|
@@ -857,7 +2216,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
857
2216
|
* @param {string} delimiter - 文本片段
|
|
858
2217
|
* @namespace 文本函数
|
|
859
2218
|
*
|
|
860
|
-
* @returns {Array<string>}
|
|
2219
|
+
* @returns {Array<string>} 文本集
|
|
861
2220
|
*/
|
|
862
2221
|
Evaluator.prototype.fnSPLIT = function (text, sep) {
|
|
863
2222
|
if (sep === void 0) { sep = ','; }
|
|
@@ -871,12 +2230,46 @@ var Evaluator = /** @class */ (function () {
|
|
|
871
2230
|
* @param {string} text - 文本
|
|
872
2231
|
* @namespace 文本函数
|
|
873
2232
|
*
|
|
874
|
-
* @returns {string}
|
|
2233
|
+
* @returns {string} 处理后的文本
|
|
875
2234
|
*/
|
|
876
2235
|
Evaluator.prototype.fnTRIM = function (text) {
|
|
877
2236
|
text = this.normalizeText(text);
|
|
878
2237
|
return text.trim();
|
|
879
2238
|
};
|
|
2239
|
+
/**
|
|
2240
|
+
* 去除文本中的 HTML 标签
|
|
2241
|
+
*
|
|
2242
|
+
* 示例:`STRIPTAG("<b>amis</b>")`
|
|
2243
|
+
*
|
|
2244
|
+
* 返回:`amis`
|
|
2245
|
+
*
|
|
2246
|
+
* @example STRIPTAG(text)
|
|
2247
|
+
* @param {string} text - 文本
|
|
2248
|
+
* @namespace 文本函数
|
|
2249
|
+
*
|
|
2250
|
+
* @returns {string} 处理后的文本
|
|
2251
|
+
*/
|
|
2252
|
+
Evaluator.prototype.fnSTRIPTAG = function (text) {
|
|
2253
|
+
text = this.normalizeText(text);
|
|
2254
|
+
return text.replace(/<\/?[^>]+(>|$)/g, '');
|
|
2255
|
+
};
|
|
2256
|
+
/**
|
|
2257
|
+
* 将字符串中的换行转成 HTML `<br>`,用于简单换行的场景
|
|
2258
|
+
*
|
|
2259
|
+
* 示例:`LINEBREAK("\n")`
|
|
2260
|
+
*
|
|
2261
|
+
* 返回:`<br/>`
|
|
2262
|
+
*
|
|
2263
|
+
* @example LINEBREAK(text)
|
|
2264
|
+
* @param {string} text - 文本
|
|
2265
|
+
* @namespace 文本函数
|
|
2266
|
+
*
|
|
2267
|
+
* @returns {string} 处理后的文本
|
|
2268
|
+
*/
|
|
2269
|
+
Evaluator.prototype.fnLINEBREAK = function (text) {
|
|
2270
|
+
text = this.normalizeText(text);
|
|
2271
|
+
return text.replace(/(?:\r\n|\r|\n)/g, '<br/>');
|
|
2272
|
+
};
|
|
880
2273
|
/**
|
|
881
2274
|
* 判断字符串(text)是否以特定字符串(startString)开始,是则返回 True,否则返回 False
|
|
882
2275
|
*
|
|
@@ -885,7 +2278,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
885
2278
|
* @param {string} startString - 起始文本
|
|
886
2279
|
* @namespace 文本函数
|
|
887
2280
|
*
|
|
888
|
-
* @returns {string}
|
|
2281
|
+
* @returns {string} 判断结果
|
|
889
2282
|
*/
|
|
890
2283
|
Evaluator.prototype.fnSTARTSWITH = function (text, search) {
|
|
891
2284
|
if (!search) {
|
|
@@ -894,6 +2287,23 @@ var Evaluator = /** @class */ (function () {
|
|
|
894
2287
|
text = this.normalizeText(text);
|
|
895
2288
|
return text.indexOf(search) === 0;
|
|
896
2289
|
};
|
|
2290
|
+
/**
|
|
2291
|
+
* 判断字符串(text)是否以特定字符串(endString)结束,是则返回 True,否则返回 False
|
|
2292
|
+
*
|
|
2293
|
+
* @example ENDSWITH(text, '片段')
|
|
2294
|
+
* @param {string} text - 文本
|
|
2295
|
+
* @param {string} endString - 结束文本
|
|
2296
|
+
* @namespace 文本函数
|
|
2297
|
+
*
|
|
2298
|
+
* @returns {string} 判断结果
|
|
2299
|
+
*/
|
|
2300
|
+
Evaluator.prototype.fnENDSWITH = function (text, search) {
|
|
2301
|
+
if (!search) {
|
|
2302
|
+
return false;
|
|
2303
|
+
}
|
|
2304
|
+
text = this.normalizeText(text);
|
|
2305
|
+
return text.indexOf(search, text.length - search.length) !== -1;
|
|
2306
|
+
};
|
|
897
2307
|
/**
|
|
898
2308
|
* 判断参数 1 中的文本是否包含参数 2 中的文本。
|
|
899
2309
|
*
|
|
@@ -902,7 +2312,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
902
2312
|
* @param {string} searchText - 搜索文本
|
|
903
2313
|
* @namespace 文本函数
|
|
904
2314
|
*
|
|
905
|
-
* @returns {string}
|
|
2315
|
+
* @returns {string} 判断结果
|
|
906
2316
|
*/
|
|
907
2317
|
Evaluator.prototype.fnCONTAINS = function (text, search) {
|
|
908
2318
|
if (!search) {
|
|
@@ -920,7 +2330,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
920
2330
|
* @param {string} replace - 要替换的文本
|
|
921
2331
|
* @namespace 文本函数
|
|
922
2332
|
*
|
|
923
|
-
* @returns {string}
|
|
2333
|
+
* @returns {string} 处理结果
|
|
924
2334
|
*/
|
|
925
2335
|
Evaluator.prototype.fnREPLACE = function (text, search, replace) {
|
|
926
2336
|
text = this.normalizeText(text);
|
|
@@ -946,7 +2356,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
946
2356
|
* @param {number} start - 起始位置
|
|
947
2357
|
* @namespace 文本函数
|
|
948
2358
|
*
|
|
949
|
-
* @returns {number}
|
|
2359
|
+
* @returns {number} 命中的位置
|
|
950
2360
|
*/
|
|
951
2361
|
Evaluator.prototype.fnSEARCH = function (text, search, start) {
|
|
952
2362
|
if (start === void 0) { start = 0; }
|
|
@@ -967,7 +2377,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
967
2377
|
* @param {number} len - 处理长度
|
|
968
2378
|
* @namespace 文本函数
|
|
969
2379
|
*
|
|
970
|
-
* @returns {number}
|
|
2380
|
+
* @returns {number} 命中的位置
|
|
971
2381
|
*/
|
|
972
2382
|
Evaluator.prototype.fnMID = function (text, from, len) {
|
|
973
2383
|
text = this.normalizeText(text);
|
|
@@ -984,7 +2394,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
984
2394
|
* @example DATE('2021-12-06 08:20:00')
|
|
985
2395
|
* @namespace 日期函数
|
|
986
2396
|
*
|
|
987
|
-
* @returns {Date}
|
|
2397
|
+
* @returns {Date} 日期对象
|
|
988
2398
|
*/
|
|
989
2399
|
Evaluator.prototype.fnDATE = function (year, month, day, hour, minute, second) {
|
|
990
2400
|
if (month === undefined) {
|
|
@@ -1000,7 +2410,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1000
2410
|
* @param {date} date 日期对象
|
|
1001
2411
|
* @param {string} format 时间戳格式,带毫秒传入 'x'。默认为 'X' 不带毫秒的。
|
|
1002
2412
|
*
|
|
1003
|
-
* @returns {number}
|
|
2413
|
+
* @returns {number} 时间戳
|
|
1004
2414
|
*/
|
|
1005
2415
|
Evaluator.prototype.fnTIMESTAMP = function (date, format) {
|
|
1006
2416
|
return parseInt(moment__default["default"](date).format(format === 'x' ? 'x' : 'X'), 10);
|
|
@@ -1011,7 +2421,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1011
2421
|
* @example TODAY()
|
|
1012
2422
|
* @namespace 日期函数
|
|
1013
2423
|
*
|
|
1014
|
-
* @returns {number}
|
|
2424
|
+
* @returns {number} 日期
|
|
1015
2425
|
*/
|
|
1016
2426
|
Evaluator.prototype.fnTODAY = function () {
|
|
1017
2427
|
return new Date();
|
|
@@ -1022,7 +2432,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1022
2432
|
* @example NOW()
|
|
1023
2433
|
* @namespace 日期函数
|
|
1024
2434
|
*
|
|
1025
|
-
* @returns {number}
|
|
2435
|
+
* @returns {number} 日期
|
|
1026
2436
|
*/
|
|
1027
2437
|
Evaluator.prototype.fnNOW = function () {
|
|
1028
2438
|
return new Date();
|
|
@@ -1035,7 +2445,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1035
2445
|
* @param {date} date 日期对象
|
|
1036
2446
|
* @param {string} format 日期格式,默认为 "YYYY-MM-DD HH:mm:ss"
|
|
1037
2447
|
*
|
|
1038
|
-
* @returns {number}
|
|
2448
|
+
* @returns {number} 日期字符串
|
|
1039
2449
|
*/
|
|
1040
2450
|
Evaluator.prototype.fnDATETOSTR = function (date, format) {
|
|
1041
2451
|
if (format === void 0) { format = 'YYYY-MM-DD HH:mm:ss'; }
|
|
@@ -1089,7 +2499,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1089
2499
|
* @namespace 日期函数
|
|
1090
2500
|
* @example YEAR(date)
|
|
1091
2501
|
* @param {date} date 日期对象
|
|
1092
|
-
* @returns {number}
|
|
2502
|
+
* @returns {number} 数值
|
|
1093
2503
|
*/
|
|
1094
2504
|
Evaluator.prototype.fnYEAR = function (date) {
|
|
1095
2505
|
date = this.normalizeDate(date);
|
|
@@ -1101,7 +2511,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1101
2511
|
* @namespace 日期函数
|
|
1102
2512
|
* @example MONTH(date)
|
|
1103
2513
|
* @param {date} date 日期对象
|
|
1104
|
-
* @returns {number}
|
|
2514
|
+
* @returns {number} 数值
|
|
1105
2515
|
*/
|
|
1106
2516
|
Evaluator.prototype.fnMONTH = function (date) {
|
|
1107
2517
|
date = this.normalizeDate(date);
|
|
@@ -1112,7 +2522,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1112
2522
|
* @namespace 日期函数
|
|
1113
2523
|
* @example DAY(date)
|
|
1114
2524
|
* @param {date} date 日期对象
|
|
1115
|
-
* @returns {number}
|
|
2525
|
+
* @returns {number} 数值
|
|
1116
2526
|
*/
|
|
1117
2527
|
Evaluator.prototype.fnDAY = function (date) {
|
|
1118
2528
|
date = this.normalizeDate(date);
|
|
@@ -1123,7 +2533,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1123
2533
|
* @param {date} date 日期对象
|
|
1124
2534
|
* @namespace 日期函数
|
|
1125
2535
|
* @example HOUR(date)
|
|
1126
|
-
* @returns {number}
|
|
2536
|
+
* @returns {number} 数值
|
|
1127
2537
|
*/
|
|
1128
2538
|
Evaluator.prototype.fnHOUR = function (date) {
|
|
1129
2539
|
date = this.normalizeDate(date);
|
|
@@ -1134,7 +2544,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1134
2544
|
* @param {date} date 日期对象
|
|
1135
2545
|
* @namespace 日期函数
|
|
1136
2546
|
* @example MINUTE(date)
|
|
1137
|
-
* @returns {number}
|
|
2547
|
+
* @returns {number} 数值
|
|
1138
2548
|
*/
|
|
1139
2549
|
Evaluator.prototype.fnMINUTE = function (date) {
|
|
1140
2550
|
date = this.normalizeDate(date);
|
|
@@ -1145,7 +2555,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1145
2555
|
* @param {date} date 日期对象
|
|
1146
2556
|
* @namespace 日期函数
|
|
1147
2557
|
* @example SECOND(date)
|
|
1148
|
-
* @returns {number}
|
|
2558
|
+
* @returns {number} 数值
|
|
1149
2559
|
*/
|
|
1150
2560
|
Evaluator.prototype.fnSECOND = function (date) {
|
|
1151
2561
|
date = this.normalizeDate(date);
|
|
@@ -1157,7 +2567,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1157
2567
|
* @param {date} startDate 日期对象
|
|
1158
2568
|
* @namespace 日期函数
|
|
1159
2569
|
* @example YEARS(endDate, startDate)
|
|
1160
|
-
* @returns {number}
|
|
2570
|
+
* @returns {number} 数值
|
|
1161
2571
|
*/
|
|
1162
2572
|
Evaluator.prototype.fnYEARS = function (endDate, startDate) {
|
|
1163
2573
|
endDate = this.normalizeDate(endDate);
|
|
@@ -1170,7 +2580,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1170
2580
|
* @param {date} startDate 日期对象
|
|
1171
2581
|
* @namespace 日期函数
|
|
1172
2582
|
* @example MINUTES(endDate, startDate)
|
|
1173
|
-
* @returns {number}
|
|
2583
|
+
* @returns {number} 数值
|
|
1174
2584
|
*/
|
|
1175
2585
|
Evaluator.prototype.fnMINUTES = function (endDate, startDate) {
|
|
1176
2586
|
endDate = this.normalizeDate(endDate);
|
|
@@ -1183,7 +2593,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1183
2593
|
* @param {date} startDate 日期对象
|
|
1184
2594
|
* @namespace 日期函数
|
|
1185
2595
|
* @example DAYS(endDate, startDate)
|
|
1186
|
-
* @returns {number}
|
|
2596
|
+
* @returns {number} 数值
|
|
1187
2597
|
*/
|
|
1188
2598
|
Evaluator.prototype.fnDAYS = function (endDate, startDate) {
|
|
1189
2599
|
endDate = this.normalizeDate(endDate);
|
|
@@ -1196,7 +2606,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1196
2606
|
* @param {date} startDate 日期对象
|
|
1197
2607
|
* @namespace 日期函数
|
|
1198
2608
|
* @example HOURS(endDate, startDate)
|
|
1199
|
-
* @returns {number}
|
|
2609
|
+
* @returns {number} 数值
|
|
1200
2610
|
*/
|
|
1201
2611
|
Evaluator.prototype.fnHOURS = function (endDate, startDate) {
|
|
1202
2612
|
endDate = this.normalizeDate(endDate);
|
|
@@ -1217,7 +2627,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1217
2627
|
* @param {string} unit 单位:支持年、月、天等等
|
|
1218
2628
|
* @namespace 日期函数
|
|
1219
2629
|
* @example DATEMODIFY(date, 2, 'days')
|
|
1220
|
-
* @returns {date}
|
|
2630
|
+
* @returns {date} 日期对象
|
|
1221
2631
|
*/
|
|
1222
2632
|
Evaluator.prototype.fnDATEMODIFY = function (date, num, format) {
|
|
1223
2633
|
date = this.normalizeDate(date);
|
|
@@ -1232,7 +2642,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1232
2642
|
* @param {string} format 日期格式
|
|
1233
2643
|
* @namespace 日期函数
|
|
1234
2644
|
* @example STRTODATE(value[, format=""])
|
|
1235
|
-
* @returns {date}
|
|
2645
|
+
* @returns {date} 日期对象
|
|
1236
2646
|
*/
|
|
1237
2647
|
Evaluator.prototype.fnSTRTODATE = function (value, format) {
|
|
1238
2648
|
if (format === void 0) { format = ''; }
|
|
@@ -1246,7 +2656,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1246
2656
|
* @param {string} unit 单位,默认是 'day', 即之比较到天
|
|
1247
2657
|
* @namespace 日期函数
|
|
1248
2658
|
* @example ISBEFORE(a, b)
|
|
1249
|
-
* @returns {boolean}
|
|
2659
|
+
* @returns {boolean} 判断结果
|
|
1250
2660
|
*/
|
|
1251
2661
|
Evaluator.prototype.fnISBEFORE = function (a, b, unit) {
|
|
1252
2662
|
if (unit === void 0) { unit = 'day'; }
|
|
@@ -1262,7 +2672,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1262
2672
|
* @param {string} unit 单位,默认是 'day', 即之比较到天
|
|
1263
2673
|
* @namespace 日期函数
|
|
1264
2674
|
* @example ISAFTER(a, b)
|
|
1265
|
-
* @returns {boolean}
|
|
2675
|
+
* @returns {boolean} 判断结果
|
|
1266
2676
|
*/
|
|
1267
2677
|
Evaluator.prototype.fnISAFTER = function (a, b, unit) {
|
|
1268
2678
|
if (unit === void 0) { unit = 'day'; }
|
|
@@ -1278,7 +2688,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1278
2688
|
* @param {string} unit 单位,默认是 'day', 即之比较到天
|
|
1279
2689
|
* @namespace 日期函数
|
|
1280
2690
|
* @example ISSAMEORBEFORE(a, b)
|
|
1281
|
-
* @returns {boolean}
|
|
2691
|
+
* @returns {boolean} 判断结果
|
|
1282
2692
|
*/
|
|
1283
2693
|
Evaluator.prototype.fnISSAMEORBEFORE = function (a, b, unit) {
|
|
1284
2694
|
if (unit === void 0) { unit = 'day'; }
|
|
@@ -1294,7 +2704,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1294
2704
|
* @param {string} unit 单位,默认是 'day', 即之比较到天
|
|
1295
2705
|
* @namespace 日期函数
|
|
1296
2706
|
* @example ISSAMEORAFTER(a, b)
|
|
1297
|
-
* @returns {boolean}
|
|
2707
|
+
* @returns {boolean} 判断结果
|
|
1298
2708
|
*/
|
|
1299
2709
|
Evaluator.prototype.fnISSAMEORAFTER = function (a, b, unit) {
|
|
1300
2710
|
if (unit === void 0) { unit = 'day'; }
|
|
@@ -1308,7 +2718,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1308
2718
|
* @param {Array<any>} arr 数组
|
|
1309
2719
|
* @namespace 其他
|
|
1310
2720
|
* @example COUNT(arr)
|
|
1311
|
-
* @returns {boolean}
|
|
2721
|
+
* @returns {boolean} 结果
|
|
1312
2722
|
*/
|
|
1313
2723
|
Evaluator.prototype.fnCOUNT = function (value) {
|
|
1314
2724
|
return Array.isArray(value) ? value.length : value ? 1 : 0;
|
|
@@ -3162,7 +4572,12 @@ var filters = {
|
|
|
3162
4572
|
length = parseInt(length, 10) || 200;
|
|
3163
4573
|
return input.substring(0, length) + (input.length > length ? end : '');
|
|
3164
4574
|
},
|
|
3165
|
-
url_encode: function (input) {
|
|
4575
|
+
url_encode: function (input) {
|
|
4576
|
+
if (input == null) {
|
|
4577
|
+
return '';
|
|
4578
|
+
}
|
|
4579
|
+
return encodeURIComponent(input);
|
|
4580
|
+
},
|
|
3166
4581
|
url_decode: function (input) { return decodeURIComponent(input); },
|
|
3167
4582
|
default: function (input, defaultValue, strict) {
|
|
3168
4583
|
var _a;
|
|
@@ -3476,6 +4891,7 @@ function skipRestTest(restFilters) {
|
|
|
3476
4891
|
}
|
|
3477
4892
|
function registerFilter(name, fn) {
|
|
3478
4893
|
filters[name] = fn;
|
|
4894
|
+
Evaluator.setDefaultFilters(filters);
|
|
3479
4895
|
}
|
|
3480
4896
|
function getFilters() {
|
|
3481
4897
|
return filters;
|