@nuxt/kit 3.5.2 → 3.5.3
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/dist/index.mjs +1977 -10
- package/package.json +11 -11
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import { dirname, normalize, join, relative, isAbsolute, resolve, basename, pars
|
|
|
6
6
|
import { consola } from 'consola';
|
|
7
7
|
import { getContext } from 'unctx';
|
|
8
8
|
import satisfies from 'semver/functions/satisfies.js';
|
|
9
|
-
import lodashTemplate from 'lodash.template';
|
|
10
9
|
import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork';
|
|
11
10
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
12
11
|
import { interopDefault, resolvePath as resolvePath$1 } from 'mlly';
|
|
@@ -93,21 +92,1989 @@ function getNuxtVersion(nuxt = useNuxt()) {
|
|
|
93
92
|
return version;
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
/** Detect free variable `global` from Node.js. */
|
|
96
|
+
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
97
|
+
|
|
98
|
+
const freeGlobal$1 = freeGlobal;
|
|
99
|
+
|
|
100
|
+
/** Detect free variable `self`. */
|
|
101
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
102
|
+
|
|
103
|
+
/** Used as a reference to the global object. */
|
|
104
|
+
var root = freeGlobal$1 || freeSelf || Function('return this')();
|
|
105
|
+
|
|
106
|
+
const root$1 = root;
|
|
107
|
+
|
|
108
|
+
/** Built-in value references. */
|
|
109
|
+
var Symbol = root$1.Symbol;
|
|
110
|
+
|
|
111
|
+
const Symbol$1 = Symbol;
|
|
112
|
+
|
|
113
|
+
/** Used for built-in method references. */
|
|
114
|
+
var objectProto$b = Object.prototype;
|
|
115
|
+
|
|
116
|
+
/** Used to check objects for own properties. */
|
|
117
|
+
var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Used to resolve the
|
|
121
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
122
|
+
* of values.
|
|
123
|
+
*/
|
|
124
|
+
var nativeObjectToString$1 = objectProto$b.toString;
|
|
125
|
+
|
|
126
|
+
/** Built-in value references. */
|
|
127
|
+
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
131
|
+
*
|
|
132
|
+
* @private
|
|
133
|
+
* @param {*} value The value to query.
|
|
134
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
135
|
+
*/
|
|
136
|
+
function getRawTag(value) {
|
|
137
|
+
var isOwn = hasOwnProperty$9.call(value, symToStringTag$1),
|
|
138
|
+
tag = value[symToStringTag$1];
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
value[symToStringTag$1] = undefined;
|
|
142
|
+
var unmasked = true;
|
|
143
|
+
} catch (e) {}
|
|
144
|
+
|
|
145
|
+
var result = nativeObjectToString$1.call(value);
|
|
146
|
+
if (unmasked) {
|
|
147
|
+
if (isOwn) {
|
|
148
|
+
value[symToStringTag$1] = tag;
|
|
149
|
+
} else {
|
|
150
|
+
delete value[symToStringTag$1];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Used for built-in method references. */
|
|
157
|
+
var objectProto$a = Object.prototype;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Used to resolve the
|
|
161
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
162
|
+
* of values.
|
|
163
|
+
*/
|
|
164
|
+
var nativeObjectToString = objectProto$a.toString;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
168
|
+
*
|
|
169
|
+
* @private
|
|
170
|
+
* @param {*} value The value to convert.
|
|
171
|
+
* @returns {string} Returns the converted string.
|
|
172
|
+
*/
|
|
173
|
+
function objectToString(value) {
|
|
174
|
+
return nativeObjectToString.call(value);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** `Object#toString` result references. */
|
|
178
|
+
var nullTag = '[object Null]',
|
|
179
|
+
undefinedTag = '[object Undefined]';
|
|
180
|
+
|
|
181
|
+
/** Built-in value references. */
|
|
182
|
+
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
186
|
+
*
|
|
187
|
+
* @private
|
|
188
|
+
* @param {*} value The value to query.
|
|
189
|
+
* @returns {string} Returns the `toStringTag`.
|
|
190
|
+
*/
|
|
191
|
+
function baseGetTag(value) {
|
|
192
|
+
if (value == null) {
|
|
193
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
194
|
+
}
|
|
195
|
+
return (symToStringTag && symToStringTag in Object(value))
|
|
196
|
+
? getRawTag(value)
|
|
197
|
+
: objectToString(value);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
202
|
+
* and has a `typeof` result of "object".
|
|
203
|
+
*
|
|
204
|
+
* @static
|
|
205
|
+
* @memberOf _
|
|
206
|
+
* @since 4.0.0
|
|
207
|
+
* @category Lang
|
|
208
|
+
* @param {*} value The value to check.
|
|
209
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
210
|
+
* @example
|
|
211
|
+
*
|
|
212
|
+
* _.isObjectLike({});
|
|
213
|
+
* // => true
|
|
214
|
+
*
|
|
215
|
+
* _.isObjectLike([1, 2, 3]);
|
|
216
|
+
* // => true
|
|
217
|
+
*
|
|
218
|
+
* _.isObjectLike(_.noop);
|
|
219
|
+
* // => false
|
|
220
|
+
*
|
|
221
|
+
* _.isObjectLike(null);
|
|
222
|
+
* // => false
|
|
223
|
+
*/
|
|
224
|
+
function isObjectLike(value) {
|
|
225
|
+
return value != null && typeof value == 'object';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** `Object#toString` result references. */
|
|
229
|
+
var symbolTag = '[object Symbol]';
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
233
|
+
*
|
|
234
|
+
* @static
|
|
235
|
+
* @memberOf _
|
|
236
|
+
* @since 4.0.0
|
|
237
|
+
* @category Lang
|
|
238
|
+
* @param {*} value The value to check.
|
|
239
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
240
|
+
* @example
|
|
241
|
+
*
|
|
242
|
+
* _.isSymbol(Symbol.iterator);
|
|
243
|
+
* // => true
|
|
244
|
+
*
|
|
245
|
+
* _.isSymbol('abc');
|
|
246
|
+
* // => false
|
|
247
|
+
*/
|
|
248
|
+
function isSymbol(value) {
|
|
249
|
+
return typeof value == 'symbol' ||
|
|
250
|
+
(isObjectLike(value) && baseGetTag(value) == symbolTag);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* A specialized version of `_.map` for arrays without support for iteratee
|
|
255
|
+
* shorthands.
|
|
256
|
+
*
|
|
257
|
+
* @private
|
|
258
|
+
* @param {Array} [array] The array to iterate over.
|
|
259
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
260
|
+
* @returns {Array} Returns the new mapped array.
|
|
261
|
+
*/
|
|
262
|
+
function arrayMap(array, iteratee) {
|
|
263
|
+
var index = -1,
|
|
264
|
+
length = array == null ? 0 : array.length,
|
|
265
|
+
result = Array(length);
|
|
266
|
+
|
|
267
|
+
while (++index < length) {
|
|
268
|
+
result[index] = iteratee(array[index], index, array);
|
|
269
|
+
}
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Checks if `value` is classified as an `Array` object.
|
|
275
|
+
*
|
|
276
|
+
* @static
|
|
277
|
+
* @memberOf _
|
|
278
|
+
* @since 0.1.0
|
|
279
|
+
* @category Lang
|
|
280
|
+
* @param {*} value The value to check.
|
|
281
|
+
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
282
|
+
* @example
|
|
283
|
+
*
|
|
284
|
+
* _.isArray([1, 2, 3]);
|
|
285
|
+
* // => true
|
|
286
|
+
*
|
|
287
|
+
* _.isArray(document.body.children);
|
|
288
|
+
* // => false
|
|
289
|
+
*
|
|
290
|
+
* _.isArray('abc');
|
|
291
|
+
* // => false
|
|
292
|
+
*
|
|
293
|
+
* _.isArray(_.noop);
|
|
294
|
+
* // => false
|
|
295
|
+
*/
|
|
296
|
+
var isArray = Array.isArray;
|
|
297
|
+
|
|
298
|
+
const isArray$1 = isArray;
|
|
299
|
+
|
|
300
|
+
/** Used as references for various `Number` constants. */
|
|
301
|
+
var INFINITY = 1 / 0;
|
|
302
|
+
|
|
303
|
+
/** Used to convert symbols to primitives and strings. */
|
|
304
|
+
var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
|
|
305
|
+
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* The base implementation of `_.toString` which doesn't convert nullish
|
|
309
|
+
* values to empty strings.
|
|
310
|
+
*
|
|
311
|
+
* @private
|
|
312
|
+
* @param {*} value The value to process.
|
|
313
|
+
* @returns {string} Returns the string.
|
|
314
|
+
*/
|
|
315
|
+
function baseToString(value) {
|
|
316
|
+
// Exit early for strings to avoid a performance hit in some environments.
|
|
317
|
+
if (typeof value == 'string') {
|
|
318
|
+
return value;
|
|
319
|
+
}
|
|
320
|
+
if (isArray$1(value)) {
|
|
321
|
+
// Recursively convert values (susceptible to call stack limits).
|
|
322
|
+
return arrayMap(value, baseToString) + '';
|
|
323
|
+
}
|
|
324
|
+
if (isSymbol(value)) {
|
|
325
|
+
return symbolToString ? symbolToString.call(value) : '';
|
|
326
|
+
}
|
|
327
|
+
var result = (value + '');
|
|
328
|
+
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Checks if `value` is the
|
|
333
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
334
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
335
|
+
*
|
|
336
|
+
* @static
|
|
337
|
+
* @memberOf _
|
|
338
|
+
* @since 0.1.0
|
|
339
|
+
* @category Lang
|
|
340
|
+
* @param {*} value The value to check.
|
|
341
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
342
|
+
* @example
|
|
343
|
+
*
|
|
344
|
+
* _.isObject({});
|
|
345
|
+
* // => true
|
|
346
|
+
*
|
|
347
|
+
* _.isObject([1, 2, 3]);
|
|
348
|
+
* // => true
|
|
349
|
+
*
|
|
350
|
+
* _.isObject(_.noop);
|
|
351
|
+
* // => true
|
|
352
|
+
*
|
|
353
|
+
* _.isObject(null);
|
|
354
|
+
* // => false
|
|
355
|
+
*/
|
|
356
|
+
function isObject(value) {
|
|
357
|
+
var type = typeof value;
|
|
358
|
+
return value != null && (type == 'object' || type == 'function');
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* This method returns the first argument it receives.
|
|
363
|
+
*
|
|
364
|
+
* @static
|
|
365
|
+
* @since 0.1.0
|
|
366
|
+
* @memberOf _
|
|
367
|
+
* @category Util
|
|
368
|
+
* @param {*} value Any value.
|
|
369
|
+
* @returns {*} Returns `value`.
|
|
370
|
+
* @example
|
|
371
|
+
*
|
|
372
|
+
* var object = { 'a': 1 };
|
|
373
|
+
*
|
|
374
|
+
* console.log(_.identity(object) === object);
|
|
375
|
+
* // => true
|
|
376
|
+
*/
|
|
377
|
+
function identity(value) {
|
|
378
|
+
return value;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** `Object#toString` result references. */
|
|
382
|
+
var asyncTag = '[object AsyncFunction]',
|
|
383
|
+
funcTag$1 = '[object Function]',
|
|
384
|
+
genTag = '[object GeneratorFunction]',
|
|
385
|
+
proxyTag = '[object Proxy]';
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Checks if `value` is classified as a `Function` object.
|
|
389
|
+
*
|
|
390
|
+
* @static
|
|
391
|
+
* @memberOf _
|
|
392
|
+
* @since 0.1.0
|
|
393
|
+
* @category Lang
|
|
394
|
+
* @param {*} value The value to check.
|
|
395
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
396
|
+
* @example
|
|
397
|
+
*
|
|
398
|
+
* _.isFunction(_);
|
|
399
|
+
* // => true
|
|
400
|
+
*
|
|
401
|
+
* _.isFunction(/abc/);
|
|
402
|
+
* // => false
|
|
403
|
+
*/
|
|
404
|
+
function isFunction(value) {
|
|
405
|
+
if (!isObject(value)) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
409
|
+
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
410
|
+
var tag = baseGetTag(value);
|
|
411
|
+
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** Used to detect overreaching core-js shims. */
|
|
415
|
+
var coreJsData = root$1['__core-js_shared__'];
|
|
416
|
+
|
|
417
|
+
const coreJsData$1 = coreJsData;
|
|
418
|
+
|
|
419
|
+
/** Used to detect methods masquerading as native. */
|
|
420
|
+
var maskSrcKey = (function() {
|
|
421
|
+
var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || '');
|
|
422
|
+
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
423
|
+
}());
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Checks if `func` has its source masked.
|
|
427
|
+
*
|
|
428
|
+
* @private
|
|
429
|
+
* @param {Function} func The function to check.
|
|
430
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
431
|
+
*/
|
|
432
|
+
function isMasked(func) {
|
|
433
|
+
return !!maskSrcKey && (maskSrcKey in func);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** Used for built-in method references. */
|
|
437
|
+
var funcProto$2 = Function.prototype;
|
|
438
|
+
|
|
439
|
+
/** Used to resolve the decompiled source of functions. */
|
|
440
|
+
var funcToString$2 = funcProto$2.toString;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Converts `func` to its source code.
|
|
444
|
+
*
|
|
445
|
+
* @private
|
|
446
|
+
* @param {Function} func The function to convert.
|
|
447
|
+
* @returns {string} Returns the source code.
|
|
448
|
+
*/
|
|
449
|
+
function toSource(func) {
|
|
450
|
+
if (func != null) {
|
|
451
|
+
try {
|
|
452
|
+
return funcToString$2.call(func);
|
|
453
|
+
} catch (e) {}
|
|
454
|
+
try {
|
|
455
|
+
return (func + '');
|
|
456
|
+
} catch (e) {}
|
|
457
|
+
}
|
|
458
|
+
return '';
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Used to match `RegExp`
|
|
463
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
464
|
+
*/
|
|
465
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
466
|
+
|
|
467
|
+
/** Used to detect host constructors (Safari). */
|
|
468
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
469
|
+
|
|
470
|
+
/** Used for built-in method references. */
|
|
471
|
+
var funcProto$1 = Function.prototype,
|
|
472
|
+
objectProto$9 = Object.prototype;
|
|
473
|
+
|
|
474
|
+
/** Used to resolve the decompiled source of functions. */
|
|
475
|
+
var funcToString$1 = funcProto$1.toString;
|
|
476
|
+
|
|
477
|
+
/** Used to check objects for own properties. */
|
|
478
|
+
var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
|
|
479
|
+
|
|
480
|
+
/** Used to detect if a method is native. */
|
|
481
|
+
var reIsNative = RegExp('^' +
|
|
482
|
+
funcToString$1.call(hasOwnProperty$8).replace(reRegExpChar, '\\$&')
|
|
483
|
+
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
488
|
+
*
|
|
489
|
+
* @private
|
|
490
|
+
* @param {*} value The value to check.
|
|
491
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
492
|
+
* else `false`.
|
|
493
|
+
*/
|
|
494
|
+
function baseIsNative(value) {
|
|
495
|
+
if (!isObject(value) || isMasked(value)) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
|
|
499
|
+
return pattern.test(toSource(value));
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Gets the value at `key` of `object`.
|
|
504
|
+
*
|
|
505
|
+
* @private
|
|
506
|
+
* @param {Object} [object] The object to query.
|
|
507
|
+
* @param {string} key The key of the property to get.
|
|
508
|
+
* @returns {*} Returns the property value.
|
|
509
|
+
*/
|
|
510
|
+
function getValue(object, key) {
|
|
511
|
+
return object == null ? undefined : object[key];
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Gets the native function at `key` of `object`.
|
|
516
|
+
*
|
|
517
|
+
* @private
|
|
518
|
+
* @param {Object} object The object to query.
|
|
519
|
+
* @param {string} key The key of the method to get.
|
|
520
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
521
|
+
*/
|
|
522
|
+
function getNative(object, key) {
|
|
523
|
+
var value = getValue(object, key);
|
|
524
|
+
return baseIsNative(value) ? value : undefined;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* A faster alternative to `Function#apply`, this function invokes `func`
|
|
529
|
+
* with the `this` binding of `thisArg` and the arguments of `args`.
|
|
530
|
+
*
|
|
531
|
+
* @private
|
|
532
|
+
* @param {Function} func The function to invoke.
|
|
533
|
+
* @param {*} thisArg The `this` binding of `func`.
|
|
534
|
+
* @param {Array} args The arguments to invoke `func` with.
|
|
535
|
+
* @returns {*} Returns the result of `func`.
|
|
536
|
+
*/
|
|
537
|
+
function apply(func, thisArg, args) {
|
|
538
|
+
switch (args.length) {
|
|
539
|
+
case 0: return func.call(thisArg);
|
|
540
|
+
case 1: return func.call(thisArg, args[0]);
|
|
541
|
+
case 2: return func.call(thisArg, args[0], args[1]);
|
|
542
|
+
case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
|
543
|
+
}
|
|
544
|
+
return func.apply(thisArg, args);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/** Used to detect hot functions by number of calls within a span of milliseconds. */
|
|
548
|
+
var HOT_COUNT = 800,
|
|
549
|
+
HOT_SPAN = 16;
|
|
550
|
+
|
|
551
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
552
|
+
var nativeNow = Date.now;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Creates a function that'll short out and invoke `identity` instead
|
|
556
|
+
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
|
|
557
|
+
* milliseconds.
|
|
558
|
+
*
|
|
559
|
+
* @private
|
|
560
|
+
* @param {Function} func The function to restrict.
|
|
561
|
+
* @returns {Function} Returns the new shortable function.
|
|
562
|
+
*/
|
|
563
|
+
function shortOut(func) {
|
|
564
|
+
var count = 0,
|
|
565
|
+
lastCalled = 0;
|
|
566
|
+
|
|
567
|
+
return function() {
|
|
568
|
+
var stamp = nativeNow(),
|
|
569
|
+
remaining = HOT_SPAN - (stamp - lastCalled);
|
|
570
|
+
|
|
571
|
+
lastCalled = stamp;
|
|
572
|
+
if (remaining > 0) {
|
|
573
|
+
if (++count >= HOT_COUNT) {
|
|
574
|
+
return arguments[0];
|
|
575
|
+
}
|
|
576
|
+
} else {
|
|
577
|
+
count = 0;
|
|
578
|
+
}
|
|
579
|
+
return func.apply(undefined, arguments);
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Creates a function that returns `value`.
|
|
585
|
+
*
|
|
586
|
+
* @static
|
|
587
|
+
* @memberOf _
|
|
588
|
+
* @since 2.4.0
|
|
589
|
+
* @category Util
|
|
590
|
+
* @param {*} value The value to return from the new function.
|
|
591
|
+
* @returns {Function} Returns the new constant function.
|
|
592
|
+
* @example
|
|
593
|
+
*
|
|
594
|
+
* var objects = _.times(2, _.constant({ 'a': 1 }));
|
|
595
|
+
*
|
|
596
|
+
* console.log(objects);
|
|
597
|
+
* // => [{ 'a': 1 }, { 'a': 1 }]
|
|
598
|
+
*
|
|
599
|
+
* console.log(objects[0] === objects[1]);
|
|
600
|
+
* // => true
|
|
601
|
+
*/
|
|
602
|
+
function constant(value) {
|
|
603
|
+
return function() {
|
|
604
|
+
return value;
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
var defineProperty = (function() {
|
|
609
|
+
try {
|
|
610
|
+
var func = getNative(Object, 'defineProperty');
|
|
611
|
+
func({}, '', {});
|
|
612
|
+
return func;
|
|
613
|
+
} catch (e) {}
|
|
614
|
+
}());
|
|
615
|
+
|
|
616
|
+
const defineProperty$1 = defineProperty;
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* The base implementation of `setToString` without support for hot loop shorting.
|
|
620
|
+
*
|
|
621
|
+
* @private
|
|
622
|
+
* @param {Function} func The function to modify.
|
|
623
|
+
* @param {Function} string The `toString` result.
|
|
624
|
+
* @returns {Function} Returns `func`.
|
|
625
|
+
*/
|
|
626
|
+
var baseSetToString = !defineProperty$1 ? identity : function(func, string) {
|
|
627
|
+
return defineProperty$1(func, 'toString', {
|
|
628
|
+
'configurable': true,
|
|
629
|
+
'enumerable': false,
|
|
630
|
+
'value': constant(string),
|
|
631
|
+
'writable': true
|
|
632
|
+
});
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
const baseSetToString$1 = baseSetToString;
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Sets the `toString` method of `func` to return `string`.
|
|
639
|
+
*
|
|
640
|
+
* @private
|
|
641
|
+
* @param {Function} func The function to modify.
|
|
642
|
+
* @param {Function} string The `toString` result.
|
|
643
|
+
* @returns {Function} Returns `func`.
|
|
644
|
+
*/
|
|
645
|
+
var setToString = shortOut(baseSetToString$1);
|
|
646
|
+
|
|
647
|
+
const setToString$1 = setToString;
|
|
648
|
+
|
|
649
|
+
/** Used as references for various `Number` constants. */
|
|
650
|
+
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
|
651
|
+
|
|
652
|
+
/** Used to detect unsigned integer values. */
|
|
653
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Checks if `value` is a valid array-like index.
|
|
657
|
+
*
|
|
658
|
+
* @private
|
|
659
|
+
* @param {*} value The value to check.
|
|
660
|
+
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
|
|
661
|
+
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
|
|
662
|
+
*/
|
|
663
|
+
function isIndex(value, length) {
|
|
664
|
+
var type = typeof value;
|
|
665
|
+
length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
|
666
|
+
|
|
667
|
+
return !!length &&
|
|
668
|
+
(type == 'number' ||
|
|
669
|
+
(type != 'symbol' && reIsUint.test(value))) &&
|
|
670
|
+
(value > -1 && value % 1 == 0 && value < length);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* The base implementation of `assignValue` and `assignMergeValue` without
|
|
675
|
+
* value checks.
|
|
676
|
+
*
|
|
677
|
+
* @private
|
|
678
|
+
* @param {Object} object The object to modify.
|
|
679
|
+
* @param {string} key The key of the property to assign.
|
|
680
|
+
* @param {*} value The value to assign.
|
|
681
|
+
*/
|
|
682
|
+
function baseAssignValue(object, key, value) {
|
|
683
|
+
if (key == '__proto__' && defineProperty$1) {
|
|
684
|
+
defineProperty$1(object, key, {
|
|
685
|
+
'configurable': true,
|
|
686
|
+
'enumerable': true,
|
|
687
|
+
'value': value,
|
|
688
|
+
'writable': true
|
|
689
|
+
});
|
|
690
|
+
} else {
|
|
691
|
+
object[key] = value;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Performs a
|
|
697
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
698
|
+
* comparison between two values to determine if they are equivalent.
|
|
699
|
+
*
|
|
700
|
+
* @static
|
|
701
|
+
* @memberOf _
|
|
702
|
+
* @since 4.0.0
|
|
703
|
+
* @category Lang
|
|
704
|
+
* @param {*} value The value to compare.
|
|
705
|
+
* @param {*} other The other value to compare.
|
|
706
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
707
|
+
* @example
|
|
708
|
+
*
|
|
709
|
+
* var object = { 'a': 1 };
|
|
710
|
+
* var other = { 'a': 1 };
|
|
711
|
+
*
|
|
712
|
+
* _.eq(object, object);
|
|
713
|
+
* // => true
|
|
714
|
+
*
|
|
715
|
+
* _.eq(object, other);
|
|
716
|
+
* // => false
|
|
717
|
+
*
|
|
718
|
+
* _.eq('a', 'a');
|
|
719
|
+
* // => true
|
|
720
|
+
*
|
|
721
|
+
* _.eq('a', Object('a'));
|
|
722
|
+
* // => false
|
|
723
|
+
*
|
|
724
|
+
* _.eq(NaN, NaN);
|
|
725
|
+
* // => true
|
|
726
|
+
*/
|
|
727
|
+
function eq(value, other) {
|
|
728
|
+
return value === other || (value !== value && other !== other);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/** Used for built-in method references. */
|
|
732
|
+
var objectProto$8 = Object.prototype;
|
|
733
|
+
|
|
734
|
+
/** Used to check objects for own properties. */
|
|
735
|
+
var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Assigns `value` to `key` of `object` if the existing value is not equivalent
|
|
739
|
+
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
740
|
+
* for equality comparisons.
|
|
741
|
+
*
|
|
742
|
+
* @private
|
|
743
|
+
* @param {Object} object The object to modify.
|
|
744
|
+
* @param {string} key The key of the property to assign.
|
|
745
|
+
* @param {*} value The value to assign.
|
|
746
|
+
*/
|
|
747
|
+
function assignValue(object, key, value) {
|
|
748
|
+
var objValue = object[key];
|
|
749
|
+
if (!(hasOwnProperty$7.call(object, key) && eq(objValue, value)) ||
|
|
750
|
+
(value === undefined && !(key in object))) {
|
|
751
|
+
baseAssignValue(object, key, value);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Copies properties of `source` to `object`.
|
|
757
|
+
*
|
|
758
|
+
* @private
|
|
759
|
+
* @param {Object} source The object to copy properties from.
|
|
760
|
+
* @param {Array} props The property identifiers to copy.
|
|
761
|
+
* @param {Object} [object={}] The object to copy properties to.
|
|
762
|
+
* @param {Function} [customizer] The function to customize copied values.
|
|
763
|
+
* @returns {Object} Returns `object`.
|
|
764
|
+
*/
|
|
765
|
+
function copyObject(source, props, object, customizer) {
|
|
766
|
+
var isNew = !object;
|
|
767
|
+
object || (object = {});
|
|
768
|
+
|
|
769
|
+
var index = -1,
|
|
770
|
+
length = props.length;
|
|
771
|
+
|
|
772
|
+
while (++index < length) {
|
|
773
|
+
var key = props[index];
|
|
774
|
+
|
|
775
|
+
var newValue = customizer
|
|
776
|
+
? customizer(object[key], source[key], key, object, source)
|
|
777
|
+
: undefined;
|
|
778
|
+
|
|
779
|
+
if (newValue === undefined) {
|
|
780
|
+
newValue = source[key];
|
|
781
|
+
}
|
|
782
|
+
if (isNew) {
|
|
783
|
+
baseAssignValue(object, key, newValue);
|
|
784
|
+
} else {
|
|
785
|
+
assignValue(object, key, newValue);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
return object;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
792
|
+
var nativeMax = Math.max;
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* A specialized version of `baseRest` which transforms the rest array.
|
|
796
|
+
*
|
|
797
|
+
* @private
|
|
798
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
799
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
800
|
+
* @param {Function} transform The rest array transform.
|
|
801
|
+
* @returns {Function} Returns the new function.
|
|
802
|
+
*/
|
|
803
|
+
function overRest(func, start, transform) {
|
|
804
|
+
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
|
805
|
+
return function() {
|
|
806
|
+
var args = arguments,
|
|
807
|
+
index = -1,
|
|
808
|
+
length = nativeMax(args.length - start, 0),
|
|
809
|
+
array = Array(length);
|
|
810
|
+
|
|
811
|
+
while (++index < length) {
|
|
812
|
+
array[index] = args[start + index];
|
|
813
|
+
}
|
|
814
|
+
index = -1;
|
|
815
|
+
var otherArgs = Array(start + 1);
|
|
816
|
+
while (++index < start) {
|
|
817
|
+
otherArgs[index] = args[index];
|
|
818
|
+
}
|
|
819
|
+
otherArgs[start] = transform(array);
|
|
820
|
+
return apply(func, this, otherArgs);
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
|
|
826
|
+
*
|
|
827
|
+
* @private
|
|
828
|
+
* @param {Function} func The function to apply a rest parameter to.
|
|
829
|
+
* @param {number} [start=func.length-1] The start position of the rest parameter.
|
|
830
|
+
* @returns {Function} Returns the new function.
|
|
831
|
+
*/
|
|
832
|
+
function baseRest(func, start) {
|
|
833
|
+
return setToString$1(overRest(func, start, identity), func + '');
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/** Used as references for various `Number` constants. */
|
|
837
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Checks if `value` is a valid array-like length.
|
|
841
|
+
*
|
|
842
|
+
* **Note:** This method is loosely based on
|
|
843
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
844
|
+
*
|
|
845
|
+
* @static
|
|
846
|
+
* @memberOf _
|
|
847
|
+
* @since 4.0.0
|
|
848
|
+
* @category Lang
|
|
849
|
+
* @param {*} value The value to check.
|
|
850
|
+
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
851
|
+
* @example
|
|
852
|
+
*
|
|
853
|
+
* _.isLength(3);
|
|
854
|
+
* // => true
|
|
855
|
+
*
|
|
856
|
+
* _.isLength(Number.MIN_VALUE);
|
|
857
|
+
* // => false
|
|
858
|
+
*
|
|
859
|
+
* _.isLength(Infinity);
|
|
860
|
+
* // => false
|
|
861
|
+
*
|
|
862
|
+
* _.isLength('3');
|
|
863
|
+
* // => false
|
|
864
|
+
*/
|
|
865
|
+
function isLength(value) {
|
|
866
|
+
return typeof value == 'number' &&
|
|
867
|
+
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
872
|
+
* not a function and has a `value.length` that's an integer greater than or
|
|
873
|
+
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
874
|
+
*
|
|
875
|
+
* @static
|
|
876
|
+
* @memberOf _
|
|
877
|
+
* @since 4.0.0
|
|
878
|
+
* @category Lang
|
|
879
|
+
* @param {*} value The value to check.
|
|
880
|
+
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
881
|
+
* @example
|
|
882
|
+
*
|
|
883
|
+
* _.isArrayLike([1, 2, 3]);
|
|
884
|
+
* // => true
|
|
885
|
+
*
|
|
886
|
+
* _.isArrayLike(document.body.children);
|
|
887
|
+
* // => true
|
|
888
|
+
*
|
|
889
|
+
* _.isArrayLike('abc');
|
|
890
|
+
* // => true
|
|
891
|
+
*
|
|
892
|
+
* _.isArrayLike(_.noop);
|
|
893
|
+
* // => false
|
|
894
|
+
*/
|
|
895
|
+
function isArrayLike(value) {
|
|
896
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Checks if the given arguments are from an iteratee call.
|
|
901
|
+
*
|
|
902
|
+
* @private
|
|
903
|
+
* @param {*} value The potential iteratee value argument.
|
|
904
|
+
* @param {*} index The potential iteratee index or key argument.
|
|
905
|
+
* @param {*} object The potential iteratee object argument.
|
|
906
|
+
* @returns {boolean} Returns `true` if the arguments are from an iteratee call,
|
|
907
|
+
* else `false`.
|
|
908
|
+
*/
|
|
909
|
+
function isIterateeCall(value, index, object) {
|
|
910
|
+
if (!isObject(object)) {
|
|
911
|
+
return false;
|
|
912
|
+
}
|
|
913
|
+
var type = typeof index;
|
|
914
|
+
if (type == 'number'
|
|
915
|
+
? (isArrayLike(object) && isIndex(index, object.length))
|
|
916
|
+
: (type == 'string' && index in object)
|
|
917
|
+
) {
|
|
918
|
+
return eq(object[index], value);
|
|
919
|
+
}
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* Creates a function like `_.assign`.
|
|
925
|
+
*
|
|
926
|
+
* @private
|
|
927
|
+
* @param {Function} assigner The function to assign values.
|
|
928
|
+
* @returns {Function} Returns the new assigner function.
|
|
929
|
+
*/
|
|
930
|
+
function createAssigner(assigner) {
|
|
931
|
+
return baseRest(function(object, sources) {
|
|
932
|
+
var index = -1,
|
|
933
|
+
length = sources.length,
|
|
934
|
+
customizer = length > 1 ? sources[length - 1] : undefined,
|
|
935
|
+
guard = length > 2 ? sources[2] : undefined;
|
|
936
|
+
|
|
937
|
+
customizer = (assigner.length > 3 && typeof customizer == 'function')
|
|
938
|
+
? (length--, customizer)
|
|
939
|
+
: undefined;
|
|
940
|
+
|
|
941
|
+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|
942
|
+
customizer = length < 3 ? undefined : customizer;
|
|
943
|
+
length = 1;
|
|
944
|
+
}
|
|
945
|
+
object = Object(object);
|
|
946
|
+
while (++index < length) {
|
|
947
|
+
var source = sources[index];
|
|
948
|
+
if (source) {
|
|
949
|
+
assigner(object, source, index, customizer);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
return object;
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/** Used for built-in method references. */
|
|
957
|
+
var objectProto$7 = Object.prototype;
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Checks if `value` is likely a prototype object.
|
|
961
|
+
*
|
|
962
|
+
* @private
|
|
963
|
+
* @param {*} value The value to check.
|
|
964
|
+
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
965
|
+
*/
|
|
966
|
+
function isPrototype(value) {
|
|
967
|
+
var Ctor = value && value.constructor,
|
|
968
|
+
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$7;
|
|
969
|
+
|
|
970
|
+
return value === proto;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* The base implementation of `_.times` without support for iteratee shorthands
|
|
975
|
+
* or max array length checks.
|
|
976
|
+
*
|
|
977
|
+
* @private
|
|
978
|
+
* @param {number} n The number of times to invoke `iteratee`.
|
|
979
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
980
|
+
* @returns {Array} Returns the array of results.
|
|
981
|
+
*/
|
|
982
|
+
function baseTimes(n, iteratee) {
|
|
983
|
+
var index = -1,
|
|
984
|
+
result = Array(n);
|
|
985
|
+
|
|
986
|
+
while (++index < n) {
|
|
987
|
+
result[index] = iteratee(index);
|
|
988
|
+
}
|
|
989
|
+
return result;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/** `Object#toString` result references. */
|
|
993
|
+
var argsTag$1 = '[object Arguments]';
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* The base implementation of `_.isArguments`.
|
|
997
|
+
*
|
|
998
|
+
* @private
|
|
999
|
+
* @param {*} value The value to check.
|
|
1000
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
1001
|
+
*/
|
|
1002
|
+
function baseIsArguments(value) {
|
|
1003
|
+
return isObjectLike(value) && baseGetTag(value) == argsTag$1;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
/** Used for built-in method references. */
|
|
1007
|
+
var objectProto$6 = Object.prototype;
|
|
1008
|
+
|
|
1009
|
+
/** Used to check objects for own properties. */
|
|
1010
|
+
var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
|
|
1011
|
+
|
|
1012
|
+
/** Built-in value references. */
|
|
1013
|
+
var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Checks if `value` is likely an `arguments` object.
|
|
1017
|
+
*
|
|
1018
|
+
* @static
|
|
1019
|
+
* @memberOf _
|
|
1020
|
+
* @since 0.1.0
|
|
1021
|
+
* @category Lang
|
|
1022
|
+
* @param {*} value The value to check.
|
|
1023
|
+
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
1024
|
+
* else `false`.
|
|
1025
|
+
* @example
|
|
1026
|
+
*
|
|
1027
|
+
* _.isArguments(function() { return arguments; }());
|
|
1028
|
+
* // => true
|
|
1029
|
+
*
|
|
1030
|
+
* _.isArguments([1, 2, 3]);
|
|
1031
|
+
* // => false
|
|
1032
|
+
*/
|
|
1033
|
+
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
1034
|
+
return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') &&
|
|
1035
|
+
!propertyIsEnumerable.call(value, 'callee');
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
const isArguments$1 = isArguments;
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* This method returns `false`.
|
|
1042
|
+
*
|
|
1043
|
+
* @static
|
|
1044
|
+
* @memberOf _
|
|
1045
|
+
* @since 4.13.0
|
|
1046
|
+
* @category Util
|
|
1047
|
+
* @returns {boolean} Returns `false`.
|
|
1048
|
+
* @example
|
|
1049
|
+
*
|
|
1050
|
+
* _.times(2, _.stubFalse);
|
|
1051
|
+
* // => [false, false]
|
|
1052
|
+
*/
|
|
1053
|
+
function stubFalse() {
|
|
1054
|
+
return false;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/** Detect free variable `exports`. */
|
|
1058
|
+
var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
1059
|
+
|
|
1060
|
+
/** Detect free variable `module`. */
|
|
1061
|
+
var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
|
|
1062
|
+
|
|
1063
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1064
|
+
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
|
|
1065
|
+
|
|
1066
|
+
/** Built-in value references. */
|
|
1067
|
+
var Buffer = moduleExports$1 ? root$1.Buffer : undefined;
|
|
1068
|
+
|
|
1069
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
1070
|
+
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Checks if `value` is a buffer.
|
|
1074
|
+
*
|
|
1075
|
+
* @static
|
|
1076
|
+
* @memberOf _
|
|
1077
|
+
* @since 4.3.0
|
|
1078
|
+
* @category Lang
|
|
1079
|
+
* @param {*} value The value to check.
|
|
1080
|
+
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
1081
|
+
* @example
|
|
1082
|
+
*
|
|
1083
|
+
* _.isBuffer(new Buffer(2));
|
|
1084
|
+
* // => true
|
|
1085
|
+
*
|
|
1086
|
+
* _.isBuffer(new Uint8Array(2));
|
|
1087
|
+
* // => false
|
|
1088
|
+
*/
|
|
1089
|
+
var isBuffer = nativeIsBuffer || stubFalse;
|
|
1090
|
+
|
|
1091
|
+
const isBuffer$1 = isBuffer;
|
|
1092
|
+
|
|
1093
|
+
/** `Object#toString` result references. */
|
|
1094
|
+
var argsTag = '[object Arguments]',
|
|
1095
|
+
arrayTag = '[object Array]',
|
|
1096
|
+
boolTag = '[object Boolean]',
|
|
1097
|
+
dateTag = '[object Date]',
|
|
1098
|
+
errorTag$1 = '[object Error]',
|
|
1099
|
+
funcTag = '[object Function]',
|
|
1100
|
+
mapTag = '[object Map]',
|
|
1101
|
+
numberTag = '[object Number]',
|
|
1102
|
+
objectTag$1 = '[object Object]',
|
|
1103
|
+
regexpTag = '[object RegExp]',
|
|
1104
|
+
setTag = '[object Set]',
|
|
1105
|
+
stringTag = '[object String]',
|
|
1106
|
+
weakMapTag = '[object WeakMap]';
|
|
1107
|
+
|
|
1108
|
+
var arrayBufferTag = '[object ArrayBuffer]',
|
|
1109
|
+
dataViewTag = '[object DataView]',
|
|
1110
|
+
float32Tag = '[object Float32Array]',
|
|
1111
|
+
float64Tag = '[object Float64Array]',
|
|
1112
|
+
int8Tag = '[object Int8Array]',
|
|
1113
|
+
int16Tag = '[object Int16Array]',
|
|
1114
|
+
int32Tag = '[object Int32Array]',
|
|
1115
|
+
uint8Tag = '[object Uint8Array]',
|
|
1116
|
+
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
1117
|
+
uint16Tag = '[object Uint16Array]',
|
|
1118
|
+
uint32Tag = '[object Uint32Array]';
|
|
1119
|
+
|
|
1120
|
+
/** Used to identify `toStringTag` values of typed arrays. */
|
|
1121
|
+
var typedArrayTags = {};
|
|
1122
|
+
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
1123
|
+
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
1124
|
+
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
1125
|
+
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
1126
|
+
typedArrayTags[uint32Tag] = true;
|
|
1127
|
+
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
|
1128
|
+
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
|
1129
|
+
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
|
1130
|
+
typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
|
|
1131
|
+
typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
|
1132
|
+
typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
|
|
1133
|
+
typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
|
1134
|
+
typedArrayTags[weakMapTag] = false;
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
1138
|
+
*
|
|
1139
|
+
* @private
|
|
1140
|
+
* @param {*} value The value to check.
|
|
1141
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
1142
|
+
*/
|
|
1143
|
+
function baseIsTypedArray(value) {
|
|
1144
|
+
return isObjectLike(value) &&
|
|
1145
|
+
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* The base implementation of `_.unary` without support for storing metadata.
|
|
1150
|
+
*
|
|
1151
|
+
* @private
|
|
1152
|
+
* @param {Function} func The function to cap arguments for.
|
|
1153
|
+
* @returns {Function} Returns the new capped function.
|
|
1154
|
+
*/
|
|
1155
|
+
function baseUnary(func) {
|
|
1156
|
+
return function(value) {
|
|
1157
|
+
return func(value);
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/** Detect free variable `exports`. */
|
|
1162
|
+
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
|
|
1163
|
+
|
|
1164
|
+
/** Detect free variable `module`. */
|
|
1165
|
+
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
|
|
1166
|
+
|
|
1167
|
+
/** Detect the popular CommonJS extension `module.exports`. */
|
|
1168
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
1169
|
+
|
|
1170
|
+
/** Detect free variable `process` from Node.js. */
|
|
1171
|
+
var freeProcess = moduleExports && freeGlobal$1.process;
|
|
1172
|
+
|
|
1173
|
+
/** Used to access faster Node.js helpers. */
|
|
1174
|
+
var nodeUtil = (function() {
|
|
1175
|
+
try {
|
|
1176
|
+
// Use `util.types` for Node.js 10+.
|
|
1177
|
+
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
1178
|
+
|
|
1179
|
+
if (types) {
|
|
1180
|
+
return types;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
// Legacy `process.binding('util')` for Node.js < 10.
|
|
1184
|
+
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
1185
|
+
} catch (e) {}
|
|
1186
|
+
}());
|
|
1187
|
+
|
|
1188
|
+
const nodeUtil$1 = nodeUtil;
|
|
1189
|
+
|
|
1190
|
+
/* Node.js helper references. */
|
|
1191
|
+
var nodeIsTypedArray = nodeUtil$1 && nodeUtil$1.isTypedArray;
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Checks if `value` is classified as a typed array.
|
|
1195
|
+
*
|
|
1196
|
+
* @static
|
|
1197
|
+
* @memberOf _
|
|
1198
|
+
* @since 3.0.0
|
|
1199
|
+
* @category Lang
|
|
1200
|
+
* @param {*} value The value to check.
|
|
1201
|
+
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
1202
|
+
* @example
|
|
1203
|
+
*
|
|
1204
|
+
* _.isTypedArray(new Uint8Array);
|
|
1205
|
+
* // => true
|
|
1206
|
+
*
|
|
1207
|
+
* _.isTypedArray([]);
|
|
1208
|
+
* // => false
|
|
1209
|
+
*/
|
|
1210
|
+
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
1211
|
+
|
|
1212
|
+
const isTypedArray$1 = isTypedArray;
|
|
1213
|
+
|
|
1214
|
+
/** Used for built-in method references. */
|
|
1215
|
+
var objectProto$5 = Object.prototype;
|
|
1216
|
+
|
|
1217
|
+
/** Used to check objects for own properties. */
|
|
1218
|
+
var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Creates an array of the enumerable property names of the array-like `value`.
|
|
1222
|
+
*
|
|
1223
|
+
* @private
|
|
1224
|
+
* @param {*} value The value to query.
|
|
1225
|
+
* @param {boolean} inherited Specify returning inherited property names.
|
|
1226
|
+
* @returns {Array} Returns the array of property names.
|
|
1227
|
+
*/
|
|
1228
|
+
function arrayLikeKeys(value, inherited) {
|
|
1229
|
+
var isArr = isArray$1(value),
|
|
1230
|
+
isArg = !isArr && isArguments$1(value),
|
|
1231
|
+
isBuff = !isArr && !isArg && isBuffer$1(value),
|
|
1232
|
+
isType = !isArr && !isArg && !isBuff && isTypedArray$1(value),
|
|
1233
|
+
skipIndexes = isArr || isArg || isBuff || isType,
|
|
1234
|
+
result = skipIndexes ? baseTimes(value.length, String) : [],
|
|
1235
|
+
length = result.length;
|
|
1236
|
+
|
|
1237
|
+
for (var key in value) {
|
|
1238
|
+
if ((inherited || hasOwnProperty$5.call(value, key)) &&
|
|
1239
|
+
!(skipIndexes && (
|
|
1240
|
+
// Safari 9 has enumerable `arguments.length` in strict mode.
|
|
1241
|
+
key == 'length' ||
|
|
1242
|
+
// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
1243
|
+
(isBuff && (key == 'offset' || key == 'parent')) ||
|
|
1244
|
+
// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
1245
|
+
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
|
1246
|
+
// Skip index properties.
|
|
1247
|
+
isIndex(key, length)
|
|
1248
|
+
))) {
|
|
1249
|
+
result.push(key);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
return result;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
/**
|
|
1256
|
+
* Creates a unary function that invokes `func` with its argument transformed.
|
|
1257
|
+
*
|
|
1258
|
+
* @private
|
|
1259
|
+
* @param {Function} func The function to wrap.
|
|
1260
|
+
* @param {Function} transform The argument transform.
|
|
1261
|
+
* @returns {Function} Returns the new function.
|
|
1262
|
+
*/
|
|
1263
|
+
function overArg(func, transform) {
|
|
1264
|
+
return function(arg) {
|
|
1265
|
+
return func(transform(arg));
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
1270
|
+
var nativeKeys = overArg(Object.keys, Object);
|
|
1271
|
+
|
|
1272
|
+
const nativeKeys$1 = nativeKeys;
|
|
1273
|
+
|
|
1274
|
+
/** Used for built-in method references. */
|
|
1275
|
+
var objectProto$4 = Object.prototype;
|
|
1276
|
+
|
|
1277
|
+
/** Used to check objects for own properties. */
|
|
1278
|
+
var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|
1282
|
+
*
|
|
1283
|
+
* @private
|
|
1284
|
+
* @param {Object} object The object to query.
|
|
1285
|
+
* @returns {Array} Returns the array of property names.
|
|
1286
|
+
*/
|
|
1287
|
+
function baseKeys(object) {
|
|
1288
|
+
if (!isPrototype(object)) {
|
|
1289
|
+
return nativeKeys$1(object);
|
|
1290
|
+
}
|
|
1291
|
+
var result = [];
|
|
1292
|
+
for (var key in Object(object)) {
|
|
1293
|
+
if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
|
|
1294
|
+
result.push(key);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
return result;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* Creates an array of the own enumerable property names of `object`.
|
|
1302
|
+
*
|
|
1303
|
+
* **Note:** Non-object values are coerced to objects. See the
|
|
1304
|
+
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|
1305
|
+
* for more details.
|
|
1306
|
+
*
|
|
1307
|
+
* @static
|
|
1308
|
+
* @since 0.1.0
|
|
1309
|
+
* @memberOf _
|
|
1310
|
+
* @category Object
|
|
1311
|
+
* @param {Object} object The object to query.
|
|
1312
|
+
* @returns {Array} Returns the array of property names.
|
|
1313
|
+
* @example
|
|
1314
|
+
*
|
|
1315
|
+
* function Foo() {
|
|
1316
|
+
* this.a = 1;
|
|
1317
|
+
* this.b = 2;
|
|
1318
|
+
* }
|
|
1319
|
+
*
|
|
1320
|
+
* Foo.prototype.c = 3;
|
|
1321
|
+
*
|
|
1322
|
+
* _.keys(new Foo);
|
|
1323
|
+
* // => ['a', 'b'] (iteration order is not guaranteed)
|
|
1324
|
+
*
|
|
1325
|
+
* _.keys('hi');
|
|
1326
|
+
* // => ['0', '1']
|
|
1327
|
+
*/
|
|
1328
|
+
function keys(object) {
|
|
1329
|
+
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* This function is like
|
|
1334
|
+
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
|
1335
|
+
* except that it includes inherited enumerable properties.
|
|
1336
|
+
*
|
|
1337
|
+
* @private
|
|
1338
|
+
* @param {Object} object The object to query.
|
|
1339
|
+
* @returns {Array} Returns the array of property names.
|
|
1340
|
+
*/
|
|
1341
|
+
function nativeKeysIn(object) {
|
|
1342
|
+
var result = [];
|
|
1343
|
+
if (object != null) {
|
|
1344
|
+
for (var key in Object(object)) {
|
|
1345
|
+
result.push(key);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
return result;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
/** Used for built-in method references. */
|
|
1352
|
+
var objectProto$3 = Object.prototype;
|
|
1353
|
+
|
|
1354
|
+
/** Used to check objects for own properties. */
|
|
1355
|
+
var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
|
|
1359
|
+
*
|
|
1360
|
+
* @private
|
|
1361
|
+
* @param {Object} object The object to query.
|
|
1362
|
+
* @returns {Array} Returns the array of property names.
|
|
1363
|
+
*/
|
|
1364
|
+
function baseKeysIn(object) {
|
|
1365
|
+
if (!isObject(object)) {
|
|
1366
|
+
return nativeKeysIn(object);
|
|
1367
|
+
}
|
|
1368
|
+
var isProto = isPrototype(object),
|
|
1369
|
+
result = [];
|
|
1370
|
+
|
|
1371
|
+
for (var key in object) {
|
|
1372
|
+
if (!(key == 'constructor' && (isProto || !hasOwnProperty$3.call(object, key)))) {
|
|
1373
|
+
result.push(key);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return result;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Creates an array of the own and inherited enumerable property names of `object`.
|
|
1381
|
+
*
|
|
1382
|
+
* **Note:** Non-object values are coerced to objects.
|
|
1383
|
+
*
|
|
1384
|
+
* @static
|
|
1385
|
+
* @memberOf _
|
|
1386
|
+
* @since 3.0.0
|
|
1387
|
+
* @category Object
|
|
1388
|
+
* @param {Object} object The object to query.
|
|
1389
|
+
* @returns {Array} Returns the array of property names.
|
|
1390
|
+
* @example
|
|
1391
|
+
*
|
|
1392
|
+
* function Foo() {
|
|
1393
|
+
* this.a = 1;
|
|
1394
|
+
* this.b = 2;
|
|
1395
|
+
* }
|
|
1396
|
+
*
|
|
1397
|
+
* Foo.prototype.c = 3;
|
|
1398
|
+
*
|
|
1399
|
+
* _.keysIn(new Foo);
|
|
1400
|
+
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
|
|
1401
|
+
*/
|
|
1402
|
+
function keysIn(object) {
|
|
1403
|
+
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* This method is like `_.assignIn` except that it accepts `customizer`
|
|
1408
|
+
* which is invoked to produce the assigned values. If `customizer` returns
|
|
1409
|
+
* `undefined`, assignment is handled by the method instead. The `customizer`
|
|
1410
|
+
* is invoked with five arguments: (objValue, srcValue, key, object, source).
|
|
1411
|
+
*
|
|
1412
|
+
* **Note:** This method mutates `object`.
|
|
1413
|
+
*
|
|
1414
|
+
* @static
|
|
1415
|
+
* @memberOf _
|
|
1416
|
+
* @since 4.0.0
|
|
1417
|
+
* @alias extendWith
|
|
1418
|
+
* @category Object
|
|
1419
|
+
* @param {Object} object The destination object.
|
|
1420
|
+
* @param {...Object} sources The source objects.
|
|
1421
|
+
* @param {Function} [customizer] The function to customize assigned values.
|
|
1422
|
+
* @returns {Object} Returns `object`.
|
|
1423
|
+
* @see _.assignWith
|
|
1424
|
+
* @example
|
|
1425
|
+
*
|
|
1426
|
+
* function customizer(objValue, srcValue) {
|
|
1427
|
+
* return _.isUndefined(objValue) ? srcValue : objValue;
|
|
1428
|
+
* }
|
|
1429
|
+
*
|
|
1430
|
+
* var defaults = _.partialRight(_.assignInWith, customizer);
|
|
1431
|
+
*
|
|
1432
|
+
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
|
|
1433
|
+
* // => { 'a': 1, 'b': 2 }
|
|
1434
|
+
*/
|
|
1435
|
+
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
|
|
1436
|
+
copyObject(source, keysIn(source), object, customizer);
|
|
1437
|
+
});
|
|
1438
|
+
|
|
1439
|
+
const extendWith = assignInWith;
|
|
1440
|
+
|
|
1441
|
+
/**
|
|
1442
|
+
* Converts `value` to a string. An empty string is returned for `null`
|
|
1443
|
+
* and `undefined` values. The sign of `-0` is preserved.
|
|
1444
|
+
*
|
|
1445
|
+
* @static
|
|
1446
|
+
* @memberOf _
|
|
1447
|
+
* @since 4.0.0
|
|
1448
|
+
* @category Lang
|
|
1449
|
+
* @param {*} value The value to convert.
|
|
1450
|
+
* @returns {string} Returns the converted string.
|
|
1451
|
+
* @example
|
|
1452
|
+
*
|
|
1453
|
+
* _.toString(null);
|
|
1454
|
+
* // => ''
|
|
1455
|
+
*
|
|
1456
|
+
* _.toString(-0);
|
|
1457
|
+
* // => '-0'
|
|
1458
|
+
*
|
|
1459
|
+
* _.toString([1, 2, 3]);
|
|
1460
|
+
* // => '1,2,3'
|
|
1461
|
+
*/
|
|
1462
|
+
function toString(value) {
|
|
1463
|
+
return value == null ? '' : baseToString(value);
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
/** Built-in value references. */
|
|
1467
|
+
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
|
1468
|
+
|
|
1469
|
+
const getPrototype$1 = getPrototype;
|
|
1470
|
+
|
|
1471
|
+
/** `Object#toString` result references. */
|
|
1472
|
+
var objectTag = '[object Object]';
|
|
1473
|
+
|
|
1474
|
+
/** Used for built-in method references. */
|
|
1475
|
+
var funcProto = Function.prototype,
|
|
1476
|
+
objectProto$2 = Object.prototype;
|
|
1477
|
+
|
|
1478
|
+
/** Used to resolve the decompiled source of functions. */
|
|
1479
|
+
var funcToString = funcProto.toString;
|
|
1480
|
+
|
|
1481
|
+
/** Used to check objects for own properties. */
|
|
1482
|
+
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
1483
|
+
|
|
1484
|
+
/** Used to infer the `Object` constructor. */
|
|
1485
|
+
var objectCtorString = funcToString.call(Object);
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* Checks if `value` is a plain object, that is, an object created by the
|
|
1489
|
+
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
1490
|
+
*
|
|
1491
|
+
* @static
|
|
1492
|
+
* @memberOf _
|
|
1493
|
+
* @since 0.8.0
|
|
1494
|
+
* @category Lang
|
|
1495
|
+
* @param {*} value The value to check.
|
|
1496
|
+
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
1497
|
+
* @example
|
|
1498
|
+
*
|
|
1499
|
+
* function Foo() {
|
|
1500
|
+
* this.a = 1;
|
|
1501
|
+
* }
|
|
1502
|
+
*
|
|
1503
|
+
* _.isPlainObject(new Foo);
|
|
1504
|
+
* // => false
|
|
1505
|
+
*
|
|
1506
|
+
* _.isPlainObject([1, 2, 3]);
|
|
1507
|
+
* // => false
|
|
1508
|
+
*
|
|
1509
|
+
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
|
1510
|
+
* // => true
|
|
1511
|
+
*
|
|
1512
|
+
* _.isPlainObject(Object.create(null));
|
|
1513
|
+
* // => true
|
|
1514
|
+
*/
|
|
1515
|
+
function isPlainObject(value) {
|
|
1516
|
+
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
|
1517
|
+
return false;
|
|
1518
|
+
}
|
|
1519
|
+
var proto = getPrototype$1(value);
|
|
1520
|
+
if (proto === null) {
|
|
1521
|
+
return true;
|
|
1522
|
+
}
|
|
1523
|
+
var Ctor = hasOwnProperty$2.call(proto, 'constructor') && proto.constructor;
|
|
1524
|
+
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
|
1525
|
+
funcToString.call(Ctor) == objectCtorString;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
/** `Object#toString` result references. */
|
|
1529
|
+
var domExcTag = '[object DOMException]',
|
|
1530
|
+
errorTag = '[object Error]';
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
|
|
1534
|
+
* `SyntaxError`, `TypeError`, or `URIError` object.
|
|
1535
|
+
*
|
|
1536
|
+
* @static
|
|
1537
|
+
* @memberOf _
|
|
1538
|
+
* @since 3.0.0
|
|
1539
|
+
* @category Lang
|
|
1540
|
+
* @param {*} value The value to check.
|
|
1541
|
+
* @returns {boolean} Returns `true` if `value` is an error object, else `false`.
|
|
1542
|
+
* @example
|
|
1543
|
+
*
|
|
1544
|
+
* _.isError(new Error);
|
|
1545
|
+
* // => true
|
|
1546
|
+
*
|
|
1547
|
+
* _.isError(Error);
|
|
1548
|
+
* // => false
|
|
1549
|
+
*/
|
|
1550
|
+
function isError(value) {
|
|
1551
|
+
if (!isObjectLike(value)) {
|
|
1552
|
+
return false;
|
|
1553
|
+
}
|
|
1554
|
+
var tag = baseGetTag(value);
|
|
1555
|
+
return tag == errorTag || tag == domExcTag ||
|
|
1556
|
+
(typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
/**
|
|
1560
|
+
* Attempts to invoke `func`, returning either the result or the caught error
|
|
1561
|
+
* object. Any additional arguments are provided to `func` when it's invoked.
|
|
1562
|
+
*
|
|
1563
|
+
* @static
|
|
1564
|
+
* @memberOf _
|
|
1565
|
+
* @since 3.0.0
|
|
1566
|
+
* @category Util
|
|
1567
|
+
* @param {Function} func The function to attempt.
|
|
1568
|
+
* @param {...*} [args] The arguments to invoke `func` with.
|
|
1569
|
+
* @returns {*} Returns the `func` result or error object.
|
|
1570
|
+
* @example
|
|
1571
|
+
*
|
|
1572
|
+
* // Avoid throwing errors for invalid selectors.
|
|
1573
|
+
* var elements = _.attempt(function(selector) {
|
|
1574
|
+
* return document.querySelectorAll(selector);
|
|
1575
|
+
* }, '>_>');
|
|
1576
|
+
*
|
|
1577
|
+
* if (_.isError(elements)) {
|
|
1578
|
+
* elements = [];
|
|
1579
|
+
* }
|
|
1580
|
+
*/
|
|
1581
|
+
var attempt = baseRest(function(func, args) {
|
|
1582
|
+
try {
|
|
1583
|
+
return apply(func, undefined, args);
|
|
1584
|
+
} catch (e) {
|
|
1585
|
+
return isError(e) ? e : new Error(e);
|
|
1586
|
+
}
|
|
1587
|
+
});
|
|
1588
|
+
|
|
1589
|
+
const attempt$1 = attempt;
|
|
1590
|
+
|
|
1591
|
+
/**
|
|
1592
|
+
* The base implementation of `_.propertyOf` without support for deep paths.
|
|
1593
|
+
*
|
|
1594
|
+
* @private
|
|
1595
|
+
* @param {Object} object The object to query.
|
|
1596
|
+
* @returns {Function} Returns the new accessor function.
|
|
1597
|
+
*/
|
|
1598
|
+
function basePropertyOf(object) {
|
|
1599
|
+
return function(key) {
|
|
1600
|
+
return object == null ? undefined : object[key];
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
/** Used to map characters to HTML entities. */
|
|
1605
|
+
var htmlEscapes = {
|
|
1606
|
+
'&': '&',
|
|
1607
|
+
'<': '<',
|
|
1608
|
+
'>': '>',
|
|
1609
|
+
'"': '"',
|
|
1610
|
+
"'": '''
|
|
1611
|
+
};
|
|
1612
|
+
|
|
1613
|
+
/**
|
|
1614
|
+
* Used by `_.escape` to convert characters to HTML entities.
|
|
1615
|
+
*
|
|
1616
|
+
* @private
|
|
1617
|
+
* @param {string} chr The matched character to escape.
|
|
1618
|
+
* @returns {string} Returns the escaped character.
|
|
1619
|
+
*/
|
|
1620
|
+
var escapeHtmlChar = basePropertyOf(htmlEscapes);
|
|
1621
|
+
|
|
1622
|
+
const escapeHtmlChar$1 = escapeHtmlChar;
|
|
1623
|
+
|
|
1624
|
+
/** Used to match HTML entities and HTML characters. */
|
|
1625
|
+
var reUnescapedHtml = /[&<>"']/g,
|
|
1626
|
+
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
|
|
1627
|
+
|
|
1628
|
+
/**
|
|
1629
|
+
* Converts the characters "&", "<", ">", '"', and "'" in `string` to their
|
|
1630
|
+
* corresponding HTML entities.
|
|
1631
|
+
*
|
|
1632
|
+
* **Note:** No other characters are escaped. To escape additional
|
|
1633
|
+
* characters use a third-party library like [_he_](https://mths.be/he).
|
|
1634
|
+
*
|
|
1635
|
+
* Though the ">" character is escaped for symmetry, characters like
|
|
1636
|
+
* ">" and "/" don't need escaping in HTML and have no special meaning
|
|
1637
|
+
* unless they're part of a tag or unquoted attribute value. See
|
|
1638
|
+
* [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
|
|
1639
|
+
* (under "semi-related fun fact") for more details.
|
|
1640
|
+
*
|
|
1641
|
+
* When working with HTML you should always
|
|
1642
|
+
* [quote attribute values](http://wonko.com/post/html-escaping) to reduce
|
|
1643
|
+
* XSS vectors.
|
|
1644
|
+
*
|
|
1645
|
+
* @static
|
|
1646
|
+
* @since 0.1.0
|
|
1647
|
+
* @memberOf _
|
|
1648
|
+
* @category String
|
|
1649
|
+
* @param {string} [string=''] The string to escape.
|
|
1650
|
+
* @returns {string} Returns the escaped string.
|
|
1651
|
+
* @example
|
|
1652
|
+
*
|
|
1653
|
+
* _.escape('fred, barney, & pebbles');
|
|
1654
|
+
* // => 'fred, barney, & pebbles'
|
|
1655
|
+
*/
|
|
1656
|
+
function escape(string) {
|
|
1657
|
+
string = toString(string);
|
|
1658
|
+
return (string && reHasUnescapedHtml.test(string))
|
|
1659
|
+
? string.replace(reUnescapedHtml, escapeHtmlChar$1)
|
|
1660
|
+
: string;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* The base implementation of `_.values` and `_.valuesIn` which creates an
|
|
1665
|
+
* array of `object` property values corresponding to the property names
|
|
1666
|
+
* of `props`.
|
|
1667
|
+
*
|
|
1668
|
+
* @private
|
|
1669
|
+
* @param {Object} object The object to query.
|
|
1670
|
+
* @param {Array} props The property names to get values for.
|
|
1671
|
+
* @returns {Object} Returns the array of property values.
|
|
1672
|
+
*/
|
|
1673
|
+
function baseValues(object, props) {
|
|
1674
|
+
return arrayMap(props, function(key) {
|
|
1675
|
+
return object[key];
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
/** Used for built-in method references. */
|
|
1680
|
+
var objectProto$1 = Object.prototype;
|
|
1681
|
+
|
|
1682
|
+
/** Used to check objects for own properties. */
|
|
1683
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* Used by `_.defaults` to customize its `_.assignIn` use to assign properties
|
|
1687
|
+
* of source objects to the destination object for all destination properties
|
|
1688
|
+
* that resolve to `undefined`.
|
|
1689
|
+
*
|
|
1690
|
+
* @private
|
|
1691
|
+
* @param {*} objValue The destination value.
|
|
1692
|
+
* @param {*} srcValue The source value.
|
|
1693
|
+
* @param {string} key The key of the property to assign.
|
|
1694
|
+
* @param {Object} object The parent object of `objValue`.
|
|
1695
|
+
* @returns {*} Returns the value to assign.
|
|
1696
|
+
*/
|
|
1697
|
+
function customDefaultsAssignIn(objValue, srcValue, key, object) {
|
|
1698
|
+
if (objValue === undefined ||
|
|
1699
|
+
(eq(objValue, objectProto$1[key]) && !hasOwnProperty$1.call(object, key))) {
|
|
1700
|
+
return srcValue;
|
|
1701
|
+
}
|
|
1702
|
+
return objValue;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
/** Used to escape characters for inclusion in compiled string literals. */
|
|
1706
|
+
var stringEscapes = {
|
|
1707
|
+
'\\': '\\',
|
|
1708
|
+
"'": "'",
|
|
1709
|
+
'\n': 'n',
|
|
1710
|
+
'\r': 'r',
|
|
1711
|
+
'\u2028': 'u2028',
|
|
1712
|
+
'\u2029': 'u2029'
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* Used by `_.template` to escape characters for inclusion in compiled string literals.
|
|
1717
|
+
*
|
|
1718
|
+
* @private
|
|
1719
|
+
* @param {string} chr The matched character to escape.
|
|
1720
|
+
* @returns {string} Returns the escaped character.
|
|
1721
|
+
*/
|
|
1722
|
+
function escapeStringChar(chr) {
|
|
1723
|
+
return '\\' + stringEscapes[chr];
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
/** Used to match template delimiters. */
|
|
1727
|
+
var reInterpolate = /<%=([\s\S]+?)%>/g;
|
|
1728
|
+
|
|
1729
|
+
const reInterpolate$1 = reInterpolate;
|
|
1730
|
+
|
|
1731
|
+
/** Used to match template delimiters. */
|
|
1732
|
+
var reEscape = /<%-([\s\S]+?)%>/g;
|
|
1733
|
+
|
|
1734
|
+
const reEscape$1 = reEscape;
|
|
1735
|
+
|
|
1736
|
+
/** Used to match template delimiters. */
|
|
1737
|
+
var reEvaluate = /<%([\s\S]+?)%>/g;
|
|
1738
|
+
|
|
1739
|
+
const reEvaluate$1 = reEvaluate;
|
|
1740
|
+
|
|
1741
|
+
/**
|
|
1742
|
+
* By default, the template delimiters used by lodash are like those in
|
|
1743
|
+
* embedded Ruby (ERB) as well as ES2015 template strings. Change the
|
|
1744
|
+
* following template settings to use alternative delimiters.
|
|
1745
|
+
*
|
|
1746
|
+
* @static
|
|
1747
|
+
* @memberOf _
|
|
1748
|
+
* @type {Object}
|
|
1749
|
+
*/
|
|
1750
|
+
var templateSettings = {
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* Used to detect `data` property values to be HTML-escaped.
|
|
1754
|
+
*
|
|
1755
|
+
* @memberOf _.templateSettings
|
|
1756
|
+
* @type {RegExp}
|
|
1757
|
+
*/
|
|
1758
|
+
'escape': reEscape$1,
|
|
1759
|
+
|
|
1760
|
+
/**
|
|
1761
|
+
* Used to detect code to be evaluated.
|
|
1762
|
+
*
|
|
1763
|
+
* @memberOf _.templateSettings
|
|
1764
|
+
* @type {RegExp}
|
|
1765
|
+
*/
|
|
1766
|
+
'evaluate': reEvaluate$1,
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* Used to detect `data` property values to inject.
|
|
1770
|
+
*
|
|
1771
|
+
* @memberOf _.templateSettings
|
|
1772
|
+
* @type {RegExp}
|
|
1773
|
+
*/
|
|
1774
|
+
'interpolate': reInterpolate$1,
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* Used to reference the data object in the template text.
|
|
1778
|
+
*
|
|
1779
|
+
* @memberOf _.templateSettings
|
|
1780
|
+
* @type {string}
|
|
1781
|
+
*/
|
|
1782
|
+
'variable': '',
|
|
1783
|
+
|
|
1784
|
+
/**
|
|
1785
|
+
* Used to import variables into the compiled template.
|
|
1786
|
+
*
|
|
1787
|
+
* @memberOf _.templateSettings
|
|
1788
|
+
* @type {Object}
|
|
1789
|
+
*/
|
|
1790
|
+
'imports': {
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* A reference to the `lodash` function.
|
|
1794
|
+
*
|
|
1795
|
+
* @memberOf _.templateSettings.imports
|
|
1796
|
+
* @type {Function}
|
|
1797
|
+
*/
|
|
1798
|
+
'_': { 'escape': escape }
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
|
|
1802
|
+
const templateSettings$1 = templateSettings;
|
|
1803
|
+
|
|
1804
|
+
/** Error message constants. */
|
|
1805
|
+
var INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
|
|
1806
|
+
|
|
1807
|
+
/** Used to match empty string literals in compiled template source. */
|
|
1808
|
+
var reEmptyStringLeading = /\b__p \+= '';/g,
|
|
1809
|
+
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
|
|
1810
|
+
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* Used to validate the `validate` option in `_.template` variable.
|
|
1814
|
+
*
|
|
1815
|
+
* Forbids characters which could potentially change the meaning of the function argument definition:
|
|
1816
|
+
* - "()," (modification of function parameters)
|
|
1817
|
+
* - "=" (default value)
|
|
1818
|
+
* - "[]{}" (destructuring of function parameters)
|
|
1819
|
+
* - "/" (beginning of a comment)
|
|
1820
|
+
* - whitespace
|
|
1821
|
+
*/
|
|
1822
|
+
var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
|
|
1823
|
+
|
|
1824
|
+
/**
|
|
1825
|
+
* Used to match
|
|
1826
|
+
* [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
|
|
1827
|
+
*/
|
|
1828
|
+
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
|
|
1829
|
+
|
|
1830
|
+
/** Used to ensure capturing order of template delimiters. */
|
|
1831
|
+
var reNoMatch = /($^)/;
|
|
1832
|
+
|
|
1833
|
+
/** Used to match unescaped characters in compiled string literals. */
|
|
1834
|
+
var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
|
|
1835
|
+
|
|
1836
|
+
/** Used for built-in method references. */
|
|
1837
|
+
var objectProto = Object.prototype;
|
|
1838
|
+
|
|
1839
|
+
/** Used to check objects for own properties. */
|
|
1840
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
* Creates a compiled template function that can interpolate data properties
|
|
1844
|
+
* in "interpolate" delimiters, HTML-escape interpolated data properties in
|
|
1845
|
+
* "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
|
|
1846
|
+
* properties may be accessed as free variables in the template. If a setting
|
|
1847
|
+
* object is given, it takes precedence over `_.templateSettings` values.
|
|
1848
|
+
*
|
|
1849
|
+
* **Note:** In the development build `_.template` utilizes
|
|
1850
|
+
* [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
|
|
1851
|
+
* for easier debugging.
|
|
1852
|
+
*
|
|
1853
|
+
* For more information on precompiling templates see
|
|
1854
|
+
* [lodash's custom builds documentation](https://lodash.com/custom-builds).
|
|
1855
|
+
*
|
|
1856
|
+
* For more information on Chrome extension sandboxes see
|
|
1857
|
+
* [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
|
|
1858
|
+
*
|
|
1859
|
+
* @static
|
|
1860
|
+
* @since 0.1.0
|
|
1861
|
+
* @memberOf _
|
|
1862
|
+
* @category String
|
|
1863
|
+
* @param {string} [string=''] The template string.
|
|
1864
|
+
* @param {Object} [options={}] The options object.
|
|
1865
|
+
* @param {RegExp} [options.escape=_.templateSettings.escape]
|
|
1866
|
+
* The HTML "escape" delimiter.
|
|
1867
|
+
* @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
|
|
1868
|
+
* The "evaluate" delimiter.
|
|
1869
|
+
* @param {Object} [options.imports=_.templateSettings.imports]
|
|
1870
|
+
* An object to import into the template as free variables.
|
|
1871
|
+
* @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
|
|
1872
|
+
* The "interpolate" delimiter.
|
|
1873
|
+
* @param {string} [options.sourceURL='templateSources[n]']
|
|
1874
|
+
* The sourceURL of the compiled template.
|
|
1875
|
+
* @param {string} [options.variable='obj']
|
|
1876
|
+
* The data object variable name.
|
|
1877
|
+
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
|
|
1878
|
+
* @returns {Function} Returns the compiled template function.
|
|
1879
|
+
* @example
|
|
1880
|
+
*
|
|
1881
|
+
* // Use the "interpolate" delimiter to create a compiled template.
|
|
1882
|
+
* var compiled = _.template('hello <%= user %>!');
|
|
1883
|
+
* compiled({ 'user': 'fred' });
|
|
1884
|
+
* // => 'hello fred!'
|
|
1885
|
+
*
|
|
1886
|
+
* // Use the HTML "escape" delimiter to escape data property values.
|
|
1887
|
+
* var compiled = _.template('<b><%- value %></b>');
|
|
1888
|
+
* compiled({ 'value': '<script>' });
|
|
1889
|
+
* // => '<b><script></b>'
|
|
1890
|
+
*
|
|
1891
|
+
* // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
|
|
1892
|
+
* var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
|
|
1893
|
+
* compiled({ 'users': ['fred', 'barney'] });
|
|
1894
|
+
* // => '<li>fred</li><li>barney</li>'
|
|
1895
|
+
*
|
|
1896
|
+
* // Use the internal `print` function in "evaluate" delimiters.
|
|
1897
|
+
* var compiled = _.template('<% print("hello " + user); %>!');
|
|
1898
|
+
* compiled({ 'user': 'barney' });
|
|
1899
|
+
* // => 'hello barney!'
|
|
1900
|
+
*
|
|
1901
|
+
* // Use the ES template literal delimiter as an "interpolate" delimiter.
|
|
1902
|
+
* // Disable support by replacing the "interpolate" delimiter.
|
|
1903
|
+
* var compiled = _.template('hello ${ user }!');
|
|
1904
|
+
* compiled({ 'user': 'pebbles' });
|
|
1905
|
+
* // => 'hello pebbles!'
|
|
1906
|
+
*
|
|
1907
|
+
* // Use backslashes to treat delimiters as plain text.
|
|
1908
|
+
* var compiled = _.template('<%= "\\<%- value %\\>" %>');
|
|
1909
|
+
* compiled({ 'value': 'ignored' });
|
|
1910
|
+
* // => '<%- value %>'
|
|
1911
|
+
*
|
|
1912
|
+
* // Use the `imports` option to import `jQuery` as `jq`.
|
|
1913
|
+
* var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
|
|
1914
|
+
* var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
|
|
1915
|
+
* compiled({ 'users': ['fred', 'barney'] });
|
|
1916
|
+
* // => '<li>fred</li><li>barney</li>'
|
|
1917
|
+
*
|
|
1918
|
+
* // Use the `sourceURL` option to specify a custom sourceURL for the template.
|
|
1919
|
+
* var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
|
|
1920
|
+
* compiled(data);
|
|
1921
|
+
* // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
|
|
1922
|
+
*
|
|
1923
|
+
* // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
|
|
1924
|
+
* var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
|
|
1925
|
+
* compiled.source;
|
|
1926
|
+
* // => function(data) {
|
|
1927
|
+
* // var __t, __p = '';
|
|
1928
|
+
* // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
|
|
1929
|
+
* // return __p;
|
|
1930
|
+
* // }
|
|
1931
|
+
*
|
|
1932
|
+
* // Use custom template delimiters.
|
|
1933
|
+
* _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
|
|
1934
|
+
* var compiled = _.template('hello {{ user }}!');
|
|
1935
|
+
* compiled({ 'user': 'mustache' });
|
|
1936
|
+
* // => 'hello mustache!'
|
|
1937
|
+
*
|
|
1938
|
+
* // Use the `source` property to inline compiled templates for meaningful
|
|
1939
|
+
* // line numbers in error messages and stack traces.
|
|
1940
|
+
* fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
|
|
1941
|
+
* var JST = {\
|
|
1942
|
+
* "main": ' + _.template(mainText).source + '\
|
|
1943
|
+
* };\
|
|
1944
|
+
* ');
|
|
1945
|
+
*/
|
|
1946
|
+
function template(string, options, guard) {
|
|
1947
|
+
// Based on John Resig's `tmpl` implementation
|
|
1948
|
+
// (http://ejohn.org/blog/javascript-micro-templating/)
|
|
1949
|
+
// and Laura Doktorova's doT.js (https://github.com/olado/doT).
|
|
1950
|
+
var settings = templateSettings$1.imports._.templateSettings || templateSettings$1;
|
|
1951
|
+
|
|
1952
|
+
if (guard && isIterateeCall(string, options, guard)) {
|
|
1953
|
+
options = undefined;
|
|
1954
|
+
}
|
|
1955
|
+
string = toString(string);
|
|
1956
|
+
options = extendWith({}, options, settings, customDefaultsAssignIn);
|
|
1957
|
+
|
|
1958
|
+
var imports = extendWith({}, options.imports, settings.imports, customDefaultsAssignIn),
|
|
1959
|
+
importsKeys = keys(imports),
|
|
1960
|
+
importsValues = baseValues(imports, importsKeys);
|
|
1961
|
+
|
|
1962
|
+
var isEscaping,
|
|
1963
|
+
isEvaluating,
|
|
1964
|
+
index = 0,
|
|
1965
|
+
interpolate = options.interpolate || reNoMatch,
|
|
1966
|
+
source = "__p += '";
|
|
1967
|
+
|
|
1968
|
+
// Compile the regexp to match each delimiter.
|
|
1969
|
+
var reDelimiters = RegExp(
|
|
1970
|
+
(options.escape || reNoMatch).source + '|' +
|
|
1971
|
+
interpolate.source + '|' +
|
|
1972
|
+
(interpolate === reInterpolate$1 ? reEsTemplate : reNoMatch).source + '|' +
|
|
1973
|
+
(options.evaluate || reNoMatch).source + '|$'
|
|
1974
|
+
, 'g');
|
|
1975
|
+
|
|
1976
|
+
// Use a sourceURL for easier debugging.
|
|
1977
|
+
// The sourceURL gets injected into the source that's eval-ed, so be careful
|
|
1978
|
+
// to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
|
|
1979
|
+
// and escape the comment, thus injecting code that gets evaled.
|
|
1980
|
+
var sourceURL = hasOwnProperty.call(options, 'sourceURL')
|
|
1981
|
+
? ('//# sourceURL=' +
|
|
1982
|
+
(options.sourceURL + '').replace(/\s/g, ' ') +
|
|
1983
|
+
'\n')
|
|
1984
|
+
: '';
|
|
1985
|
+
|
|
1986
|
+
string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
|
1987
|
+
interpolateValue || (interpolateValue = esTemplateValue);
|
|
1988
|
+
|
|
1989
|
+
// Escape characters that can't be included in string literals.
|
|
1990
|
+
source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
|
|
1991
|
+
|
|
1992
|
+
// Replace delimiters with snippets.
|
|
1993
|
+
if (escapeValue) {
|
|
1994
|
+
isEscaping = true;
|
|
1995
|
+
source += "' +\n__e(" + escapeValue + ") +\n'";
|
|
1996
|
+
}
|
|
1997
|
+
if (evaluateValue) {
|
|
1998
|
+
isEvaluating = true;
|
|
1999
|
+
source += "';\n" + evaluateValue + ";\n__p += '";
|
|
2000
|
+
}
|
|
2001
|
+
if (interpolateValue) {
|
|
2002
|
+
source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
|
|
2003
|
+
}
|
|
2004
|
+
index = offset + match.length;
|
|
2005
|
+
|
|
2006
|
+
// The JS engine embedded in Adobe products needs `match` returned in
|
|
2007
|
+
// order to produce the correct `offset` value.
|
|
2008
|
+
return match;
|
|
2009
|
+
});
|
|
2010
|
+
|
|
2011
|
+
source += "';\n";
|
|
2012
|
+
|
|
2013
|
+
// If `variable` is not specified wrap a with-statement around the generated
|
|
2014
|
+
// code to add the data object to the top of the scope chain.
|
|
2015
|
+
var variable = hasOwnProperty.call(options, 'variable') && options.variable;
|
|
2016
|
+
if (!variable) {
|
|
2017
|
+
source = 'with (obj) {\n' + source + '\n}\n';
|
|
2018
|
+
}
|
|
2019
|
+
// Throw an error if a forbidden character was found in `variable`, to prevent
|
|
2020
|
+
// potential command injection attacks.
|
|
2021
|
+
else if (reForbiddenIdentifierChars.test(variable)) {
|
|
2022
|
+
throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
// Cleanup code by stripping empty strings.
|
|
2026
|
+
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
|
|
2027
|
+
.replace(reEmptyStringMiddle, '$1')
|
|
2028
|
+
.replace(reEmptyStringTrailing, '$1;');
|
|
2029
|
+
|
|
2030
|
+
// Frame code as the function body.
|
|
2031
|
+
source = 'function(' + (variable || 'obj') + ') {\n' +
|
|
2032
|
+
(variable
|
|
2033
|
+
? ''
|
|
2034
|
+
: 'obj || (obj = {});\n'
|
|
2035
|
+
) +
|
|
2036
|
+
"var __t, __p = ''" +
|
|
2037
|
+
(isEscaping
|
|
2038
|
+
? ', __e = _.escape'
|
|
2039
|
+
: ''
|
|
2040
|
+
) +
|
|
2041
|
+
(isEvaluating
|
|
2042
|
+
? ', __j = Array.prototype.join;\n' +
|
|
2043
|
+
"function print() { __p += __j.call(arguments, '') }\n"
|
|
2044
|
+
: ';\n'
|
|
2045
|
+
) +
|
|
2046
|
+
source +
|
|
2047
|
+
'return __p\n}';
|
|
2048
|
+
|
|
2049
|
+
var result = attempt$1(function() {
|
|
2050
|
+
return Function(importsKeys, sourceURL + 'return ' + source)
|
|
2051
|
+
.apply(undefined, importsValues);
|
|
2052
|
+
});
|
|
2053
|
+
|
|
2054
|
+
// Provide the compiled function's source by its `toString` method or
|
|
2055
|
+
// the `source` property as a convenience for inlining compiled templates.
|
|
2056
|
+
result.source = source;
|
|
2057
|
+
if (isError(result)) {
|
|
2058
|
+
throw result;
|
|
2059
|
+
}
|
|
2060
|
+
return result;
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
async function compileTemplate(template$1, ctx) {
|
|
2064
|
+
const data = { ...ctx, options: template$1.options };
|
|
2065
|
+
if (template$1.src) {
|
|
99
2066
|
try {
|
|
100
|
-
const srcContents = await promises.readFile(template.src, "utf-8");
|
|
101
|
-
return
|
|
2067
|
+
const srcContents = await promises.readFile(template$1.src, "utf-8");
|
|
2068
|
+
return template(srcContents, {})(data);
|
|
102
2069
|
} catch (err) {
|
|
103
|
-
console.error("Error compiling template: ", template);
|
|
2070
|
+
console.error("Error compiling template: ", template$1);
|
|
104
2071
|
throw err;
|
|
105
2072
|
}
|
|
106
2073
|
}
|
|
107
|
-
if (template.getContents) {
|
|
108
|
-
return template.getContents(data);
|
|
2074
|
+
if (template$1.getContents) {
|
|
2075
|
+
return template$1.getContents(data);
|
|
109
2076
|
}
|
|
110
|
-
throw new Error("Invalid template: " + JSON.stringify(template));
|
|
2077
|
+
throw new Error("Invalid template: " + JSON.stringify(template$1));
|
|
111
2078
|
}
|
|
112
2079
|
const serialize = (data) => JSON.stringify(data, null, 2).replace(/"{(.+)}"(?=,?$)/gm, (r) => JSON.parse(r).replace(/^{(.*)}$/, "$1"));
|
|
113
2080
|
const importSources = (sources, { lazy = false } = {}) => {
|