objection 3.5.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +3 -3
  2. package/lib/model/AjvValidator.js +33 -10
  3. package/lib/model/modelClone.js +0 -2
  4. package/lib/queryBuilder/InternalOptions.js +2 -0
  5. package/lib/queryBuilder/QueryBuilder.js +56 -10
  6. package/lib/queryBuilder/RelationExpression.js +6 -4
  7. package/lib/queryBuilder/graph/GraphOptions.js +141 -22
  8. package/lib/queryBuilder/graph/GraphUpsert.js +57 -0
  9. package/lib/queryBuilder/graph/insert/GraphInsert.js +2 -0
  10. package/lib/queryBuilder/graph/patch/GraphPatchAction.js +3 -0
  11. package/lib/queryBuilder/operations/InstanceUpdateOperation.js +6 -1
  12. package/lib/queryBuilder/operations/UpdateOperation.js +11 -0
  13. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeMsSqlOperation.js +3 -1
  14. package/lib/queryBuilder/operations/whereInComposite/WhereInCompositeSqliteOperation.js +4 -9
  15. package/lib/queryBuilder/parsers/jsonFieldExpressionParser.js +434 -364
  16. package/lib/queryBuilder/parsers/relationExpressionParser.js +513 -548
  17. package/lib/queryBuilder/parsers/relationExpressionParser.pegjs +1 -1
  18. package/lib/queryBuilder/transformations/WrapMysqlModifySubqueryTransformation.js +4 -7
  19. package/lib/relations/Relation.js +7 -0
  20. package/lib/relations/RelationFindOperation.js +27 -40
  21. package/lib/relations/belongsToOne/BelongsToOneDeleteOperation.js +4 -2
  22. package/lib/relations/belongsToOne/BelongsToOneRelation.js +9 -0
  23. package/lib/relations/manyToMany/ManyToManyModifyMixin.js +41 -13
  24. package/lib/relations/manyToMany/ManyToManyMySqlModifyMixin.js +31 -42
  25. package/lib/relations/manyToMany/ManyToManyRelation.js +15 -18
  26. package/lib/relations/manyToMany/ManyToManySqliteModifyMixin.js +0 -13
  27. package/lib/relations/manyToMany/find/ManyToManyFindOperation.js +2 -3
  28. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateMySqlOperation.js +1 -5
  29. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperation.js +1 -5
  30. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateOperationBase.js +9 -0
  31. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelateSqliteOperation.js +1 -5
  32. package/lib/relations/manyToMany/update/ManyToManyUpdateOperationBase.js +28 -2
  33. package/lib/utils/identifierMapping.js +8 -17
  34. package/lib/utils/objectUtils.js +109 -2
  35. package/lib/utils/parseFieldExpression.js +10 -3
  36. package/package.json +5 -2
  37. package/typings/objection/index.d.ts +56 -36
  38. package/lib/relations/manyToMany/ManyToManyPostgresModifyMixin.js +0 -27
  39. package/lib/relations/manyToMany/unrelate/ManyToManyUnrelatePostgresOperation.js +0 -16
  40. package/lib/relations/manyToMany/update/ManyToManyUpdatePostgresOperation.js +0 -12
  41. package/lib/utils/clone.js +0 -2329
@@ -1,2329 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * @license
5
- * Lodash (Custom Build) <https://lodash.com/>
6
- * Build: `lodash include="cloneDeep,clone" exports="node" --development`
7
- * Copyright JS Foundation and other contributors <https://js.foundation/>
8
- * Released under MIT license <https://lodash.com/license>
9
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
10
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
11
- */
12
- (function () {
13
- /** Used as a safe reference for `undefined` in pre-ES5 environments. */
14
- var undefined;
15
-
16
- /** Used as the semantic version number. */
17
- var VERSION = '4.17.5';
18
-
19
- /** Used as the size to enable large array optimizations. */
20
- var LARGE_ARRAY_SIZE = 200;
21
-
22
- /** Used to stand-in for `undefined` hash values. */
23
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
24
-
25
- /** Used to compose bitmasks for cloning. */
26
- var CLONE_DEEP_FLAG = 1,
27
- CLONE_FLAT_FLAG = 2,
28
- CLONE_SYMBOLS_FLAG = 4;
29
-
30
- /** Used as references for various `Number` constants. */
31
- var MAX_SAFE_INTEGER = 9007199254740991;
32
-
33
- /** `Object#toString` result references. */
34
- var argsTag = '[object Arguments]',
35
- arrayTag = '[object Array]',
36
- asyncTag = '[object AsyncFunction]',
37
- boolTag = '[object Boolean]',
38
- dateTag = '[object Date]',
39
- errorTag = '[object Error]',
40
- funcTag = '[object Function]',
41
- genTag = '[object GeneratorFunction]',
42
- mapTag = '[object Map]',
43
- numberTag = '[object Number]',
44
- nullTag = '[object Null]',
45
- objectTag = '[object Object]',
46
- promiseTag = '[object Promise]',
47
- proxyTag = '[object Proxy]',
48
- regexpTag = '[object RegExp]',
49
- setTag = '[object Set]',
50
- stringTag = '[object String]',
51
- symbolTag = '[object Symbol]',
52
- undefinedTag = '[object Undefined]',
53
- weakMapTag = '[object WeakMap]';
54
-
55
- var arrayBufferTag = '[object ArrayBuffer]',
56
- dataViewTag = '[object DataView]',
57
- float32Tag = '[object Float32Array]',
58
- float64Tag = '[object Float64Array]',
59
- int8Tag = '[object Int8Array]',
60
- int16Tag = '[object Int16Array]',
61
- int32Tag = '[object Int32Array]',
62
- uint8Tag = '[object Uint8Array]',
63
- uint8ClampedTag = '[object Uint8ClampedArray]',
64
- uint16Tag = '[object Uint16Array]',
65
- uint32Tag = '[object Uint32Array]';
66
-
67
- /**
68
- * Used to match `RegExp`
69
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
70
- */
71
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
72
-
73
- /** Used to match `RegExp` flags from their coerced string values. */
74
- var reFlags = /\w*$/;
75
-
76
- /** Used to detect host constructors (Safari). */
77
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
78
-
79
- /** Used to detect unsigned integer values. */
80
- var reIsUint = /^(?:0|[1-9]\d*)$/;
81
-
82
- /** Used to identify `toStringTag` values of typed arrays. */
83
- var typedArrayTags = {};
84
- typedArrayTags[float32Tag] =
85
- typedArrayTags[float64Tag] =
86
- typedArrayTags[int8Tag] =
87
- typedArrayTags[int16Tag] =
88
- typedArrayTags[int32Tag] =
89
- typedArrayTags[uint8Tag] =
90
- typedArrayTags[uint8ClampedTag] =
91
- typedArrayTags[uint16Tag] =
92
- typedArrayTags[uint32Tag] =
93
- true;
94
- typedArrayTags[argsTag] =
95
- typedArrayTags[arrayTag] =
96
- typedArrayTags[arrayBufferTag] =
97
- typedArrayTags[boolTag] =
98
- typedArrayTags[dataViewTag] =
99
- typedArrayTags[dateTag] =
100
- typedArrayTags[errorTag] =
101
- typedArrayTags[funcTag] =
102
- typedArrayTags[mapTag] =
103
- typedArrayTags[numberTag] =
104
- typedArrayTags[objectTag] =
105
- typedArrayTags[regexpTag] =
106
- typedArrayTags[setTag] =
107
- typedArrayTags[stringTag] =
108
- typedArrayTags[weakMapTag] =
109
- false;
110
-
111
- /** Used to identify `toStringTag` values supported by `_.clone`. */
112
- var cloneableTags = {};
113
- cloneableTags[argsTag] =
114
- cloneableTags[arrayTag] =
115
- cloneableTags[arrayBufferTag] =
116
- cloneableTags[dataViewTag] =
117
- cloneableTags[boolTag] =
118
- cloneableTags[dateTag] =
119
- cloneableTags[float32Tag] =
120
- cloneableTags[float64Tag] =
121
- cloneableTags[int8Tag] =
122
- cloneableTags[int16Tag] =
123
- cloneableTags[int32Tag] =
124
- cloneableTags[mapTag] =
125
- cloneableTags[numberTag] =
126
- cloneableTags[objectTag] =
127
- cloneableTags[regexpTag] =
128
- cloneableTags[setTag] =
129
- cloneableTags[stringTag] =
130
- cloneableTags[symbolTag] =
131
- cloneableTags[uint8Tag] =
132
- cloneableTags[uint8ClampedTag] =
133
- cloneableTags[uint16Tag] =
134
- cloneableTags[uint32Tag] =
135
- true;
136
- cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
137
-
138
- /** Detect free variable `global` from Node.js. */
139
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
140
-
141
- /** Used as a reference to the global object. */
142
- var root = freeGlobal || Function('return this')();
143
-
144
- /** Detect free variable `exports`. */
145
- var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
146
-
147
- /** Detect free variable `module`. */
148
- var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
149
-
150
- /** Detect the popular CommonJS extension `module.exports`. */
151
- var moduleExports = freeModule && freeModule.exports === freeExports;
152
-
153
- /** Detect free variable `process` from Node.js. */
154
- var freeProcess = moduleExports && freeGlobal.process;
155
-
156
- /** Used to access faster Node.js helpers. */
157
- var nodeUtil = (function () {
158
- try {
159
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
160
- } catch (e) {}
161
- })();
162
-
163
- /* Node.js helper references. */
164
- var nodeIsMap = nodeUtil && nodeUtil.isMap,
165
- nodeIsSet = nodeUtil && nodeUtil.isSet,
166
- nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
167
-
168
- /*--------------------------------------------------------------------------*/
169
-
170
- /**
171
- * A specialized version of `_.forEach` for arrays without support for
172
- * iteratee shorthands.
173
- *
174
- * @private
175
- * @param {Array} [array] The array to iterate over.
176
- * @param {Function} iteratee The function invoked per iteration.
177
- * @returns {Array} Returns `array`.
178
- */
179
- function arrayEach(array, iteratee) {
180
- var index = -1,
181
- length = array == null ? 0 : array.length;
182
-
183
- while (++index < length) {
184
- if (iteratee(array[index], index, array) === false) {
185
- break;
186
- }
187
- }
188
- return array;
189
- }
190
-
191
- /**
192
- * A specialized version of `_.filter` for arrays without support for
193
- * iteratee shorthands.
194
- *
195
- * @private
196
- * @param {Array} [array] The array to iterate over.
197
- * @param {Function} predicate The function invoked per iteration.
198
- * @returns {Array} Returns the new filtered array.
199
- */
200
- function arrayFilter(array, predicate) {
201
- var index = -1,
202
- length = array == null ? 0 : array.length,
203
- resIndex = 0,
204
- result = [];
205
-
206
- while (++index < length) {
207
- var value = array[index];
208
- if (predicate(value, index, array)) {
209
- result[resIndex++] = value;
210
- }
211
- }
212
- return result;
213
- }
214
-
215
- /**
216
- * Appends the elements of `values` to `array`.
217
- *
218
- * @private
219
- * @param {Array} array The array to modify.
220
- * @param {Array} values The values to append.
221
- * @returns {Array} Returns `array`.
222
- */
223
- function arrayPush(array, values) {
224
- var index = -1,
225
- length = values.length,
226
- offset = array.length;
227
-
228
- while (++index < length) {
229
- array[offset + index] = values[index];
230
- }
231
- return array;
232
- }
233
-
234
- /**
235
- * The base implementation of `_.times` without support for iteratee shorthands
236
- * or max array length checks.
237
- *
238
- * @private
239
- * @param {number} n The number of times to invoke `iteratee`.
240
- * @param {Function} iteratee The function invoked per iteration.
241
- * @returns {Array} Returns the array of results.
242
- */
243
- function baseTimes(n, iteratee) {
244
- var index = -1,
245
- result = Array(n);
246
-
247
- while (++index < n) {
248
- result[index] = iteratee(index);
249
- }
250
- return result;
251
- }
252
-
253
- /**
254
- * The base implementation of `_.unary` without support for storing metadata.
255
- *
256
- * @private
257
- * @param {Function} func The function to cap arguments for.
258
- * @returns {Function} Returns the new capped function.
259
- */
260
- function baseUnary(func) {
261
- return function (value) {
262
- return func(value);
263
- };
264
- }
265
-
266
- /**
267
- * Gets the value at `key` of `object`.
268
- *
269
- * @private
270
- * @param {Object} [object] The object to query.
271
- * @param {string} key The key of the property to get.
272
- * @returns {*} Returns the property value.
273
- */
274
- function getValue(object, key) {
275
- return object == null ? undefined : object[key];
276
- }
277
-
278
- /**
279
- * Creates a unary function that invokes `func` with its argument transformed.
280
- *
281
- * @private
282
- * @param {Function} func The function to wrap.
283
- * @param {Function} transform The argument transform.
284
- * @returns {Function} Returns the new function.
285
- */
286
- function overArg(func, transform) {
287
- return function (arg) {
288
- return func(transform(arg));
289
- };
290
- }
291
-
292
- /*--------------------------------------------------------------------------*/
293
-
294
- /** Used for built-in method references. */
295
- var arrayProto = Array.prototype,
296
- funcProto = Function.prototype,
297
- objectProto = Object.prototype;
298
-
299
- /** Used to detect overreaching core-js shims. */
300
- var coreJsData = root['__core-js_shared__'];
301
-
302
- /** Used to resolve the decompiled source of functions. */
303
- var funcToString = funcProto.toString;
304
-
305
- /** Used to check objects for own properties. */
306
- var hasOwnProperty = objectProto.hasOwnProperty;
307
-
308
- /** Used to detect methods masquerading as native. */
309
- var maskSrcKey = (function () {
310
- var uid = /[^.]+$/.exec((coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO) || '');
311
- return uid ? 'Symbol(src)_1.' + uid : '';
312
- })();
313
-
314
- /**
315
- * Used to resolve the
316
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
317
- * of values.
318
- */
319
- var nativeObjectToString = objectProto.toString;
320
-
321
- /** Used to detect if a method is native. */
322
- var reIsNative = RegExp(
323
- '^' +
324
- funcToString
325
- .call(hasOwnProperty)
326
- .replace(reRegExpChar, '\\$&')
327
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') +
328
- '$',
329
- );
330
-
331
- /** Built-in value references. */
332
- var Buffer = moduleExports ? root.Buffer : undefined,
333
- Symbol = root.Symbol,
334
- Uint8Array = root.Uint8Array,
335
- allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
336
- getPrototype = overArg(Object.getPrototypeOf, Object),
337
- objectCreate = Object.create,
338
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
339
- splice = arrayProto.splice,
340
- symToStringTag = Symbol ? Symbol.toStringTag : undefined;
341
-
342
- var defineProperty = (function () {
343
- try {
344
- var func = getNative(Object, 'defineProperty');
345
- func({}, '', {});
346
- return func;
347
- } catch (e) {}
348
- })();
349
-
350
- /* Built-in method references for those with the same name as other `lodash` methods. */
351
- var nativeGetSymbols = Object.getOwnPropertySymbols,
352
- nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
353
- nativeKeys = overArg(Object.keys, Object);
354
-
355
- /* Built-in method references that are verified to be native. */
356
- var DataView = getNative(root, 'DataView'),
357
- Map = getNative(root, 'Map'),
358
- Promise = getNative(root, 'Promise'),
359
- Set = getNative(root, 'Set'),
360
- WeakMap = getNative(root, 'WeakMap'),
361
- nativeCreate = getNative(Object, 'create');
362
-
363
- /** Used to lookup unminified function names. */
364
- var realNames = {};
365
-
366
- /** Used to detect maps, sets, and weakmaps. */
367
- var dataViewCtorString = toSource(DataView),
368
- mapCtorString = toSource(Map),
369
- promiseCtorString = toSource(Promise),
370
- setCtorString = toSource(Set),
371
- weakMapCtorString = toSource(WeakMap);
372
-
373
- /** Used to convert symbols to primitives and strings. */
374
- var symbolProto = Symbol ? Symbol.prototype : undefined,
375
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
376
-
377
- /*------------------------------------------------------------------------*/
378
-
379
- /**
380
- * Creates a `lodash` object which wraps `value` to enable implicit method
381
- * chain sequences. Methods that operate on and return arrays, collections,
382
- * and functions can be chained together. Methods that retrieve a single value
383
- * or may return a primitive value will automatically end the chain sequence
384
- * and return the unwrapped value. Otherwise, the value must be unwrapped
385
- * with `_#value`.
386
- *
387
- * Explicit chain sequences, which must be unwrapped with `_#value`, may be
388
- * enabled using `_.chain`.
389
- *
390
- * The execution of chained methods is lazy, that is, it's deferred until
391
- * `_#value` is implicitly or explicitly called.
392
- *
393
- * Lazy evaluation allows several methods to support shortcut fusion.
394
- * Shortcut fusion is an optimization to merge iteratee calls; this avoids
395
- * the creation of intermediate arrays and can greatly reduce the number of
396
- * iteratee executions. Sections of a chain sequence qualify for shortcut
397
- * fusion if the section is applied to an array and iteratees accept only
398
- * one argument. The heuristic for whether a section qualifies for shortcut
399
- * fusion is subject to change.
400
- *
401
- * Chaining is supported in custom builds as long as the `_#value` method is
402
- * directly or indirectly included in the build.
403
- *
404
- * In addition to lodash methods, wrappers have `Array` and `String` methods.
405
- *
406
- * The wrapper `Array` methods are:
407
- * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
408
- *
409
- * The wrapper `String` methods are:
410
- * `replace` and `split`
411
- *
412
- * The wrapper methods that support shortcut fusion are:
413
- * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
414
- * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
415
- * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
416
- *
417
- * The chainable wrapper methods are:
418
- * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
419
- * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
420
- * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
421
- * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
422
- * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
423
- * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
424
- * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
425
- * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
426
- * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
427
- * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
428
- * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
429
- * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
430
- * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
431
- * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
432
- * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
433
- * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
434
- * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
435
- * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
436
- * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
437
- * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
438
- * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
439
- * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
440
- * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
441
- * `zipObject`, `zipObjectDeep`, and `zipWith`
442
- *
443
- * The wrapper methods that are **not** chainable by default are:
444
- * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
445
- * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
446
- * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
447
- * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
448
- * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
449
- * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
450
- * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
451
- * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
452
- * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
453
- * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
454
- * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
455
- * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
456
- * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
457
- * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
458
- * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
459
- * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
460
- * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
461
- * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
462
- * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
463
- * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
464
- * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
465
- * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
466
- * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
467
- * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
468
- * `upperFirst`, `value`, and `words`
469
- *
470
- * @name _
471
- * @constructor
472
- * @category Seq
473
- * @param {*} value The value to wrap in a `lodash` instance.
474
- * @returns {Object} Returns the new `lodash` wrapper instance.
475
- * @example
476
- *
477
- * function square(n) {
478
- * return n * n;
479
- * }
480
- *
481
- * var wrapped = _([1, 2, 3]);
482
- *
483
- * // Returns an unwrapped value.
484
- * wrapped.reduce(_.add);
485
- * // => 6
486
- *
487
- * // Returns a wrapped value.
488
- * var squares = wrapped.map(square);
489
- *
490
- * _.isArray(squares);
491
- * // => false
492
- *
493
- * _.isArray(squares.value());
494
- * // => true
495
- */
496
- function lodash() {
497
- // No operation performed.
498
- }
499
-
500
- /**
501
- * The base implementation of `_.create` without support for assigning
502
- * properties to the created object.
503
- *
504
- * @private
505
- * @param {Object} proto The object to inherit from.
506
- * @returns {Object} Returns the new object.
507
- */
508
- var baseCreate = (function () {
509
- function object() {}
510
- return function (proto) {
511
- if (!isObject(proto)) {
512
- return {};
513
- }
514
- if (objectCreate) {
515
- return objectCreate(proto);
516
- }
517
- object.prototype = proto;
518
- var result = new object();
519
- object.prototype = undefined;
520
- return result;
521
- };
522
- })();
523
-
524
- /*------------------------------------------------------------------------*/
525
-
526
- /**
527
- * Creates a hash object.
528
- *
529
- * @private
530
- * @constructor
531
- * @param {Array} [entries] The key-value pairs to cache.
532
- */
533
- function Hash(entries) {
534
- var index = -1,
535
- length = entries == null ? 0 : entries.length;
536
-
537
- this.clear();
538
- while (++index < length) {
539
- var entry = entries[index];
540
- this.set(entry[0], entry[1]);
541
- }
542
- }
543
-
544
- /**
545
- * Removes all key-value entries from the hash.
546
- *
547
- * @private
548
- * @name clear
549
- * @memberOf Hash
550
- */
551
- function hashClear() {
552
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
553
- this.size = 0;
554
- }
555
-
556
- /**
557
- * Removes `key` and its value from the hash.
558
- *
559
- * @private
560
- * @name delete
561
- * @memberOf Hash
562
- * @param {Object} hash The hash to modify.
563
- * @param {string} key The key of the value to remove.
564
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
565
- */
566
- function hashDelete(key) {
567
- var result = this.has(key) && delete this.__data__[key];
568
- this.size -= result ? 1 : 0;
569
- return result;
570
- }
571
-
572
- /**
573
- * Gets the hash value for `key`.
574
- *
575
- * @private
576
- * @name get
577
- * @memberOf Hash
578
- * @param {string} key The key of the value to get.
579
- * @returns {*} Returns the entry value.
580
- */
581
- function hashGet(key) {
582
- var data = this.__data__;
583
- if (nativeCreate) {
584
- var result = data[key];
585
- return result === HASH_UNDEFINED ? undefined : result;
586
- }
587
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
588
- }
589
-
590
- /**
591
- * Checks if a hash value for `key` exists.
592
- *
593
- * @private
594
- * @name has
595
- * @memberOf Hash
596
- * @param {string} key The key of the entry to check.
597
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
598
- */
599
- function hashHas(key) {
600
- var data = this.__data__;
601
- return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
602
- }
603
-
604
- /**
605
- * Sets the hash `key` to `value`.
606
- *
607
- * @private
608
- * @name set
609
- * @memberOf Hash
610
- * @param {string} key The key of the value to set.
611
- * @param {*} value The value to set.
612
- * @returns {Object} Returns the hash instance.
613
- */
614
- function hashSet(key, value) {
615
- var data = this.__data__;
616
- this.size += this.has(key) ? 0 : 1;
617
- data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
618
- return this;
619
- }
620
-
621
- // Add methods to `Hash`.
622
- Hash.prototype.clear = hashClear;
623
- Hash.prototype['delete'] = hashDelete;
624
- Hash.prototype.get = hashGet;
625
- Hash.prototype.has = hashHas;
626
- Hash.prototype.set = hashSet;
627
-
628
- /*------------------------------------------------------------------------*/
629
-
630
- /**
631
- * Creates an list cache object.
632
- *
633
- * @private
634
- * @constructor
635
- * @param {Array} [entries] The key-value pairs to cache.
636
- */
637
- function ListCache(entries) {
638
- var index = -1,
639
- length = entries == null ? 0 : entries.length;
640
-
641
- this.clear();
642
- while (++index < length) {
643
- var entry = entries[index];
644
- this.set(entry[0], entry[1]);
645
- }
646
- }
647
-
648
- /**
649
- * Removes all key-value entries from the list cache.
650
- *
651
- * @private
652
- * @name clear
653
- * @memberOf ListCache
654
- */
655
- function listCacheClear() {
656
- this.__data__ = [];
657
- this.size = 0;
658
- }
659
-
660
- /**
661
- * Removes `key` and its value from the list cache.
662
- *
663
- * @private
664
- * @name delete
665
- * @memberOf ListCache
666
- * @param {string} key The key of the value to remove.
667
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
668
- */
669
- function listCacheDelete(key) {
670
- var data = this.__data__,
671
- index = assocIndexOf(data, key);
672
-
673
- if (index < 0) {
674
- return false;
675
- }
676
- var lastIndex = data.length - 1;
677
- if (index == lastIndex) {
678
- data.pop();
679
- } else {
680
- splice.call(data, index, 1);
681
- }
682
- --this.size;
683
- return true;
684
- }
685
-
686
- /**
687
- * Gets the list cache value for `key`.
688
- *
689
- * @private
690
- * @name get
691
- * @memberOf ListCache
692
- * @param {string} key The key of the value to get.
693
- * @returns {*} Returns the entry value.
694
- */
695
- function listCacheGet(key) {
696
- var data = this.__data__,
697
- index = assocIndexOf(data, key);
698
-
699
- return index < 0 ? undefined : data[index][1];
700
- }
701
-
702
- /**
703
- * Checks if a list cache value for `key` exists.
704
- *
705
- * @private
706
- * @name has
707
- * @memberOf ListCache
708
- * @param {string} key The key of the entry to check.
709
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
710
- */
711
- function listCacheHas(key) {
712
- return assocIndexOf(this.__data__, key) > -1;
713
- }
714
-
715
- /**
716
- * Sets the list cache `key` to `value`.
717
- *
718
- * @private
719
- * @name set
720
- * @memberOf ListCache
721
- * @param {string} key The key of the value to set.
722
- * @param {*} value The value to set.
723
- * @returns {Object} Returns the list cache instance.
724
- */
725
- function listCacheSet(key, value) {
726
- var data = this.__data__,
727
- index = assocIndexOf(data, key);
728
-
729
- if (index < 0) {
730
- ++this.size;
731
- data.push([key, value]);
732
- } else {
733
- data[index][1] = value;
734
- }
735
- return this;
736
- }
737
-
738
- // Add methods to `ListCache`.
739
- ListCache.prototype.clear = listCacheClear;
740
- ListCache.prototype['delete'] = listCacheDelete;
741
- ListCache.prototype.get = listCacheGet;
742
- ListCache.prototype.has = listCacheHas;
743
- ListCache.prototype.set = listCacheSet;
744
-
745
- /*------------------------------------------------------------------------*/
746
-
747
- /**
748
- * Creates a map cache object to store key-value pairs.
749
- *
750
- * @private
751
- * @constructor
752
- * @param {Array} [entries] The key-value pairs to cache.
753
- */
754
- function MapCache(entries) {
755
- var index = -1,
756
- length = entries == null ? 0 : entries.length;
757
-
758
- this.clear();
759
- while (++index < length) {
760
- var entry = entries[index];
761
- this.set(entry[0], entry[1]);
762
- }
763
- }
764
-
765
- /**
766
- * Removes all key-value entries from the map.
767
- *
768
- * @private
769
- * @name clear
770
- * @memberOf MapCache
771
- */
772
- function mapCacheClear() {
773
- this.size = 0;
774
- this.__data__ = {
775
- hash: new Hash(),
776
- map: new (Map || ListCache)(),
777
- string: new Hash(),
778
- };
779
- }
780
-
781
- /**
782
- * Removes `key` and its value from the map.
783
- *
784
- * @private
785
- * @name delete
786
- * @memberOf MapCache
787
- * @param {string} key The key of the value to remove.
788
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
789
- */
790
- function mapCacheDelete(key) {
791
- var result = getMapData(this, key)['delete'](key);
792
- this.size -= result ? 1 : 0;
793
- return result;
794
- }
795
-
796
- /**
797
- * Gets the map value for `key`.
798
- *
799
- * @private
800
- * @name get
801
- * @memberOf MapCache
802
- * @param {string} key The key of the value to get.
803
- * @returns {*} Returns the entry value.
804
- */
805
- function mapCacheGet(key) {
806
- return getMapData(this, key).get(key);
807
- }
808
-
809
- /**
810
- * Checks if a map value for `key` exists.
811
- *
812
- * @private
813
- * @name has
814
- * @memberOf MapCache
815
- * @param {string} key The key of the entry to check.
816
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
817
- */
818
- function mapCacheHas(key) {
819
- return getMapData(this, key).has(key);
820
- }
821
-
822
- /**
823
- * Sets the map `key` to `value`.
824
- *
825
- * @private
826
- * @name set
827
- * @memberOf MapCache
828
- * @param {string} key The key of the value to set.
829
- * @param {*} value The value to set.
830
- * @returns {Object} Returns the map cache instance.
831
- */
832
- function mapCacheSet(key, value) {
833
- var data = getMapData(this, key),
834
- size = data.size;
835
-
836
- data.set(key, value);
837
- this.size += data.size == size ? 0 : 1;
838
- return this;
839
- }
840
-
841
- // Add methods to `MapCache`.
842
- MapCache.prototype.clear = mapCacheClear;
843
- MapCache.prototype['delete'] = mapCacheDelete;
844
- MapCache.prototype.get = mapCacheGet;
845
- MapCache.prototype.has = mapCacheHas;
846
- MapCache.prototype.set = mapCacheSet;
847
-
848
- /*------------------------------------------------------------------------*/
849
-
850
- /**
851
- * Creates a stack cache object to store key-value pairs.
852
- *
853
- * @private
854
- * @constructor
855
- * @param {Array} [entries] The key-value pairs to cache.
856
- */
857
- function Stack(entries) {
858
- var data = (this.__data__ = new ListCache(entries));
859
- this.size = data.size;
860
- }
861
-
862
- /**
863
- * Removes all key-value entries from the stack.
864
- *
865
- * @private
866
- * @name clear
867
- * @memberOf Stack
868
- */
869
- function stackClear() {
870
- this.__data__ = new ListCache();
871
- this.size = 0;
872
- }
873
-
874
- /**
875
- * Removes `key` and its value from the stack.
876
- *
877
- * @private
878
- * @name delete
879
- * @memberOf Stack
880
- * @param {string} key The key of the value to remove.
881
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
882
- */
883
- function stackDelete(key) {
884
- var data = this.__data__,
885
- result = data['delete'](key);
886
-
887
- this.size = data.size;
888
- return result;
889
- }
890
-
891
- /**
892
- * Gets the stack value for `key`.
893
- *
894
- * @private
895
- * @name get
896
- * @memberOf Stack
897
- * @param {string} key The key of the value to get.
898
- * @returns {*} Returns the entry value.
899
- */
900
- function stackGet(key) {
901
- return this.__data__.get(key);
902
- }
903
-
904
- /**
905
- * Checks if a stack value for `key` exists.
906
- *
907
- * @private
908
- * @name has
909
- * @memberOf Stack
910
- * @param {string} key The key of the entry to check.
911
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
912
- */
913
- function stackHas(key) {
914
- return this.__data__.has(key);
915
- }
916
-
917
- /**
918
- * Sets the stack `key` to `value`.
919
- *
920
- * @private
921
- * @name set
922
- * @memberOf Stack
923
- * @param {string} key The key of the value to set.
924
- * @param {*} value The value to set.
925
- * @returns {Object} Returns the stack cache instance.
926
- */
927
- function stackSet(key, value) {
928
- var data = this.__data__;
929
- if (data instanceof ListCache) {
930
- var pairs = data.__data__;
931
- if (!Map || pairs.length < LARGE_ARRAY_SIZE - 1) {
932
- pairs.push([key, value]);
933
- this.size = ++data.size;
934
- return this;
935
- }
936
- data = this.__data__ = new MapCache(pairs);
937
- }
938
- data.set(key, value);
939
- this.size = data.size;
940
- return this;
941
- }
942
-
943
- // Add methods to `Stack`.
944
- Stack.prototype.clear = stackClear;
945
- Stack.prototype['delete'] = stackDelete;
946
- Stack.prototype.get = stackGet;
947
- Stack.prototype.has = stackHas;
948
- Stack.prototype.set = stackSet;
949
-
950
- /*------------------------------------------------------------------------*/
951
-
952
- /**
953
- * Creates an array of the enumerable property names of the array-like `value`.
954
- *
955
- * @private
956
- * @param {*} value The value to query.
957
- * @param {boolean} inherited Specify returning inherited property names.
958
- * @returns {Array} Returns the array of property names.
959
- */
960
- function arrayLikeKeys(value, inherited) {
961
- var isArr = isArray(value),
962
- isArg = !isArr && isArguments(value),
963
- isBuff = !isArr && !isArg && isBuffer(value),
964
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
965
- skipIndexes = isArr || isArg || isBuff || isType,
966
- result = skipIndexes ? baseTimes(value.length, String) : [],
967
- length = result.length;
968
-
969
- for (var key in value) {
970
- if (
971
- (inherited || hasOwnProperty.call(value, key)) &&
972
- !(
973
- skipIndexes &&
974
- // Safari 9 has enumerable `arguments.length` in strict mode.
975
- (key == 'length' ||
976
- // Node.js 0.10 has enumerable non-index properties on buffers.
977
- (isBuff && (key == 'offset' || key == 'parent')) ||
978
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
979
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
980
- // Skip index properties.
981
- isIndex(key, length))
982
- )
983
- ) {
984
- result.push(key);
985
- }
986
- }
987
- return result;
988
- }
989
-
990
- /**
991
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
992
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
993
- * for equality comparisons.
994
- *
995
- * @private
996
- * @param {Object} object The object to modify.
997
- * @param {string} key The key of the property to assign.
998
- * @param {*} value The value to assign.
999
- */
1000
- function assignValue(object, key, value) {
1001
- var objValue = object[key];
1002
- if (
1003
- !(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
1004
- (value === undefined && !(key in object))
1005
- ) {
1006
- baseAssignValue(object, key, value);
1007
- }
1008
- }
1009
-
1010
- /**
1011
- * Gets the index at which the `key` is found in `array` of key-value pairs.
1012
- *
1013
- * @private
1014
- * @param {Array} array The array to inspect.
1015
- * @param {*} key The key to search for.
1016
- * @returns {number} Returns the index of the matched value, else `-1`.
1017
- */
1018
- function assocIndexOf(array, key) {
1019
- var length = array.length;
1020
- while (length--) {
1021
- if (eq(array[length][0], key)) {
1022
- return length;
1023
- }
1024
- }
1025
- return -1;
1026
- }
1027
-
1028
- /**
1029
- * The base implementation of `_.assign` without support for multiple sources
1030
- * or `customizer` functions.
1031
- *
1032
- * @private
1033
- * @param {Object} object The destination object.
1034
- * @param {Object} source The source object.
1035
- * @returns {Object} Returns `object`.
1036
- */
1037
- function baseAssign(object, source) {
1038
- return object && copyObject(source, keys(source), object);
1039
- }
1040
-
1041
- /**
1042
- * The base implementation of `_.assignIn` without support for multiple sources
1043
- * or `customizer` functions.
1044
- *
1045
- * @private
1046
- * @param {Object} object The destination object.
1047
- * @param {Object} source The source object.
1048
- * @returns {Object} Returns `object`.
1049
- */
1050
- function baseAssignIn(object, source) {
1051
- return object && copyObject(source, keysIn(source), object);
1052
- }
1053
-
1054
- /**
1055
- * The base implementation of `assignValue` and `assignMergeValue` without
1056
- * value checks.
1057
- *
1058
- * @private
1059
- * @param {Object} object The object to modify.
1060
- * @param {string} key The key of the property to assign.
1061
- * @param {*} value The value to assign.
1062
- */
1063
- function baseAssignValue(object, key, value) {
1064
- if (key == '__proto__' && defineProperty) {
1065
- defineProperty(object, key, {
1066
- configurable: true,
1067
- enumerable: true,
1068
- value: value,
1069
- writable: true,
1070
- });
1071
- } else {
1072
- object[key] = value;
1073
- }
1074
- }
1075
-
1076
- /**
1077
- * The base implementation of `_.clone` and `_.cloneDeep` which tracks
1078
- * traversed objects.
1079
- *
1080
- * @private
1081
- * @param {*} value The value to clone.
1082
- * @param {boolean} bitmask The bitmask flags.
1083
- * 1 - Deep clone
1084
- * 2 - Flatten inherited properties
1085
- * 4 - Clone symbols
1086
- * @param {Function} [customizer] The function to customize cloning.
1087
- * @param {string} [key] The key of `value`.
1088
- * @param {Object} [object] The parent object of `value`.
1089
- * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
1090
- * @returns {*} Returns the cloned value.
1091
- */
1092
- function baseClone(value, bitmask, customizer, key, object, stack) {
1093
- var result,
1094
- isDeep = bitmask & CLONE_DEEP_FLAG,
1095
- isFlat = bitmask & CLONE_FLAT_FLAG,
1096
- isFull = bitmask & CLONE_SYMBOLS_FLAG;
1097
-
1098
- if (customizer) {
1099
- result = object ? customizer(value, key, object, stack) : customizer(value);
1100
- }
1101
- if (result !== undefined) {
1102
- return result;
1103
- }
1104
- if (!isObject(value)) {
1105
- return value;
1106
- }
1107
- var isArr = isArray(value);
1108
- if (isArr) {
1109
- result = initCloneArray(value);
1110
- if (!isDeep) {
1111
- return copyArray(value, result);
1112
- }
1113
- } else {
1114
- var tag = getTag(value),
1115
- isFunc = tag == funcTag || tag == genTag;
1116
-
1117
- if (isBuffer(value)) {
1118
- return cloneBuffer(value, isDeep);
1119
- }
1120
- if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
1121
- result = isFlat || isFunc ? {} : initCloneObject(value);
1122
- if (!isDeep) {
1123
- return isFlat
1124
- ? copySymbolsIn(value, baseAssignIn(result, value))
1125
- : copySymbols(value, baseAssign(result, value));
1126
- }
1127
- } else {
1128
- if (!cloneableTags[tag]) {
1129
- return object ? value : {};
1130
- }
1131
- result = initCloneByTag(value, tag, isDeep);
1132
- }
1133
- }
1134
- // Check for circular references and return its corresponding clone.
1135
- stack || (stack = new Stack());
1136
- var stacked = stack.get(value);
1137
- if (stacked) {
1138
- return stacked;
1139
- }
1140
- stack.set(value, result);
1141
-
1142
- if (isSet(value)) {
1143
- value.forEach(function (subValue) {
1144
- result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
1145
- });
1146
-
1147
- return result;
1148
- }
1149
-
1150
- if (isMap(value)) {
1151
- value.forEach(function (subValue, key) {
1152
- result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
1153
- });
1154
-
1155
- return result;
1156
- }
1157
-
1158
- var keysFunc = isFull ? (isFlat ? getAllKeysIn : getAllKeys) : isFlat ? keysIn : keys;
1159
-
1160
- var props = isArr ? undefined : keysFunc(value);
1161
- arrayEach(props || value, function (subValue, key) {
1162
- if (props) {
1163
- key = subValue;
1164
- subValue = value[key];
1165
- }
1166
- // Recursively populate clone (susceptible to call stack limits).
1167
- assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
1168
- });
1169
- return result;
1170
- }
1171
-
1172
- /**
1173
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
1174
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
1175
- * symbols of `object`.
1176
- *
1177
- * @private
1178
- * @param {Object} object The object to query.
1179
- * @param {Function} keysFunc The function to get the keys of `object`.
1180
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
1181
- * @returns {Array} Returns the array of property names and symbols.
1182
- */
1183
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1184
- var result = keysFunc(object);
1185
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
1186
- }
1187
-
1188
- /**
1189
- * The base implementation of `getTag` without fallbacks for buggy environments.
1190
- *
1191
- * @private
1192
- * @param {*} value The value to query.
1193
- * @returns {string} Returns the `toStringTag`.
1194
- */
1195
- function baseGetTag(value) {
1196
- if (value == null) {
1197
- return value === undefined ? undefinedTag : nullTag;
1198
- }
1199
- return symToStringTag && symToStringTag in Object(value)
1200
- ? getRawTag(value)
1201
- : objectToString(value);
1202
- }
1203
-
1204
- /**
1205
- * The base implementation of `_.isArguments`.
1206
- *
1207
- * @private
1208
- * @param {*} value The value to check.
1209
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1210
- */
1211
- function baseIsArguments(value) {
1212
- return isObjectLike(value) && baseGetTag(value) == argsTag;
1213
- }
1214
-
1215
- /**
1216
- * The base implementation of `_.isMap` without Node.js optimizations.
1217
- *
1218
- * @private
1219
- * @param {*} value The value to check.
1220
- * @returns {boolean} Returns `true` if `value` is a map, else `false`.
1221
- */
1222
- function baseIsMap(value) {
1223
- return isObjectLike(value) && getTag(value) == mapTag;
1224
- }
1225
-
1226
- /**
1227
- * The base implementation of `_.isNative` without bad shim checks.
1228
- *
1229
- * @private
1230
- * @param {*} value The value to check.
1231
- * @returns {boolean} Returns `true` if `value` is a native function,
1232
- * else `false`.
1233
- */
1234
- function baseIsNative(value) {
1235
- if (!isObject(value) || isMasked(value)) {
1236
- return false;
1237
- }
1238
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
1239
- return pattern.test(toSource(value));
1240
- }
1241
-
1242
- /**
1243
- * The base implementation of `_.isSet` without Node.js optimizations.
1244
- *
1245
- * @private
1246
- * @param {*} value The value to check.
1247
- * @returns {boolean} Returns `true` if `value` is a set, else `false`.
1248
- */
1249
- function baseIsSet(value) {
1250
- return isObjectLike(value) && getTag(value) == setTag;
1251
- }
1252
-
1253
- /**
1254
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
1255
- *
1256
- * @private
1257
- * @param {*} value The value to check.
1258
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1259
- */
1260
- function baseIsTypedArray(value) {
1261
- return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
1262
- }
1263
-
1264
- /**
1265
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1266
- *
1267
- * @private
1268
- * @param {Object} object The object to query.
1269
- * @returns {Array} Returns the array of property names.
1270
- */
1271
- function baseKeys(object) {
1272
- if (!isPrototype(object)) {
1273
- return nativeKeys(object);
1274
- }
1275
- var result = [];
1276
- for (var key in Object(object)) {
1277
- if (hasOwnProperty.call(object, key) && key != 'constructor') {
1278
- result.push(key);
1279
- }
1280
- }
1281
- return result;
1282
- }
1283
-
1284
- /**
1285
- * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
1286
- *
1287
- * @private
1288
- * @param {Object} object The object to query.
1289
- * @returns {Array} Returns the array of property names.
1290
- */
1291
- function baseKeysIn(object) {
1292
- if (!isObject(object)) {
1293
- return nativeKeysIn(object);
1294
- }
1295
- var isProto = isPrototype(object),
1296
- result = [];
1297
-
1298
- for (var key in object) {
1299
- if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
1300
- result.push(key);
1301
- }
1302
- }
1303
- return result;
1304
- }
1305
-
1306
- /**
1307
- * Creates a clone of `buffer`.
1308
- *
1309
- * @private
1310
- * @param {Buffer} buffer The buffer to clone.
1311
- * @param {boolean} [isDeep] Specify a deep clone.
1312
- * @returns {Buffer} Returns the cloned buffer.
1313
- */
1314
- function cloneBuffer(buffer, isDeep) {
1315
- if (isDeep) {
1316
- return buffer.slice();
1317
- }
1318
- var length = buffer.length,
1319
- result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
1320
-
1321
- buffer.copy(result);
1322
- return result;
1323
- }
1324
-
1325
- /**
1326
- * Creates a clone of `arrayBuffer`.
1327
- *
1328
- * @private
1329
- * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
1330
- * @returns {ArrayBuffer} Returns the cloned array buffer.
1331
- */
1332
- function cloneArrayBuffer(arrayBuffer) {
1333
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1334
- new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1335
- return result;
1336
- }
1337
-
1338
- /**
1339
- * Creates a clone of `dataView`.
1340
- *
1341
- * @private
1342
- * @param {Object} dataView The data view to clone.
1343
- * @param {boolean} [isDeep] Specify a deep clone.
1344
- * @returns {Object} Returns the cloned data view.
1345
- */
1346
- function cloneDataView(dataView, isDeep) {
1347
- var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
1348
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
1349
- }
1350
-
1351
- /**
1352
- * Creates a clone of `regexp`.
1353
- *
1354
- * @private
1355
- * @param {Object} regexp The regexp to clone.
1356
- * @returns {Object} Returns the cloned regexp.
1357
- */
1358
- function cloneRegExp(regexp) {
1359
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
1360
- result.lastIndex = regexp.lastIndex;
1361
- return result;
1362
- }
1363
-
1364
- /**
1365
- * Creates a clone of the `symbol` object.
1366
- *
1367
- * @private
1368
- * @param {Object} symbol The symbol object to clone.
1369
- * @returns {Object} Returns the cloned symbol object.
1370
- */
1371
- function cloneSymbol(symbol) {
1372
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
1373
- }
1374
-
1375
- /**
1376
- * Creates a clone of `typedArray`.
1377
- *
1378
- * @private
1379
- * @param {Object} typedArray The typed array to clone.
1380
- * @param {boolean} [isDeep] Specify a deep clone.
1381
- * @returns {Object} Returns the cloned typed array.
1382
- */
1383
- function cloneTypedArray(typedArray, isDeep) {
1384
- var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1385
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1386
- }
1387
-
1388
- /**
1389
- * Copies the values of `source` to `array`.
1390
- *
1391
- * @private
1392
- * @param {Array} source The array to copy values from.
1393
- * @param {Array} [array=[]] The array to copy values to.
1394
- * @returns {Array} Returns `array`.
1395
- */
1396
- function copyArray(source, array) {
1397
- var index = -1,
1398
- length = source.length;
1399
-
1400
- array || (array = Array(length));
1401
- while (++index < length) {
1402
- array[index] = source[index];
1403
- }
1404
- return array;
1405
- }
1406
-
1407
- /**
1408
- * Copies properties of `source` to `object`.
1409
- *
1410
- * @private
1411
- * @param {Object} source The object to copy properties from.
1412
- * @param {Array} props The property identifiers to copy.
1413
- * @param {Object} [object={}] The object to copy properties to.
1414
- * @param {Function} [customizer] The function to customize copied values.
1415
- * @returns {Object} Returns `object`.
1416
- */
1417
- function copyObject(source, props, object, customizer) {
1418
- var isNew = !object;
1419
- object || (object = {});
1420
-
1421
- var index = -1,
1422
- length = props.length;
1423
-
1424
- while (++index < length) {
1425
- var key = props[index];
1426
-
1427
- var newValue = customizer
1428
- ? customizer(object[key], source[key], key, object, source)
1429
- : undefined;
1430
-
1431
- if (newValue === undefined) {
1432
- newValue = source[key];
1433
- }
1434
- if (isNew) {
1435
- baseAssignValue(object, key, newValue);
1436
- } else {
1437
- assignValue(object, key, newValue);
1438
- }
1439
- }
1440
- return object;
1441
- }
1442
-
1443
- /**
1444
- * Copies own symbols of `source` to `object`.
1445
- *
1446
- * @private
1447
- * @param {Object} source The object to copy symbols from.
1448
- * @param {Object} [object={}] The object to copy symbols to.
1449
- * @returns {Object} Returns `object`.
1450
- */
1451
- function copySymbols(source, object) {
1452
- return copyObject(source, getSymbols(source), object);
1453
- }
1454
-
1455
- /**
1456
- * Copies own and inherited symbols of `source` to `object`.
1457
- *
1458
- * @private
1459
- * @param {Object} source The object to copy symbols from.
1460
- * @param {Object} [object={}] The object to copy symbols to.
1461
- * @returns {Object} Returns `object`.
1462
- */
1463
- function copySymbolsIn(source, object) {
1464
- return copyObject(source, getSymbolsIn(source), object);
1465
- }
1466
-
1467
- /**
1468
- * Creates an array of own enumerable property names and symbols of `object`.
1469
- *
1470
- * @private
1471
- * @param {Object} object The object to query.
1472
- * @returns {Array} Returns the array of property names and symbols.
1473
- */
1474
- function getAllKeys(object) {
1475
- return baseGetAllKeys(object, keys, getSymbols);
1476
- }
1477
-
1478
- /**
1479
- * Creates an array of own and inherited enumerable property names and
1480
- * symbols of `object`.
1481
- *
1482
- * @private
1483
- * @param {Object} object The object to query.
1484
- * @returns {Array} Returns the array of property names and symbols.
1485
- */
1486
- function getAllKeysIn(object) {
1487
- return baseGetAllKeys(object, keysIn, getSymbolsIn);
1488
- }
1489
-
1490
- /**
1491
- * Gets the data for `map`.
1492
- *
1493
- * @private
1494
- * @param {Object} map The map to query.
1495
- * @param {string} key The reference key.
1496
- * @returns {*} Returns the map data.
1497
- */
1498
- function getMapData(map, key) {
1499
- var data = map.__data__;
1500
- return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
1501
- }
1502
-
1503
- /**
1504
- * Gets the native function at `key` of `object`.
1505
- *
1506
- * @private
1507
- * @param {Object} object The object to query.
1508
- * @param {string} key The key of the method to get.
1509
- * @returns {*} Returns the function if it's native, else `undefined`.
1510
- */
1511
- function getNative(object, key) {
1512
- var value = getValue(object, key);
1513
- return baseIsNative(value) ? value : undefined;
1514
- }
1515
-
1516
- /**
1517
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1518
- *
1519
- * @private
1520
- * @param {*} value The value to query.
1521
- * @returns {string} Returns the raw `toStringTag`.
1522
- */
1523
- function getRawTag(value) {
1524
- var isOwn = hasOwnProperty.call(value, symToStringTag),
1525
- tag = value[symToStringTag];
1526
-
1527
- try {
1528
- value[symToStringTag] = undefined;
1529
- var unmasked = true;
1530
- } catch (e) {}
1531
-
1532
- var result = nativeObjectToString.call(value);
1533
- if (unmasked) {
1534
- if (isOwn) {
1535
- value[symToStringTag] = tag;
1536
- } else {
1537
- delete value[symToStringTag];
1538
- }
1539
- }
1540
- return result;
1541
- }
1542
-
1543
- /**
1544
- * Creates an array of the own enumerable symbols of `object`.
1545
- *
1546
- * @private
1547
- * @param {Object} object The object to query.
1548
- * @returns {Array} Returns the array of symbols.
1549
- */
1550
- var getSymbols = !nativeGetSymbols
1551
- ? stubArray
1552
- : function (object) {
1553
- if (object == null) {
1554
- return [];
1555
- }
1556
- object = Object(object);
1557
- return arrayFilter(nativeGetSymbols(object), function (symbol) {
1558
- return propertyIsEnumerable.call(object, symbol);
1559
- });
1560
- };
1561
-
1562
- /**
1563
- * Creates an array of the own and inherited enumerable symbols of `object`.
1564
- *
1565
- * @private
1566
- * @param {Object} object The object to query.
1567
- * @returns {Array} Returns the array of symbols.
1568
- */
1569
- var getSymbolsIn = !nativeGetSymbols
1570
- ? stubArray
1571
- : function (object) {
1572
- var result = [];
1573
- while (object) {
1574
- arrayPush(result, getSymbols(object));
1575
- object = getPrototype(object);
1576
- }
1577
- return result;
1578
- };
1579
-
1580
- /**
1581
- * Gets the `toStringTag` of `value`.
1582
- *
1583
- * @private
1584
- * @param {*} value The value to query.
1585
- * @returns {string} Returns the `toStringTag`.
1586
- */
1587
- var getTag = baseGetTag;
1588
-
1589
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
1590
- if (
1591
- (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1592
- (Map && getTag(new Map()) != mapTag) ||
1593
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
1594
- (Set && getTag(new Set()) != setTag) ||
1595
- (WeakMap && getTag(new WeakMap()) != weakMapTag)
1596
- ) {
1597
- getTag = function (value) {
1598
- var result = baseGetTag(value),
1599
- Ctor = result == objectTag ? value.constructor : undefined,
1600
- ctorString = Ctor ? toSource(Ctor) : '';
1601
-
1602
- if (ctorString) {
1603
- switch (ctorString) {
1604
- case dataViewCtorString:
1605
- return dataViewTag;
1606
- case mapCtorString:
1607
- return mapTag;
1608
- case promiseCtorString:
1609
- return promiseTag;
1610
- case setCtorString:
1611
- return setTag;
1612
- case weakMapCtorString:
1613
- return weakMapTag;
1614
- }
1615
- }
1616
- return result;
1617
- };
1618
- }
1619
-
1620
- /**
1621
- * Initializes an array clone.
1622
- *
1623
- * @private
1624
- * @param {Array} array The array to clone.
1625
- * @returns {Array} Returns the initialized clone.
1626
- */
1627
- function initCloneArray(array) {
1628
- var length = array.length,
1629
- result = new array.constructor(length);
1630
-
1631
- // Add properties assigned by `RegExp#exec`.
1632
- if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
1633
- result.index = array.index;
1634
- result.input = array.input;
1635
- }
1636
- return result;
1637
- }
1638
-
1639
- /**
1640
- * Initializes an object clone.
1641
- *
1642
- * @private
1643
- * @param {Object} object The object to clone.
1644
- * @returns {Object} Returns the initialized clone.
1645
- */
1646
- function initCloneObject(object) {
1647
- return typeof object.constructor == 'function' && !isPrototype(object)
1648
- ? baseCreate(getPrototype(object))
1649
- : {};
1650
- }
1651
-
1652
- /**
1653
- * Initializes an object clone based on its `toStringTag`.
1654
- *
1655
- * **Note:** This function only supports cloning values with tags of
1656
- * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
1657
- *
1658
- * @private
1659
- * @param {Object} object The object to clone.
1660
- * @param {string} tag The `toStringTag` of the object to clone.
1661
- * @param {boolean} [isDeep] Specify a deep clone.
1662
- * @returns {Object} Returns the initialized clone.
1663
- */
1664
- function initCloneByTag(object, tag, isDeep) {
1665
- var Ctor = object.constructor;
1666
- switch (tag) {
1667
- case arrayBufferTag:
1668
- return cloneArrayBuffer(object);
1669
-
1670
- case boolTag:
1671
- case dateTag:
1672
- return new Ctor(+object);
1673
-
1674
- case dataViewTag:
1675
- return cloneDataView(object, isDeep);
1676
-
1677
- case float32Tag:
1678
- case float64Tag:
1679
- case int8Tag:
1680
- case int16Tag:
1681
- case int32Tag:
1682
- case uint8Tag:
1683
- case uint8ClampedTag:
1684
- case uint16Tag:
1685
- case uint32Tag:
1686
- return cloneTypedArray(object, isDeep);
1687
-
1688
- case mapTag:
1689
- return new Ctor();
1690
-
1691
- case numberTag:
1692
- case stringTag:
1693
- return new Ctor(object);
1694
-
1695
- case regexpTag:
1696
- return cloneRegExp(object);
1697
-
1698
- case setTag:
1699
- return new Ctor();
1700
-
1701
- case symbolTag:
1702
- return cloneSymbol(object);
1703
- }
1704
- }
1705
-
1706
- /**
1707
- * Checks if `value` is a valid array-like index.
1708
- *
1709
- * @private
1710
- * @param {*} value The value to check.
1711
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1712
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1713
- */
1714
- function isIndex(value, length) {
1715
- var type = typeof value;
1716
- length = length == null ? MAX_SAFE_INTEGER : length;
1717
-
1718
- return (
1719
- !!length &&
1720
- (type == 'number' || (type != 'symbol' && reIsUint.test(value))) &&
1721
- value > -1 &&
1722
- value % 1 == 0 &&
1723
- value < length
1724
- );
1725
- }
1726
-
1727
- /**
1728
- * Checks if `value` is suitable for use as unique object key.
1729
- *
1730
- * @private
1731
- * @param {*} value The value to check.
1732
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1733
- */
1734
- function isKeyable(value) {
1735
- var type = typeof value;
1736
- return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean'
1737
- ? value !== '__proto__'
1738
- : value === null;
1739
- }
1740
-
1741
- /**
1742
- * Checks if `func` has its source masked.
1743
- *
1744
- * @private
1745
- * @param {Function} func The function to check.
1746
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1747
- */
1748
- function isMasked(func) {
1749
- return !!maskSrcKey && maskSrcKey in func;
1750
- }
1751
-
1752
- /**
1753
- * Checks if `value` is likely a prototype object.
1754
- *
1755
- * @private
1756
- * @param {*} value The value to check.
1757
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1758
- */
1759
- function isPrototype(value) {
1760
- var Ctor = value && value.constructor,
1761
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1762
-
1763
- return value === proto;
1764
- }
1765
-
1766
- /**
1767
- * This function is like
1768
- * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1769
- * except that it includes inherited enumerable properties.
1770
- *
1771
- * @private
1772
- * @param {Object} object The object to query.
1773
- * @returns {Array} Returns the array of property names.
1774
- */
1775
- function nativeKeysIn(object) {
1776
- var result = [];
1777
- if (object != null) {
1778
- for (var key in Object(object)) {
1779
- result.push(key);
1780
- }
1781
- }
1782
- return result;
1783
- }
1784
-
1785
- /**
1786
- * Converts `value` to a string using `Object.prototype.toString`.
1787
- *
1788
- * @private
1789
- * @param {*} value The value to convert.
1790
- * @returns {string} Returns the converted string.
1791
- */
1792
- function objectToString(value) {
1793
- return nativeObjectToString.call(value);
1794
- }
1795
-
1796
- /**
1797
- * Converts `func` to its source code.
1798
- *
1799
- * @private
1800
- * @param {Function} func The function to convert.
1801
- * @returns {string} Returns the source code.
1802
- */
1803
- function toSource(func) {
1804
- if (func != null) {
1805
- try {
1806
- return funcToString.call(func);
1807
- } catch (e) {}
1808
- try {
1809
- return func + '';
1810
- } catch (e) {}
1811
- }
1812
- return '';
1813
- }
1814
-
1815
- /*------------------------------------------------------------------------*/
1816
-
1817
- /**
1818
- * Creates a shallow clone of `value`.
1819
- *
1820
- * **Note:** This method is loosely based on the
1821
- * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
1822
- * and supports cloning arrays, array buffers, booleans, date objects, maps,
1823
- * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
1824
- * arrays. The own enumerable properties of `arguments` objects are cloned
1825
- * as plain objects. An empty object is returned for uncloneable values such
1826
- * as error objects, functions, DOM nodes, and WeakMaps.
1827
- *
1828
- * @static
1829
- * @memberOf _
1830
- * @since 0.1.0
1831
- * @category Lang
1832
- * @param {*} value The value to clone.
1833
- * @returns {*} Returns the cloned value.
1834
- * @see _.cloneDeep
1835
- * @example
1836
- *
1837
- * var objects = [{ 'a': 1 }, { 'b': 2 }];
1838
- *
1839
- * var shallow = _.clone(objects);
1840
- * console.log(shallow[0] === objects[0]);
1841
- * // => true
1842
- */
1843
- function clone(value) {
1844
- return baseClone(value, CLONE_SYMBOLS_FLAG);
1845
- }
1846
-
1847
- /**
1848
- * This method is like `_.clone` except that it recursively clones `value`.
1849
- *
1850
- * @static
1851
- * @memberOf _
1852
- * @since 1.0.0
1853
- * @category Lang
1854
- * @param {*} value The value to recursively clone.
1855
- * @returns {*} Returns the deep cloned value.
1856
- * @see _.clone
1857
- * @example
1858
- *
1859
- * var objects = [{ 'a': 1 }, { 'b': 2 }];
1860
- *
1861
- * var deep = _.cloneDeep(objects);
1862
- * console.log(deep[0] === objects[0]);
1863
- * // => false
1864
- */
1865
- function cloneDeep(value) {
1866
- return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
1867
- }
1868
-
1869
- /**
1870
- * Performs a
1871
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1872
- * comparison between two values to determine if they are equivalent.
1873
- *
1874
- * @static
1875
- * @memberOf _
1876
- * @since 4.0.0
1877
- * @category Lang
1878
- * @param {*} value The value to compare.
1879
- * @param {*} other The other value to compare.
1880
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1881
- * @example
1882
- *
1883
- * var object = { 'a': 1 };
1884
- * var other = { 'a': 1 };
1885
- *
1886
- * _.eq(object, object);
1887
- * // => true
1888
- *
1889
- * _.eq(object, other);
1890
- * // => false
1891
- *
1892
- * _.eq('a', 'a');
1893
- * // => true
1894
- *
1895
- * _.eq('a', Object('a'));
1896
- * // => false
1897
- *
1898
- * _.eq(NaN, NaN);
1899
- * // => true
1900
- */
1901
- function eq(value, other) {
1902
- return value === other || (value !== value && other !== other);
1903
- }
1904
-
1905
- /**
1906
- * Checks if `value` is likely an `arguments` object.
1907
- *
1908
- * @static
1909
- * @memberOf _
1910
- * @since 0.1.0
1911
- * @category Lang
1912
- * @param {*} value The value to check.
1913
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1914
- * else `false`.
1915
- * @example
1916
- *
1917
- * _.isArguments(function() { return arguments; }());
1918
- * // => true
1919
- *
1920
- * _.isArguments([1, 2, 3]);
1921
- * // => false
1922
- */
1923
- var isArguments = baseIsArguments(
1924
- (function () {
1925
- return arguments;
1926
- })(),
1927
- )
1928
- ? baseIsArguments
1929
- : function (value) {
1930
- return (
1931
- isObjectLike(value) &&
1932
- hasOwnProperty.call(value, 'callee') &&
1933
- !propertyIsEnumerable.call(value, 'callee')
1934
- );
1935
- };
1936
-
1937
- /**
1938
- * Checks if `value` is classified as an `Array` object.
1939
- *
1940
- * @static
1941
- * @memberOf _
1942
- * @since 0.1.0
1943
- * @category Lang
1944
- * @param {*} value The value to check.
1945
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1946
- * @example
1947
- *
1948
- * _.isArray([1, 2, 3]);
1949
- * // => true
1950
- *
1951
- * _.isArray(document.body.children);
1952
- * // => false
1953
- *
1954
- * _.isArray('abc');
1955
- * // => false
1956
- *
1957
- * _.isArray(_.noop);
1958
- * // => false
1959
- */
1960
- var isArray = Array.isArray;
1961
-
1962
- /**
1963
- * Checks if `value` is array-like. A value is considered array-like if it's
1964
- * not a function and has a `value.length` that's an integer greater than or
1965
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1966
- *
1967
- * @static
1968
- * @memberOf _
1969
- * @since 4.0.0
1970
- * @category Lang
1971
- * @param {*} value The value to check.
1972
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1973
- * @example
1974
- *
1975
- * _.isArrayLike([1, 2, 3]);
1976
- * // => true
1977
- *
1978
- * _.isArrayLike(document.body.children);
1979
- * // => true
1980
- *
1981
- * _.isArrayLike('abc');
1982
- * // => true
1983
- *
1984
- * _.isArrayLike(_.noop);
1985
- * // => false
1986
- */
1987
- function isArrayLike(value) {
1988
- return value != null && isLength(value.length) && !isFunction(value);
1989
- }
1990
-
1991
- /**
1992
- * Checks if `value` is a buffer.
1993
- *
1994
- * @static
1995
- * @memberOf _
1996
- * @since 4.3.0
1997
- * @category Lang
1998
- * @param {*} value The value to check.
1999
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
2000
- * @example
2001
- *
2002
- * _.isBuffer(new Buffer(2));
2003
- * // => true
2004
- *
2005
- * _.isBuffer(new Uint8Array(2));
2006
- * // => false
2007
- */
2008
- var isBuffer = nativeIsBuffer || stubFalse;
2009
-
2010
- /**
2011
- * Checks if `value` is classified as a `Function` object.
2012
- *
2013
- * @static
2014
- * @memberOf _
2015
- * @since 0.1.0
2016
- * @category Lang
2017
- * @param {*} value The value to check.
2018
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2019
- * @example
2020
- *
2021
- * _.isFunction(_);
2022
- * // => true
2023
- *
2024
- * _.isFunction(/abc/);
2025
- * // => false
2026
- */
2027
- function isFunction(value) {
2028
- if (!isObject(value)) {
2029
- return false;
2030
- }
2031
- // The use of `Object#toString` avoids issues with the `typeof` operator
2032
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
2033
- var tag = baseGetTag(value);
2034
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
2035
- }
2036
-
2037
- /**
2038
- * Checks if `value` is a valid array-like length.
2039
- *
2040
- * **Note:** This method is loosely based on
2041
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2042
- *
2043
- * @static
2044
- * @memberOf _
2045
- * @since 4.0.0
2046
- * @category Lang
2047
- * @param {*} value The value to check.
2048
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2049
- * @example
2050
- *
2051
- * _.isLength(3);
2052
- * // => true
2053
- *
2054
- * _.isLength(Number.MIN_VALUE);
2055
- * // => false
2056
- *
2057
- * _.isLength(Infinity);
2058
- * // => false
2059
- *
2060
- * _.isLength('3');
2061
- * // => false
2062
- */
2063
- function isLength(value) {
2064
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2065
- }
2066
-
2067
- /**
2068
- * Checks if `value` is the
2069
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2070
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2071
- *
2072
- * @static
2073
- * @memberOf _
2074
- * @since 0.1.0
2075
- * @category Lang
2076
- * @param {*} value The value to check.
2077
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2078
- * @example
2079
- *
2080
- * _.isObject({});
2081
- * // => true
2082
- *
2083
- * _.isObject([1, 2, 3]);
2084
- * // => true
2085
- *
2086
- * _.isObject(_.noop);
2087
- * // => true
2088
- *
2089
- * _.isObject(null);
2090
- * // => false
2091
- */
2092
- function isObject(value) {
2093
- var type = typeof value;
2094
- return value != null && (type == 'object' || type == 'function');
2095
- }
2096
-
2097
- /**
2098
- * Checks if `value` is object-like. A value is object-like if it's not `null`
2099
- * and has a `typeof` result of "object".
2100
- *
2101
- * @static
2102
- * @memberOf _
2103
- * @since 4.0.0
2104
- * @category Lang
2105
- * @param {*} value The value to check.
2106
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2107
- * @example
2108
- *
2109
- * _.isObjectLike({});
2110
- * // => true
2111
- *
2112
- * _.isObjectLike([1, 2, 3]);
2113
- * // => true
2114
- *
2115
- * _.isObjectLike(_.noop);
2116
- * // => false
2117
- *
2118
- * _.isObjectLike(null);
2119
- * // => false
2120
- */
2121
- function isObjectLike(value) {
2122
- return value != null && typeof value == 'object';
2123
- }
2124
-
2125
- /**
2126
- * Checks if `value` is classified as a `Map` object.
2127
- *
2128
- * @static
2129
- * @memberOf _
2130
- * @since 4.3.0
2131
- * @category Lang
2132
- * @param {*} value The value to check.
2133
- * @returns {boolean} Returns `true` if `value` is a map, else `false`.
2134
- * @example
2135
- *
2136
- * _.isMap(new Map);
2137
- * // => true
2138
- *
2139
- * _.isMap(new WeakMap);
2140
- * // => false
2141
- */
2142
- var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
2143
-
2144
- /**
2145
- * Checks if `value` is classified as a `Set` object.
2146
- *
2147
- * @static
2148
- * @memberOf _
2149
- * @since 4.3.0
2150
- * @category Lang
2151
- * @param {*} value The value to check.
2152
- * @returns {boolean} Returns `true` if `value` is a set, else `false`.
2153
- * @example
2154
- *
2155
- * _.isSet(new Set);
2156
- * // => true
2157
- *
2158
- * _.isSet(new WeakSet);
2159
- * // => false
2160
- */
2161
- var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
2162
-
2163
- /**
2164
- * Checks if `value` is classified as a typed array.
2165
- *
2166
- * @static
2167
- * @memberOf _
2168
- * @since 3.0.0
2169
- * @category Lang
2170
- * @param {*} value The value to check.
2171
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2172
- * @example
2173
- *
2174
- * _.isTypedArray(new Uint8Array);
2175
- * // => true
2176
- *
2177
- * _.isTypedArray([]);
2178
- * // => false
2179
- */
2180
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
2181
-
2182
- /*------------------------------------------------------------------------*/
2183
-
2184
- /**
2185
- * Creates an array of the own enumerable property names of `object`.
2186
- *
2187
- * **Note:** Non-object values are coerced to objects. See the
2188
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2189
- * for more details.
2190
- *
2191
- * @static
2192
- * @since 0.1.0
2193
- * @memberOf _
2194
- * @category Object
2195
- * @param {Object} object The object to query.
2196
- * @returns {Array} Returns the array of property names.
2197
- * @example
2198
- *
2199
- * function Foo() {
2200
- * this.a = 1;
2201
- * this.b = 2;
2202
- * }
2203
- *
2204
- * Foo.prototype.c = 3;
2205
- *
2206
- * _.keys(new Foo);
2207
- * // => ['a', 'b'] (iteration order is not guaranteed)
2208
- *
2209
- * _.keys('hi');
2210
- * // => ['0', '1']
2211
- */
2212
- function keys(object) {
2213
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
2214
- }
2215
-
2216
- /**
2217
- * Creates an array of the own and inherited enumerable property names of `object`.
2218
- *
2219
- * **Note:** Non-object values are coerced to objects.
2220
- *
2221
- * @static
2222
- * @memberOf _
2223
- * @since 3.0.0
2224
- * @category Object
2225
- * @param {Object} object The object to query.
2226
- * @returns {Array} Returns the array of property names.
2227
- * @example
2228
- *
2229
- * function Foo() {
2230
- * this.a = 1;
2231
- * this.b = 2;
2232
- * }
2233
- *
2234
- * Foo.prototype.c = 3;
2235
- *
2236
- * _.keysIn(new Foo);
2237
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
2238
- */
2239
- function keysIn(object) {
2240
- return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
2241
- }
2242
-
2243
- /*------------------------------------------------------------------------*/
2244
-
2245
- /**
2246
- * This method returns a new empty array.
2247
- *
2248
- * @static
2249
- * @memberOf _
2250
- * @since 4.13.0
2251
- * @category Util
2252
- * @returns {Array} Returns the new empty array.
2253
- * @example
2254
- *
2255
- * var arrays = _.times(2, _.stubArray);
2256
- *
2257
- * console.log(arrays);
2258
- * // => [[], []]
2259
- *
2260
- * console.log(arrays[0] === arrays[1]);
2261
- * // => false
2262
- */
2263
- function stubArray() {
2264
- return [];
2265
- }
2266
-
2267
- /**
2268
- * This method returns `false`.
2269
- *
2270
- * @static
2271
- * @memberOf _
2272
- * @since 4.13.0
2273
- * @category Util
2274
- * @returns {boolean} Returns `false`.
2275
- * @example
2276
- *
2277
- * _.times(2, _.stubFalse);
2278
- * // => [false, false]
2279
- */
2280
- function stubFalse() {
2281
- return false;
2282
- }
2283
-
2284
- /*------------------------------------------------------------------------*/
2285
-
2286
- // Add methods that return wrapped values in chain sequences.
2287
- lodash.keys = keys;
2288
- lodash.keysIn = keysIn;
2289
-
2290
- /*------------------------------------------------------------------------*/
2291
-
2292
- // Add methods that return unwrapped values in chain sequences.
2293
- lodash.clone = clone;
2294
- lodash.cloneDeep = cloneDeep;
2295
- lodash.eq = eq;
2296
- lodash.isArguments = isArguments;
2297
- lodash.isArray = isArray;
2298
- lodash.isArrayLike = isArrayLike;
2299
- lodash.isBuffer = isBuffer;
2300
- lodash.isFunction = isFunction;
2301
- lodash.isLength = isLength;
2302
- lodash.isMap = isMap;
2303
- lodash.isObject = isObject;
2304
- lodash.isObjectLike = isObjectLike;
2305
- lodash.isSet = isSet;
2306
- lodash.isTypedArray = isTypedArray;
2307
- lodash.stubArray = stubArray;
2308
- lodash.stubFalse = stubFalse;
2309
-
2310
- /*------------------------------------------------------------------------*/
2311
-
2312
- /**
2313
- * The semantic version number.
2314
- *
2315
- * @static
2316
- * @memberOf _
2317
- * @type {string}
2318
- */
2319
- lodash.VERSION = VERSION;
2320
-
2321
- /*--------------------------------------------------------------------------*/
2322
-
2323
- if (freeModule) {
2324
- // Export for Node.js.
2325
- (freeModule.exports = lodash)._ = lodash;
2326
- // Export for CommonJS support.
2327
- freeExports._ = lodash;
2328
- }
2329
- }).call(this);