amis-formula 1.2.7 → 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 +251 -0
- package/dist/doc.md +160 -0
- package/dist/evalutor.d.ts +160 -0
- package/dist/index.js +1410 -1
- 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
|
*/
|
|
@@ -660,6 +1814,111 @@ var Evaluator = /** @class */ (function () {
|
|
|
660
1814
|
}
|
|
661
1815
|
return (this.fnSUM.apply(this, args.map(function (item) { return _this.formatNumber(item); })) / args.length);
|
|
662
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
|
+
};
|
|
663
1922
|
/**
|
|
664
1923
|
* 将数值转为中文大写金额
|
|
665
1924
|
*
|
|
@@ -846,6 +2105,105 @@ var Evaluator = /** @class */ (function () {
|
|
|
846
2105
|
text = this.normalizeText(text);
|
|
847
2106
|
return text.toUpperCase();
|
|
848
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
|
+
};
|
|
849
2207
|
/**
|
|
850
2208
|
* 将文本根据指定片段分割成数组
|
|
851
2209
|
*
|
|
@@ -878,6 +2236,40 @@ var Evaluator = /** @class */ (function () {
|
|
|
878
2236
|
text = this.normalizeText(text);
|
|
879
2237
|
return text.trim();
|
|
880
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
|
+
};
|
|
881
2273
|
/**
|
|
882
2274
|
* 判断字符串(text)是否以特定字符串(startString)开始,是则返回 True,否则返回 False
|
|
883
2275
|
*
|
|
@@ -895,6 +2287,23 @@ var Evaluator = /** @class */ (function () {
|
|
|
895
2287
|
text = this.normalizeText(text);
|
|
896
2288
|
return text.indexOf(search) === 0;
|
|
897
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
|
+
};
|
|
898
2307
|
/**
|
|
899
2308
|
* 判断参数 1 中的文本是否包含参数 2 中的文本。
|
|
900
2309
|
*
|