amis-formula 1.2.5 → 1.2.9
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 +301 -50
- package/dist/doc.md +205 -45
- package/dist/evalutor.d.ts +210 -50
- package/dist/index.js +1470 -54
- 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.9
|
|
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
|
*/
|
|
@@ -113,7 +1267,8 @@ var Evaluator = /** @class */ (function () {
|
|
|
113
1267
|
Evaluator.prototype.script = function (ast) {
|
|
114
1268
|
var _a;
|
|
115
1269
|
var defaultFilter = this.options.defaultFilter;
|
|
116
|
-
|
|
1270
|
+
// 只给简单的变量取值用法自动补fitler
|
|
1271
|
+
if (defaultFilter && ~['getter', 'variable'].indexOf((_a = ast.body) === null || _a === void 0 ? void 0 : _a.type)) {
|
|
117
1272
|
ast.body = {
|
|
118
1273
|
type: 'filter',
|
|
119
1274
|
input: ast.body,
|
|
@@ -452,7 +1607,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
452
1607
|
* @example IFS(condition1, result1, condition2, result2,...conditionN, resultN)
|
|
453
1608
|
* @param {...any} args - 条件,返回值集合
|
|
454
1609
|
* @namespace 逻辑函数
|
|
455
|
-
* @returns {any}
|
|
1610
|
+
* @returns {any} 第一个满足条件的结果,没有命中的返回 false。
|
|
456
1611
|
*/
|
|
457
1612
|
Evaluator.prototype.fnIFS = function () {
|
|
458
1613
|
var args = [];
|
|
@@ -478,7 +1633,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
478
1633
|
* @param {number} num - 数值
|
|
479
1634
|
* @namespace 数学函数
|
|
480
1635
|
*
|
|
481
|
-
* @returns {number}
|
|
1636
|
+
* @returns {number} 传入数值的绝对值
|
|
482
1637
|
*/
|
|
483
1638
|
Evaluator.prototype.fnABS = function (a) {
|
|
484
1639
|
a = this.formatNumber(a);
|
|
@@ -491,7 +1646,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
491
1646
|
* @param {...number} num - 数值
|
|
492
1647
|
* @namespace 数学函数
|
|
493
1648
|
*
|
|
494
|
-
* @returns {number}
|
|
1649
|
+
* @returns {number} 所有传入值中最大的那个
|
|
495
1650
|
*/
|
|
496
1651
|
Evaluator.prototype.fnMAX = function () {
|
|
497
1652
|
var _this = this;
|
|
@@ -508,7 +1663,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
508
1663
|
* @param {...number} num - 数值
|
|
509
1664
|
* @namespace 数学函数
|
|
510
1665
|
*
|
|
511
|
-
* @returns {number}
|
|
1666
|
+
* @returns {number} 所有传入值中最小的那个
|
|
512
1667
|
*/
|
|
513
1668
|
Evaluator.prototype.fnMIN = function () {
|
|
514
1669
|
var _this = this;
|
|
@@ -525,7 +1680,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
525
1680
|
* @param {...number} num - 数值
|
|
526
1681
|
* @namespace 数学函数
|
|
527
1682
|
*
|
|
528
|
-
* @returns {number}
|
|
1683
|
+
* @returns {number} 所有传入数值的总和
|
|
529
1684
|
*/
|
|
530
1685
|
Evaluator.prototype.fnSUM = function () {
|
|
531
1686
|
var _this = this;
|
|
@@ -542,7 +1697,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
542
1697
|
* @param {number} num - 数值
|
|
543
1698
|
* @namespace 数学函数
|
|
544
1699
|
*
|
|
545
|
-
* @returns {number}
|
|
1700
|
+
* @returns {number} 数值对应的整形
|
|
546
1701
|
*/
|
|
547
1702
|
Evaluator.prototype.fnINT = function (n) {
|
|
548
1703
|
return Math.floor(this.formatNumber(n));
|
|
@@ -555,7 +1710,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
555
1710
|
* @param {number} divisor - 除数
|
|
556
1711
|
* @namespace 数学函数
|
|
557
1712
|
*
|
|
558
|
-
* @returns {number}
|
|
1713
|
+
* @returns {number} 两数相除的余数
|
|
559
1714
|
*/
|
|
560
1715
|
Evaluator.prototype.fnMOD = function (a, b) {
|
|
561
1716
|
return this.formatNumber(a) % this.formatNumber(b);
|
|
@@ -566,7 +1721,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
566
1721
|
* @example PI()
|
|
567
1722
|
* @namespace 数学函数
|
|
568
1723
|
*
|
|
569
|
-
* @returns {number}
|
|
1724
|
+
* @returns {number} 圆周率数值
|
|
570
1725
|
*/
|
|
571
1726
|
Evaluator.prototype.fnPI = function () {
|
|
572
1727
|
return Math.PI;
|
|
@@ -579,7 +1734,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
579
1734
|
* @param {number} numDigits - 小数位数
|
|
580
1735
|
* @namespace 数学函数
|
|
581
1736
|
*
|
|
582
|
-
* @returns {number}
|
|
1737
|
+
* @returns {number} 传入数值四舍五入后的结果
|
|
583
1738
|
*/
|
|
584
1739
|
Evaluator.prototype.fnROUND = function (a, b) {
|
|
585
1740
|
a = this.formatNumber(a);
|
|
@@ -599,7 +1754,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
599
1754
|
* @param {number} numDigits - 小数位数
|
|
600
1755
|
* @namespace 数学函数
|
|
601
1756
|
*
|
|
602
|
-
* @returns {number}
|
|
1757
|
+
* @returns {number} 传入数值向下取整后的结果
|
|
603
1758
|
*/
|
|
604
1759
|
Evaluator.prototype.fnFLOOR = function (a, b) {
|
|
605
1760
|
a = this.formatNumber(a);
|
|
@@ -619,7 +1774,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
619
1774
|
* @param {number} numDigits - 小数位数
|
|
620
1775
|
* @namespace 数学函数
|
|
621
1776
|
*
|
|
622
|
-
* @returns {number}
|
|
1777
|
+
* @returns {number} 传入数值向上取整后的结果
|
|
623
1778
|
*/
|
|
624
1779
|
Evaluator.prototype.fnCEIL = function (a, b) {
|
|
625
1780
|
a = this.formatNumber(a);
|
|
@@ -638,7 +1793,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
638
1793
|
* @param {number} num - 要处理的数字
|
|
639
1794
|
* @namespace 数学函数
|
|
640
1795
|
*
|
|
641
|
-
* @returns {number}
|
|
1796
|
+
* @returns {number} 开平方的结果
|
|
642
1797
|
*/
|
|
643
1798
|
Evaluator.prototype.fnSQRT = function (n) {
|
|
644
1799
|
return Math.sqrt(this.formatNumber(n));
|
|
@@ -650,7 +1805,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
650
1805
|
* @param {...number} num - 要处理的数字
|
|
651
1806
|
* @namespace 数学函数
|
|
652
1807
|
*
|
|
653
|
-
* @returns {number}
|
|
1808
|
+
* @returns {number} 所有数值的平均值
|
|
654
1809
|
*/
|
|
655
1810
|
Evaluator.prototype.fnAVG = function () {
|
|
656
1811
|
var _this = this;
|
|
@@ -660,6 +1815,111 @@ var Evaluator = /** @class */ (function () {
|
|
|
660
1815
|
}
|
|
661
1816
|
return (this.fnSUM.apply(this, args.map(function (item) { return _this.formatNumber(item); })) / args.length);
|
|
662
1817
|
};
|
|
1818
|
+
/**
|
|
1819
|
+
* 返回数据点与数据均值点之差(数据偏差)的平方和
|
|
1820
|
+
*
|
|
1821
|
+
* @example DEVSQ(num1, num2, ...numN)
|
|
1822
|
+
* @param {...number} num - 要处理的数字
|
|
1823
|
+
* @namespace 数学函数
|
|
1824
|
+
*
|
|
1825
|
+
* @returns {number} 所有数值的平均值
|
|
1826
|
+
*/
|
|
1827
|
+
Evaluator.prototype.fnDEVSQ = function () {
|
|
1828
|
+
var _this = this;
|
|
1829
|
+
var args = [];
|
|
1830
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1831
|
+
args[_i] = arguments[_i];
|
|
1832
|
+
}
|
|
1833
|
+
if (args.length === 0) {
|
|
1834
|
+
return null;
|
|
1835
|
+
}
|
|
1836
|
+
var nums = args.map(function (item) { return _this.formatNumber(item); });
|
|
1837
|
+
var sum = nums.reduce(function (sum, a) { return sum + a || 0; }, 0);
|
|
1838
|
+
var mean = sum / nums.length;
|
|
1839
|
+
var result = 0;
|
|
1840
|
+
for (var _a = 0, nums_1 = nums; _a < nums_1.length; _a++) {
|
|
1841
|
+
var num = nums_1[_a];
|
|
1842
|
+
result += Math.pow(num - mean, 2);
|
|
1843
|
+
}
|
|
1844
|
+
return result;
|
|
1845
|
+
};
|
|
1846
|
+
/**
|
|
1847
|
+
* 数据点到其算术平均值的绝对偏差的平均值
|
|
1848
|
+
*
|
|
1849
|
+
* @example AVEDEV(num1, num2, ...numN)
|
|
1850
|
+
* @param {...number} num - 要处理的数字
|
|
1851
|
+
* @namespace 数学函数
|
|
1852
|
+
*
|
|
1853
|
+
* @returns {number} 所有数值的平均值
|
|
1854
|
+
*/
|
|
1855
|
+
Evaluator.prototype.fnAVEDEV = function () {
|
|
1856
|
+
var _this = this;
|
|
1857
|
+
var args = [];
|
|
1858
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1859
|
+
args[_i] = arguments[_i];
|
|
1860
|
+
}
|
|
1861
|
+
if (args.length === 0) {
|
|
1862
|
+
return null;
|
|
1863
|
+
}
|
|
1864
|
+
var nums = args.map(function (item) { return _this.formatNumber(item); });
|
|
1865
|
+
var sum = nums.reduce(function (sum, a) { return sum + a || 0; }, 0);
|
|
1866
|
+
var mean = sum / nums.length;
|
|
1867
|
+
var result = 0;
|
|
1868
|
+
for (var _a = 0, nums_2 = nums; _a < nums_2.length; _a++) {
|
|
1869
|
+
var num = nums_2[_a];
|
|
1870
|
+
result += Math.abs(num - mean);
|
|
1871
|
+
}
|
|
1872
|
+
return result / nums.length;
|
|
1873
|
+
};
|
|
1874
|
+
/**
|
|
1875
|
+
* 数据点的调和平均值
|
|
1876
|
+
*
|
|
1877
|
+
* @example HARMEAN(num1, num2, ...numN)
|
|
1878
|
+
* @param {...number} num - 要处理的数字
|
|
1879
|
+
* @namespace 数学函数
|
|
1880
|
+
*
|
|
1881
|
+
* @returns {number} 所有数值的平均值
|
|
1882
|
+
*/
|
|
1883
|
+
Evaluator.prototype.fnHARMEAN = function () {
|
|
1884
|
+
var _this = this;
|
|
1885
|
+
var args = [];
|
|
1886
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1887
|
+
args[_i] = arguments[_i];
|
|
1888
|
+
}
|
|
1889
|
+
if (args.length === 0) {
|
|
1890
|
+
return null;
|
|
1891
|
+
}
|
|
1892
|
+
var nums = args.map(function (item) { return _this.formatNumber(item); });
|
|
1893
|
+
var den = 0;
|
|
1894
|
+
for (var _a = 0, nums_3 = nums; _a < nums_3.length; _a++) {
|
|
1895
|
+
var num = nums_3[_a];
|
|
1896
|
+
den += 1 / num;
|
|
1897
|
+
}
|
|
1898
|
+
return nums.length / den;
|
|
1899
|
+
};
|
|
1900
|
+
/**
|
|
1901
|
+
* 数据集中第 k 个最大值
|
|
1902
|
+
*
|
|
1903
|
+
* @example LARGE(array, k)
|
|
1904
|
+
* @param {array} nums - 要处理的数字
|
|
1905
|
+
* @param {number} k - 第几大
|
|
1906
|
+
* @namespace 数学函数
|
|
1907
|
+
*
|
|
1908
|
+
* @returns {number} 所有数值的平均值
|
|
1909
|
+
*/
|
|
1910
|
+
Evaluator.prototype.fnLARGE = function (nums, k) {
|
|
1911
|
+
var _this = this;
|
|
1912
|
+
if (nums.length === 0) {
|
|
1913
|
+
return null;
|
|
1914
|
+
}
|
|
1915
|
+
var numsFormat = nums.map(function (item) { return _this.formatNumber(item); });
|
|
1916
|
+
if (k < 0 || numsFormat.length < k) {
|
|
1917
|
+
return null;
|
|
1918
|
+
}
|
|
1919
|
+
return numsFormat.sort(function (a, b) {
|
|
1920
|
+
return b - a;
|
|
1921
|
+
})[k - 1];
|
|
1922
|
+
};
|
|
663
1923
|
/**
|
|
664
1924
|
* 将数值转为中文大写金额
|
|
665
1925
|
*
|
|
@@ -667,7 +1927,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
667
1927
|
* @param {number} num - 要处理的数字
|
|
668
1928
|
* @namespace 数学函数
|
|
669
1929
|
*
|
|
670
|
-
* @returns {string}
|
|
1930
|
+
* @returns {string} 数值中文大写字符
|
|
671
1931
|
*/
|
|
672
1932
|
Evaluator.prototype.fnUPPERMONEY = function (n) {
|
|
673
1933
|
n = this.formatNumber(n);
|
|
@@ -709,7 +1969,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
709
1969
|
* @example RAND()
|
|
710
1970
|
* @namespace 数学函数
|
|
711
1971
|
*
|
|
712
|
-
* @returns {number}
|
|
1972
|
+
* @returns {number} 随机数
|
|
713
1973
|
*/
|
|
714
1974
|
Evaluator.prototype.fnRAND = function () {
|
|
715
1975
|
return Math.random();
|
|
@@ -769,7 +2029,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
769
2029
|
* @param {string[]} textArr - 要处理的文本集合
|
|
770
2030
|
* @namespace 文本函数
|
|
771
2031
|
*
|
|
772
|
-
* @returns {number[]}
|
|
2032
|
+
* @returns {number[]} 长度集合
|
|
773
2033
|
*/
|
|
774
2034
|
Evaluator.prototype.fnLENGTH = function () {
|
|
775
2035
|
var args = [];
|
|
@@ -785,7 +2045,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
785
2045
|
* @param {string} text - 要处理的文本
|
|
786
2046
|
* @namespace 文本函数
|
|
787
2047
|
*
|
|
788
|
-
* @returns {boolean}
|
|
2048
|
+
* @returns {boolean} 判断结果
|
|
789
2049
|
*/
|
|
790
2050
|
Evaluator.prototype.fnISEMPTY = function (text) {
|
|
791
2051
|
return !text || !String(text).trim();
|
|
@@ -797,7 +2057,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
797
2057
|
* @param {...string} text - 文本集合
|
|
798
2058
|
* @namespace 文本函数
|
|
799
2059
|
*
|
|
800
|
-
* @returns {string}
|
|
2060
|
+
* @returns {string} 连接后的文本
|
|
801
2061
|
*/
|
|
802
2062
|
Evaluator.prototype.fnCONCATENATE = function () {
|
|
803
2063
|
var args = [];
|
|
@@ -815,7 +2075,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
815
2075
|
* @param {number} code - 编码值
|
|
816
2076
|
* @namespace 文本函数
|
|
817
2077
|
*
|
|
818
|
-
* @returns {string}
|
|
2078
|
+
* @returns {string} 指定位置的字符
|
|
819
2079
|
*/
|
|
820
2080
|
Evaluator.prototype.fnCHAR = function (code) {
|
|
821
2081
|
return String.fromCharCode(code);
|
|
@@ -827,7 +2087,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
827
2087
|
* @param {string} text - 文本
|
|
828
2088
|
* @namespace 文本函数
|
|
829
2089
|
*
|
|
830
|
-
* @returns {string}
|
|
2090
|
+
* @returns {string} 结果文本
|
|
831
2091
|
*/
|
|
832
2092
|
Evaluator.prototype.fnLOWER = function (text) {
|
|
833
2093
|
text = this.normalizeText(text);
|
|
@@ -840,12 +2100,111 @@ var Evaluator = /** @class */ (function () {
|
|
|
840
2100
|
* @param {string} text - 文本
|
|
841
2101
|
* @namespace 文本函数
|
|
842
2102
|
*
|
|
843
|
-
* @returns {string}
|
|
2103
|
+
* @returns {string} 结果文本
|
|
844
2104
|
*/
|
|
845
2105
|
Evaluator.prototype.fnUPPER = function (text) {
|
|
846
2106
|
text = this.normalizeText(text);
|
|
847
2107
|
return text.toUpperCase();
|
|
848
2108
|
};
|
|
2109
|
+
/**
|
|
2110
|
+
* 将传入文本首字母转成大写
|
|
2111
|
+
*
|
|
2112
|
+
* @example UPPERFIRST(text)
|
|
2113
|
+
* @param {string} text - 文本
|
|
2114
|
+
* @namespace 文本函数
|
|
2115
|
+
*
|
|
2116
|
+
* @returns {string} 结果文本
|
|
2117
|
+
*/
|
|
2118
|
+
Evaluator.prototype.fnUPPERFIRST = function (text) {
|
|
2119
|
+
text = this.normalizeText(text);
|
|
2120
|
+
return upperFirst_1(text);
|
|
2121
|
+
};
|
|
2122
|
+
/**
|
|
2123
|
+
* 向前补齐文本长度
|
|
2124
|
+
*
|
|
2125
|
+
* 示例 `PADSTART("6", 2, "0")`
|
|
2126
|
+
*
|
|
2127
|
+
* 返回 `06`
|
|
2128
|
+
*
|
|
2129
|
+
* @example PADSTART(text)
|
|
2130
|
+
* @param {string} text - 文本
|
|
2131
|
+
* @param {number} num - 目标长度
|
|
2132
|
+
* @param {string} pad - 用于补齐的文本
|
|
2133
|
+
* @namespace 文本函数
|
|
2134
|
+
*
|
|
2135
|
+
* @returns {string} 结果文本
|
|
2136
|
+
*/
|
|
2137
|
+
Evaluator.prototype.fnPADSTART = function (text, num, pad) {
|
|
2138
|
+
text = this.normalizeText(text);
|
|
2139
|
+
return padStart_1(text, num, pad);
|
|
2140
|
+
};
|
|
2141
|
+
/**
|
|
2142
|
+
* 将文本转成标题
|
|
2143
|
+
*
|
|
2144
|
+
* 示例 `CAPITALIZE("star")`
|
|
2145
|
+
*
|
|
2146
|
+
* 返回 `Star`
|
|
2147
|
+
*
|
|
2148
|
+
* @example CAPITALIZE(text)
|
|
2149
|
+
* @param {string} text - 文本
|
|
2150
|
+
* @namespace 文本函数
|
|
2151
|
+
*
|
|
2152
|
+
* @returns {string} 结果文本
|
|
2153
|
+
*/
|
|
2154
|
+
Evaluator.prototype.fnCAPITALIZE = function (text) {
|
|
2155
|
+
text = this.normalizeText(text);
|
|
2156
|
+
return capitalize_1(text);
|
|
2157
|
+
};
|
|
2158
|
+
/**
|
|
2159
|
+
* 对文本进行 HTML 转义
|
|
2160
|
+
*
|
|
2161
|
+
* 示例 `ESCAPE("star")`
|
|
2162
|
+
*
|
|
2163
|
+
* 返回 `Star`
|
|
2164
|
+
*
|
|
2165
|
+
* @example ESCAPE(text)
|
|
2166
|
+
* @param {string} text - 文本
|
|
2167
|
+
* @namespace 文本函数
|
|
2168
|
+
*
|
|
2169
|
+
* @returns {string} 结果文本
|
|
2170
|
+
*/
|
|
2171
|
+
Evaluator.prototype.fnESCAPE = function (text) {
|
|
2172
|
+
text = this.normalizeText(text);
|
|
2173
|
+
return _escape(text);
|
|
2174
|
+
};
|
|
2175
|
+
/**
|
|
2176
|
+
* 对文本长度进行截断
|
|
2177
|
+
*
|
|
2178
|
+
* 示例 `TRUNCATE("amis.baidu.com", 6)`
|
|
2179
|
+
*
|
|
2180
|
+
* 返回 `amis...`
|
|
2181
|
+
*
|
|
2182
|
+
* @example TRUNCATE(text, 6)
|
|
2183
|
+
* @param {string} text - 文本
|
|
2184
|
+
* @param {number} text - 最长长度
|
|
2185
|
+
* @namespace 文本函数
|
|
2186
|
+
*
|
|
2187
|
+
* @returns {string} 结果文本
|
|
2188
|
+
*/
|
|
2189
|
+
Evaluator.prototype.fnTRUNCATE = function (text, length) {
|
|
2190
|
+
text = this.normalizeText(text);
|
|
2191
|
+
return truncate_1(text, { length: length });
|
|
2192
|
+
};
|
|
2193
|
+
/**
|
|
2194
|
+
* 取在某个分隔符之前的所有字符串
|
|
2195
|
+
*
|
|
2196
|
+
* @example BEFORELAST(text, '.')
|
|
2197
|
+
* @param {string} text - 文本
|
|
2198
|
+
* @param {string} delimiter - 结束文本
|
|
2199
|
+
* @namespace 文本函数
|
|
2200
|
+
*
|
|
2201
|
+
* @returns {string} 判断结果
|
|
2202
|
+
*/
|
|
2203
|
+
Evaluator.prototype.fnBEFORELAST = function (text, delimiter) {
|
|
2204
|
+
if (delimiter === void 0) { delimiter = '.'; }
|
|
2205
|
+
text = this.normalizeText(text);
|
|
2206
|
+
return text.split(delimiter).slice(0, -1).join(delimiter) || text + '';
|
|
2207
|
+
};
|
|
849
2208
|
/**
|
|
850
2209
|
* 将文本根据指定片段分割成数组
|
|
851
2210
|
*
|
|
@@ -858,7 +2217,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
858
2217
|
* @param {string} delimiter - 文本片段
|
|
859
2218
|
* @namespace 文本函数
|
|
860
2219
|
*
|
|
861
|
-
* @returns {Array<string>}
|
|
2220
|
+
* @returns {Array<string>} 文本集
|
|
862
2221
|
*/
|
|
863
2222
|
Evaluator.prototype.fnSPLIT = function (text, sep) {
|
|
864
2223
|
if (sep === void 0) { sep = ','; }
|
|
@@ -872,12 +2231,46 @@ var Evaluator = /** @class */ (function () {
|
|
|
872
2231
|
* @param {string} text - 文本
|
|
873
2232
|
* @namespace 文本函数
|
|
874
2233
|
*
|
|
875
|
-
* @returns {string}
|
|
2234
|
+
* @returns {string} 处理后的文本
|
|
876
2235
|
*/
|
|
877
2236
|
Evaluator.prototype.fnTRIM = function (text) {
|
|
878
2237
|
text = this.normalizeText(text);
|
|
879
2238
|
return text.trim();
|
|
880
2239
|
};
|
|
2240
|
+
/**
|
|
2241
|
+
* 去除文本中的 HTML 标签
|
|
2242
|
+
*
|
|
2243
|
+
* 示例:`STRIPTAG("<b>amis</b>")`
|
|
2244
|
+
*
|
|
2245
|
+
* 返回:`amis`
|
|
2246
|
+
*
|
|
2247
|
+
* @example STRIPTAG(text)
|
|
2248
|
+
* @param {string} text - 文本
|
|
2249
|
+
* @namespace 文本函数
|
|
2250
|
+
*
|
|
2251
|
+
* @returns {string} 处理后的文本
|
|
2252
|
+
*/
|
|
2253
|
+
Evaluator.prototype.fnSTRIPTAG = function (text) {
|
|
2254
|
+
text = this.normalizeText(text);
|
|
2255
|
+
return text.replace(/<\/?[^>]+(>|$)/g, '');
|
|
2256
|
+
};
|
|
2257
|
+
/**
|
|
2258
|
+
* 将字符串中的换行转成 HTML `<br>`,用于简单换行的场景
|
|
2259
|
+
*
|
|
2260
|
+
* 示例:`LINEBREAK("\n")`
|
|
2261
|
+
*
|
|
2262
|
+
* 返回:`<br/>`
|
|
2263
|
+
*
|
|
2264
|
+
* @example LINEBREAK(text)
|
|
2265
|
+
* @param {string} text - 文本
|
|
2266
|
+
* @namespace 文本函数
|
|
2267
|
+
*
|
|
2268
|
+
* @returns {string} 处理后的文本
|
|
2269
|
+
*/
|
|
2270
|
+
Evaluator.prototype.fnLINEBREAK = function (text) {
|
|
2271
|
+
text = this.normalizeText(text);
|
|
2272
|
+
return text.replace(/(?:\r\n|\r|\n)/g, '<br/>');
|
|
2273
|
+
};
|
|
881
2274
|
/**
|
|
882
2275
|
* 判断字符串(text)是否以特定字符串(startString)开始,是则返回 True,否则返回 False
|
|
883
2276
|
*
|
|
@@ -886,7 +2279,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
886
2279
|
* @param {string} startString - 起始文本
|
|
887
2280
|
* @namespace 文本函数
|
|
888
2281
|
*
|
|
889
|
-
* @returns {string}
|
|
2282
|
+
* @returns {string} 判断结果
|
|
890
2283
|
*/
|
|
891
2284
|
Evaluator.prototype.fnSTARTSWITH = function (text, search) {
|
|
892
2285
|
if (!search) {
|
|
@@ -895,6 +2288,23 @@ var Evaluator = /** @class */ (function () {
|
|
|
895
2288
|
text = this.normalizeText(text);
|
|
896
2289
|
return text.indexOf(search) === 0;
|
|
897
2290
|
};
|
|
2291
|
+
/**
|
|
2292
|
+
* 判断字符串(text)是否以特定字符串(endString)结束,是则返回 True,否则返回 False
|
|
2293
|
+
*
|
|
2294
|
+
* @example ENDSWITH(text, '片段')
|
|
2295
|
+
* @param {string} text - 文本
|
|
2296
|
+
* @param {string} endString - 结束文本
|
|
2297
|
+
* @namespace 文本函数
|
|
2298
|
+
*
|
|
2299
|
+
* @returns {string} 判断结果
|
|
2300
|
+
*/
|
|
2301
|
+
Evaluator.prototype.fnENDSWITH = function (text, search) {
|
|
2302
|
+
if (!search) {
|
|
2303
|
+
return false;
|
|
2304
|
+
}
|
|
2305
|
+
text = this.normalizeText(text);
|
|
2306
|
+
return text.indexOf(search, text.length - search.length) !== -1;
|
|
2307
|
+
};
|
|
898
2308
|
/**
|
|
899
2309
|
* 判断参数 1 中的文本是否包含参数 2 中的文本。
|
|
900
2310
|
*
|
|
@@ -903,7 +2313,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
903
2313
|
* @param {string} searchText - 搜索文本
|
|
904
2314
|
* @namespace 文本函数
|
|
905
2315
|
*
|
|
906
|
-
* @returns {string}
|
|
2316
|
+
* @returns {string} 判断结果
|
|
907
2317
|
*/
|
|
908
2318
|
Evaluator.prototype.fnCONTAINS = function (text, search) {
|
|
909
2319
|
if (!search) {
|
|
@@ -921,7 +2331,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
921
2331
|
* @param {string} replace - 要替换的文本
|
|
922
2332
|
* @namespace 文本函数
|
|
923
2333
|
*
|
|
924
|
-
* @returns {string}
|
|
2334
|
+
* @returns {string} 处理结果
|
|
925
2335
|
*/
|
|
926
2336
|
Evaluator.prototype.fnREPLACE = function (text, search, replace) {
|
|
927
2337
|
text = this.normalizeText(text);
|
|
@@ -947,7 +2357,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
947
2357
|
* @param {number} start - 起始位置
|
|
948
2358
|
* @namespace 文本函数
|
|
949
2359
|
*
|
|
950
|
-
* @returns {number}
|
|
2360
|
+
* @returns {number} 命中的位置
|
|
951
2361
|
*/
|
|
952
2362
|
Evaluator.prototype.fnSEARCH = function (text, search, start) {
|
|
953
2363
|
if (start === void 0) { start = 0; }
|
|
@@ -968,7 +2378,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
968
2378
|
* @param {number} len - 处理长度
|
|
969
2379
|
* @namespace 文本函数
|
|
970
2380
|
*
|
|
971
|
-
* @returns {number}
|
|
2381
|
+
* @returns {number} 命中的位置
|
|
972
2382
|
*/
|
|
973
2383
|
Evaluator.prototype.fnMID = function (text, from, len) {
|
|
974
2384
|
text = this.normalizeText(text);
|
|
@@ -985,7 +2395,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
985
2395
|
* @example DATE('2021-12-06 08:20:00')
|
|
986
2396
|
* @namespace 日期函数
|
|
987
2397
|
*
|
|
988
|
-
* @returns {Date}
|
|
2398
|
+
* @returns {Date} 日期对象
|
|
989
2399
|
*/
|
|
990
2400
|
Evaluator.prototype.fnDATE = function (year, month, day, hour, minute, second) {
|
|
991
2401
|
if (month === undefined) {
|
|
@@ -1001,7 +2411,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1001
2411
|
* @param {date} date 日期对象
|
|
1002
2412
|
* @param {string} format 时间戳格式,带毫秒传入 'x'。默认为 'X' 不带毫秒的。
|
|
1003
2413
|
*
|
|
1004
|
-
* @returns {number}
|
|
2414
|
+
* @returns {number} 时间戳
|
|
1005
2415
|
*/
|
|
1006
2416
|
Evaluator.prototype.fnTIMESTAMP = function (date, format) {
|
|
1007
2417
|
return parseInt(moment__default["default"](date).format(format === 'x' ? 'x' : 'X'), 10);
|
|
@@ -1012,7 +2422,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1012
2422
|
* @example TODAY()
|
|
1013
2423
|
* @namespace 日期函数
|
|
1014
2424
|
*
|
|
1015
|
-
* @returns {number}
|
|
2425
|
+
* @returns {number} 日期
|
|
1016
2426
|
*/
|
|
1017
2427
|
Evaluator.prototype.fnTODAY = function () {
|
|
1018
2428
|
return new Date();
|
|
@@ -1023,7 +2433,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1023
2433
|
* @example NOW()
|
|
1024
2434
|
* @namespace 日期函数
|
|
1025
2435
|
*
|
|
1026
|
-
* @returns {number}
|
|
2436
|
+
* @returns {number} 日期
|
|
1027
2437
|
*/
|
|
1028
2438
|
Evaluator.prototype.fnNOW = function () {
|
|
1029
2439
|
return new Date();
|
|
@@ -1036,7 +2446,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1036
2446
|
* @param {date} date 日期对象
|
|
1037
2447
|
* @param {string} format 日期格式,默认为 "YYYY-MM-DD HH:mm:ss"
|
|
1038
2448
|
*
|
|
1039
|
-
* @returns {number}
|
|
2449
|
+
* @returns {number} 日期字符串
|
|
1040
2450
|
*/
|
|
1041
2451
|
Evaluator.prototype.fnDATETOSTR = function (date, format) {
|
|
1042
2452
|
if (format === void 0) { format = 'YYYY-MM-DD HH:mm:ss'; }
|
|
@@ -1090,7 +2500,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1090
2500
|
* @namespace 日期函数
|
|
1091
2501
|
* @example YEAR(date)
|
|
1092
2502
|
* @param {date} date 日期对象
|
|
1093
|
-
* @returns {number}
|
|
2503
|
+
* @returns {number} 数值
|
|
1094
2504
|
*/
|
|
1095
2505
|
Evaluator.prototype.fnYEAR = function (date) {
|
|
1096
2506
|
date = this.normalizeDate(date);
|
|
@@ -1102,7 +2512,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1102
2512
|
* @namespace 日期函数
|
|
1103
2513
|
* @example MONTH(date)
|
|
1104
2514
|
* @param {date} date 日期对象
|
|
1105
|
-
* @returns {number}
|
|
2515
|
+
* @returns {number} 数值
|
|
1106
2516
|
*/
|
|
1107
2517
|
Evaluator.prototype.fnMONTH = function (date) {
|
|
1108
2518
|
date = this.normalizeDate(date);
|
|
@@ -1113,7 +2523,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1113
2523
|
* @namespace 日期函数
|
|
1114
2524
|
* @example DAY(date)
|
|
1115
2525
|
* @param {date} date 日期对象
|
|
1116
|
-
* @returns {number}
|
|
2526
|
+
* @returns {number} 数值
|
|
1117
2527
|
*/
|
|
1118
2528
|
Evaluator.prototype.fnDAY = function (date) {
|
|
1119
2529
|
date = this.normalizeDate(date);
|
|
@@ -1124,7 +2534,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1124
2534
|
* @param {date} date 日期对象
|
|
1125
2535
|
* @namespace 日期函数
|
|
1126
2536
|
* @example HOUR(date)
|
|
1127
|
-
* @returns {number}
|
|
2537
|
+
* @returns {number} 数值
|
|
1128
2538
|
*/
|
|
1129
2539
|
Evaluator.prototype.fnHOUR = function (date) {
|
|
1130
2540
|
date = this.normalizeDate(date);
|
|
@@ -1135,7 +2545,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1135
2545
|
* @param {date} date 日期对象
|
|
1136
2546
|
* @namespace 日期函数
|
|
1137
2547
|
* @example MINUTE(date)
|
|
1138
|
-
* @returns {number}
|
|
2548
|
+
* @returns {number} 数值
|
|
1139
2549
|
*/
|
|
1140
2550
|
Evaluator.prototype.fnMINUTE = function (date) {
|
|
1141
2551
|
date = this.normalizeDate(date);
|
|
@@ -1146,7 +2556,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1146
2556
|
* @param {date} date 日期对象
|
|
1147
2557
|
* @namespace 日期函数
|
|
1148
2558
|
* @example SECOND(date)
|
|
1149
|
-
* @returns {number}
|
|
2559
|
+
* @returns {number} 数值
|
|
1150
2560
|
*/
|
|
1151
2561
|
Evaluator.prototype.fnSECOND = function (date) {
|
|
1152
2562
|
date = this.normalizeDate(date);
|
|
@@ -1158,7 +2568,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1158
2568
|
* @param {date} startDate 日期对象
|
|
1159
2569
|
* @namespace 日期函数
|
|
1160
2570
|
* @example YEARS(endDate, startDate)
|
|
1161
|
-
* @returns {number}
|
|
2571
|
+
* @returns {number} 数值
|
|
1162
2572
|
*/
|
|
1163
2573
|
Evaluator.prototype.fnYEARS = function (endDate, startDate) {
|
|
1164
2574
|
endDate = this.normalizeDate(endDate);
|
|
@@ -1171,7 +2581,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1171
2581
|
* @param {date} startDate 日期对象
|
|
1172
2582
|
* @namespace 日期函数
|
|
1173
2583
|
* @example MINUTES(endDate, startDate)
|
|
1174
|
-
* @returns {number}
|
|
2584
|
+
* @returns {number} 数值
|
|
1175
2585
|
*/
|
|
1176
2586
|
Evaluator.prototype.fnMINUTES = function (endDate, startDate) {
|
|
1177
2587
|
endDate = this.normalizeDate(endDate);
|
|
@@ -1184,7 +2594,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1184
2594
|
* @param {date} startDate 日期对象
|
|
1185
2595
|
* @namespace 日期函数
|
|
1186
2596
|
* @example DAYS(endDate, startDate)
|
|
1187
|
-
* @returns {number}
|
|
2597
|
+
* @returns {number} 数值
|
|
1188
2598
|
*/
|
|
1189
2599
|
Evaluator.prototype.fnDAYS = function (endDate, startDate) {
|
|
1190
2600
|
endDate = this.normalizeDate(endDate);
|
|
@@ -1197,7 +2607,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1197
2607
|
* @param {date} startDate 日期对象
|
|
1198
2608
|
* @namespace 日期函数
|
|
1199
2609
|
* @example HOURS(endDate, startDate)
|
|
1200
|
-
* @returns {number}
|
|
2610
|
+
* @returns {number} 数值
|
|
1201
2611
|
*/
|
|
1202
2612
|
Evaluator.prototype.fnHOURS = function (endDate, startDate) {
|
|
1203
2613
|
endDate = this.normalizeDate(endDate);
|
|
@@ -1218,7 +2628,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1218
2628
|
* @param {string} unit 单位:支持年、月、天等等
|
|
1219
2629
|
* @namespace 日期函数
|
|
1220
2630
|
* @example DATEMODIFY(date, 2, 'days')
|
|
1221
|
-
* @returns {date}
|
|
2631
|
+
* @returns {date} 日期对象
|
|
1222
2632
|
*/
|
|
1223
2633
|
Evaluator.prototype.fnDATEMODIFY = function (date, num, format) {
|
|
1224
2634
|
date = this.normalizeDate(date);
|
|
@@ -1233,7 +2643,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1233
2643
|
* @param {string} format 日期格式
|
|
1234
2644
|
* @namespace 日期函数
|
|
1235
2645
|
* @example STRTODATE(value[, format=""])
|
|
1236
|
-
* @returns {date}
|
|
2646
|
+
* @returns {date} 日期对象
|
|
1237
2647
|
*/
|
|
1238
2648
|
Evaluator.prototype.fnSTRTODATE = function (value, format) {
|
|
1239
2649
|
if (format === void 0) { format = ''; }
|
|
@@ -1247,7 +2657,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1247
2657
|
* @param {string} unit 单位,默认是 'day', 即之比较到天
|
|
1248
2658
|
* @namespace 日期函数
|
|
1249
2659
|
* @example ISBEFORE(a, b)
|
|
1250
|
-
* @returns {boolean}
|
|
2660
|
+
* @returns {boolean} 判断结果
|
|
1251
2661
|
*/
|
|
1252
2662
|
Evaluator.prototype.fnISBEFORE = function (a, b, unit) {
|
|
1253
2663
|
if (unit === void 0) { unit = 'day'; }
|
|
@@ -1263,7 +2673,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1263
2673
|
* @param {string} unit 单位,默认是 'day', 即之比较到天
|
|
1264
2674
|
* @namespace 日期函数
|
|
1265
2675
|
* @example ISAFTER(a, b)
|
|
1266
|
-
* @returns {boolean}
|
|
2676
|
+
* @returns {boolean} 判断结果
|
|
1267
2677
|
*/
|
|
1268
2678
|
Evaluator.prototype.fnISAFTER = function (a, b, unit) {
|
|
1269
2679
|
if (unit === void 0) { unit = 'day'; }
|
|
@@ -1279,7 +2689,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1279
2689
|
* @param {string} unit 单位,默认是 'day', 即之比较到天
|
|
1280
2690
|
* @namespace 日期函数
|
|
1281
2691
|
* @example ISSAMEORBEFORE(a, b)
|
|
1282
|
-
* @returns {boolean}
|
|
2692
|
+
* @returns {boolean} 判断结果
|
|
1283
2693
|
*/
|
|
1284
2694
|
Evaluator.prototype.fnISSAMEORBEFORE = function (a, b, unit) {
|
|
1285
2695
|
if (unit === void 0) { unit = 'day'; }
|
|
@@ -1295,7 +2705,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1295
2705
|
* @param {string} unit 单位,默认是 'day', 即之比较到天
|
|
1296
2706
|
* @namespace 日期函数
|
|
1297
2707
|
* @example ISSAMEORAFTER(a, b)
|
|
1298
|
-
* @returns {boolean}
|
|
2708
|
+
* @returns {boolean} 判断结果
|
|
1299
2709
|
*/
|
|
1300
2710
|
Evaluator.prototype.fnISSAMEORAFTER = function (a, b, unit) {
|
|
1301
2711
|
if (unit === void 0) { unit = 'day'; }
|
|
@@ -1309,7 +2719,7 @@ var Evaluator = /** @class */ (function () {
|
|
|
1309
2719
|
* @param {Array<any>} arr 数组
|
|
1310
2720
|
* @namespace 其他
|
|
1311
2721
|
* @example COUNT(arr)
|
|
1312
|
-
* @returns {boolean}
|
|
2722
|
+
* @returns {boolean} 结果
|
|
1313
2723
|
*/
|
|
1314
2724
|
Evaluator.prototype.fnCOUNT = function (value) {
|
|
1315
2725
|
return Array.isArray(value) ? value.length : value ? 1 : 0;
|
|
@@ -3163,7 +4573,12 @@ var filters = {
|
|
|
3163
4573
|
length = parseInt(length, 10) || 200;
|
|
3164
4574
|
return input.substring(0, length) + (input.length > length ? end : '');
|
|
3165
4575
|
},
|
|
3166
|
-
url_encode: function (input) {
|
|
4576
|
+
url_encode: function (input) {
|
|
4577
|
+
if (input == null) {
|
|
4578
|
+
return '';
|
|
4579
|
+
}
|
|
4580
|
+
return encodeURIComponent(input);
|
|
4581
|
+
},
|
|
3167
4582
|
url_decode: function (input) { return decodeURIComponent(input); },
|
|
3168
4583
|
default: function (input, defaultValue, strict) {
|
|
3169
4584
|
var _a;
|
|
@@ -3428,7 +4843,7 @@ var filters = {
|
|
|
3428
4843
|
};
|
|
3429
4844
|
function conditionalFilter(input, hasAlternate, filterContext, test, trueValue, falseValue) {
|
|
3430
4845
|
var _a;
|
|
3431
|
-
hasAlternate && skipRestTest(filterContext.restFilters);
|
|
4846
|
+
(hasAlternate || test) && skipRestTest(filterContext.restFilters);
|
|
3432
4847
|
var result = test ? trueValue : falseValue;
|
|
3433
4848
|
return test || hasAlternate
|
|
3434
4849
|
? (_a = getStrOrVariable(result, filterContext.data)) !== null && _a !== void 0 ? _a : result
|
|
@@ -3477,6 +4892,7 @@ function skipRestTest(restFilters) {
|
|
|
3477
4892
|
}
|
|
3478
4893
|
function registerFilter(name, fn) {
|
|
3479
4894
|
filters[name] = fn;
|
|
4895
|
+
Evaluator.setDefaultFilters(filters);
|
|
3480
4896
|
}
|
|
3481
4897
|
function getFilters() {
|
|
3482
4898
|
return filters;
|