1 | /**
|
---|
2 | * @license
|
---|
3 | * Lodash (Custom Build) <https://lodash.com/>
|
---|
4 | * Build: `lodash modularize exports="es" -o ./`
|
---|
5 | * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
---|
6 | * Released under MIT license <https://lodash.com/license>
|
---|
7 | * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
---|
8 | * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
---|
9 | */
|
---|
10 | import array from './array.js';
|
---|
11 | import collection from './collection.js';
|
---|
12 | import date from './date.js';
|
---|
13 | import func from './function.js';
|
---|
14 | import lang from './lang.js';
|
---|
15 | import math from './math.js';
|
---|
16 | import number from './number.js';
|
---|
17 | import object from './object.js';
|
---|
18 | import seq from './seq.js';
|
---|
19 | import string from './string.js';
|
---|
20 | import util from './util.js';
|
---|
21 | import LazyWrapper from './_LazyWrapper.js';
|
---|
22 | import LodashWrapper from './_LodashWrapper.js';
|
---|
23 | import Symbol from './_Symbol.js';
|
---|
24 | import arrayEach from './_arrayEach.js';
|
---|
25 | import arrayPush from './_arrayPush.js';
|
---|
26 | import baseForOwn from './_baseForOwn.js';
|
---|
27 | import baseFunctions from './_baseFunctions.js';
|
---|
28 | import baseInvoke from './_baseInvoke.js';
|
---|
29 | import baseIteratee from './_baseIteratee.js';
|
---|
30 | import baseRest from './_baseRest.js';
|
---|
31 | import createHybrid from './_createHybrid.js';
|
---|
32 | import identity from './identity.js';
|
---|
33 | import isArray from './isArray.js';
|
---|
34 | import isObject from './isObject.js';
|
---|
35 | import keys from './keys.js';
|
---|
36 | import last from './last.js';
|
---|
37 | import lazyClone from './_lazyClone.js';
|
---|
38 | import lazyReverse from './_lazyReverse.js';
|
---|
39 | import lazyValue from './_lazyValue.js';
|
---|
40 | import _mixin from './mixin.js';
|
---|
41 | import negate from './negate.js';
|
---|
42 | import realNames from './_realNames.js';
|
---|
43 | import thru from './thru.js';
|
---|
44 | import toInteger from './toInteger.js';
|
---|
45 | import lodash from './wrapperLodash.js';
|
---|
46 |
|
---|
47 | /** Used as the semantic version number. */
|
---|
48 | var VERSION = '4.17.21';
|
---|
49 |
|
---|
50 | /** Used to compose bitmasks for function metadata. */
|
---|
51 | var WRAP_BIND_KEY_FLAG = 2;
|
---|
52 |
|
---|
53 | /** Used to indicate the type of lazy iteratees. */
|
---|
54 | var LAZY_FILTER_FLAG = 1,
|
---|
55 | LAZY_WHILE_FLAG = 3;
|
---|
56 |
|
---|
57 | /** Used as references for the maximum length and index of an array. */
|
---|
58 | var MAX_ARRAY_LENGTH = 4294967295;
|
---|
59 |
|
---|
60 | /** Used for built-in method references. */
|
---|
61 | var arrayProto = Array.prototype,
|
---|
62 | objectProto = Object.prototype;
|
---|
63 |
|
---|
64 | /** Used to check objects for own properties. */
|
---|
65 | var hasOwnProperty = objectProto.hasOwnProperty;
|
---|
66 |
|
---|
67 | /** Built-in value references. */
|
---|
68 | var symIterator = Symbol ? Symbol.iterator : undefined;
|
---|
69 |
|
---|
70 | /* Built-in method references for those with the same name as other `lodash` methods. */
|
---|
71 | var nativeMax = Math.max,
|
---|
72 | nativeMin = Math.min;
|
---|
73 |
|
---|
74 | // wrap `_.mixin` so it works when provided only one argument
|
---|
75 | var mixin = (function(func) {
|
---|
76 | return function(object, source, options) {
|
---|
77 | if (options == null) {
|
---|
78 | var isObj = isObject(source),
|
---|
79 | props = isObj && keys(source),
|
---|
80 | methodNames = props && props.length && baseFunctions(source, props);
|
---|
81 |
|
---|
82 | if (!(methodNames ? methodNames.length : isObj)) {
|
---|
83 | options = source;
|
---|
84 | source = object;
|
---|
85 | object = this;
|
---|
86 | }
|
---|
87 | }
|
---|
88 | return func(object, source, options);
|
---|
89 | };
|
---|
90 | }(_mixin));
|
---|
91 |
|
---|
92 | // Add methods that return wrapped values in chain sequences.
|
---|
93 | lodash.after = func.after;
|
---|
94 | lodash.ary = func.ary;
|
---|
95 | lodash.assign = object.assign;
|
---|
96 | lodash.assignIn = object.assignIn;
|
---|
97 | lodash.assignInWith = object.assignInWith;
|
---|
98 | lodash.assignWith = object.assignWith;
|
---|
99 | lodash.at = object.at;
|
---|
100 | lodash.before = func.before;
|
---|
101 | lodash.bind = func.bind;
|
---|
102 | lodash.bindAll = util.bindAll;
|
---|
103 | lodash.bindKey = func.bindKey;
|
---|
104 | lodash.castArray = lang.castArray;
|
---|
105 | lodash.chain = seq.chain;
|
---|
106 | lodash.chunk = array.chunk;
|
---|
107 | lodash.compact = array.compact;
|
---|
108 | lodash.concat = array.concat;
|
---|
109 | lodash.cond = util.cond;
|
---|
110 | lodash.conforms = util.conforms;
|
---|
111 | lodash.constant = util.constant;
|
---|
112 | lodash.countBy = collection.countBy;
|
---|
113 | lodash.create = object.create;
|
---|
114 | lodash.curry = func.curry;
|
---|
115 | lodash.curryRight = func.curryRight;
|
---|
116 | lodash.debounce = func.debounce;
|
---|
117 | lodash.defaults = object.defaults;
|
---|
118 | lodash.defaultsDeep = object.defaultsDeep;
|
---|
119 | lodash.defer = func.defer;
|
---|
120 | lodash.delay = func.delay;
|
---|
121 | lodash.difference = array.difference;
|
---|
122 | lodash.differenceBy = array.differenceBy;
|
---|
123 | lodash.differenceWith = array.differenceWith;
|
---|
124 | lodash.drop = array.drop;
|
---|
125 | lodash.dropRight = array.dropRight;
|
---|
126 | lodash.dropRightWhile = array.dropRightWhile;
|
---|
127 | lodash.dropWhile = array.dropWhile;
|
---|
128 | lodash.fill = array.fill;
|
---|
129 | lodash.filter = collection.filter;
|
---|
130 | lodash.flatMap = collection.flatMap;
|
---|
131 | lodash.flatMapDeep = collection.flatMapDeep;
|
---|
132 | lodash.flatMapDepth = collection.flatMapDepth;
|
---|
133 | lodash.flatten = array.flatten;
|
---|
134 | lodash.flattenDeep = array.flattenDeep;
|
---|
135 | lodash.flattenDepth = array.flattenDepth;
|
---|
136 | lodash.flip = func.flip;
|
---|
137 | lodash.flow = util.flow;
|
---|
138 | lodash.flowRight = util.flowRight;
|
---|
139 | lodash.fromPairs = array.fromPairs;
|
---|
140 | lodash.functions = object.functions;
|
---|
141 | lodash.functionsIn = object.functionsIn;
|
---|
142 | lodash.groupBy = collection.groupBy;
|
---|
143 | lodash.initial = array.initial;
|
---|
144 | lodash.intersection = array.intersection;
|
---|
145 | lodash.intersectionBy = array.intersectionBy;
|
---|
146 | lodash.intersectionWith = array.intersectionWith;
|
---|
147 | lodash.invert = object.invert;
|
---|
148 | lodash.invertBy = object.invertBy;
|
---|
149 | lodash.invokeMap = collection.invokeMap;
|
---|
150 | lodash.iteratee = util.iteratee;
|
---|
151 | lodash.keyBy = collection.keyBy;
|
---|
152 | lodash.keys = keys;
|
---|
153 | lodash.keysIn = object.keysIn;
|
---|
154 | lodash.map = collection.map;
|
---|
155 | lodash.mapKeys = object.mapKeys;
|
---|
156 | lodash.mapValues = object.mapValues;
|
---|
157 | lodash.matches = util.matches;
|
---|
158 | lodash.matchesProperty = util.matchesProperty;
|
---|
159 | lodash.memoize = func.memoize;
|
---|
160 | lodash.merge = object.merge;
|
---|
161 | lodash.mergeWith = object.mergeWith;
|
---|
162 | lodash.method = util.method;
|
---|
163 | lodash.methodOf = util.methodOf;
|
---|
164 | lodash.mixin = mixin;
|
---|
165 | lodash.negate = negate;
|
---|
166 | lodash.nthArg = util.nthArg;
|
---|
167 | lodash.omit = object.omit;
|
---|
168 | lodash.omitBy = object.omitBy;
|
---|
169 | lodash.once = func.once;
|
---|
170 | lodash.orderBy = collection.orderBy;
|
---|
171 | lodash.over = util.over;
|
---|
172 | lodash.overArgs = func.overArgs;
|
---|
173 | lodash.overEvery = util.overEvery;
|
---|
174 | lodash.overSome = util.overSome;
|
---|
175 | lodash.partial = func.partial;
|
---|
176 | lodash.partialRight = func.partialRight;
|
---|
177 | lodash.partition = collection.partition;
|
---|
178 | lodash.pick = object.pick;
|
---|
179 | lodash.pickBy = object.pickBy;
|
---|
180 | lodash.property = util.property;
|
---|
181 | lodash.propertyOf = util.propertyOf;
|
---|
182 | lodash.pull = array.pull;
|
---|
183 | lodash.pullAll = array.pullAll;
|
---|
184 | lodash.pullAllBy = array.pullAllBy;
|
---|
185 | lodash.pullAllWith = array.pullAllWith;
|
---|
186 | lodash.pullAt = array.pullAt;
|
---|
187 | lodash.range = util.range;
|
---|
188 | lodash.rangeRight = util.rangeRight;
|
---|
189 | lodash.rearg = func.rearg;
|
---|
190 | lodash.reject = collection.reject;
|
---|
191 | lodash.remove = array.remove;
|
---|
192 | lodash.rest = func.rest;
|
---|
193 | lodash.reverse = array.reverse;
|
---|
194 | lodash.sampleSize = collection.sampleSize;
|
---|
195 | lodash.set = object.set;
|
---|
196 | lodash.setWith = object.setWith;
|
---|
197 | lodash.shuffle = collection.shuffle;
|
---|
198 | lodash.slice = array.slice;
|
---|
199 | lodash.sortBy = collection.sortBy;
|
---|
200 | lodash.sortedUniq = array.sortedUniq;
|
---|
201 | lodash.sortedUniqBy = array.sortedUniqBy;
|
---|
202 | lodash.split = string.split;
|
---|
203 | lodash.spread = func.spread;
|
---|
204 | lodash.tail = array.tail;
|
---|
205 | lodash.take = array.take;
|
---|
206 | lodash.takeRight = array.takeRight;
|
---|
207 | lodash.takeRightWhile = array.takeRightWhile;
|
---|
208 | lodash.takeWhile = array.takeWhile;
|
---|
209 | lodash.tap = seq.tap;
|
---|
210 | lodash.throttle = func.throttle;
|
---|
211 | lodash.thru = thru;
|
---|
212 | lodash.toArray = lang.toArray;
|
---|
213 | lodash.toPairs = object.toPairs;
|
---|
214 | lodash.toPairsIn = object.toPairsIn;
|
---|
215 | lodash.toPath = util.toPath;
|
---|
216 | lodash.toPlainObject = lang.toPlainObject;
|
---|
217 | lodash.transform = object.transform;
|
---|
218 | lodash.unary = func.unary;
|
---|
219 | lodash.union = array.union;
|
---|
220 | lodash.unionBy = array.unionBy;
|
---|
221 | lodash.unionWith = array.unionWith;
|
---|
222 | lodash.uniq = array.uniq;
|
---|
223 | lodash.uniqBy = array.uniqBy;
|
---|
224 | lodash.uniqWith = array.uniqWith;
|
---|
225 | lodash.unset = object.unset;
|
---|
226 | lodash.unzip = array.unzip;
|
---|
227 | lodash.unzipWith = array.unzipWith;
|
---|
228 | lodash.update = object.update;
|
---|
229 | lodash.updateWith = object.updateWith;
|
---|
230 | lodash.values = object.values;
|
---|
231 | lodash.valuesIn = object.valuesIn;
|
---|
232 | lodash.without = array.without;
|
---|
233 | lodash.words = string.words;
|
---|
234 | lodash.wrap = func.wrap;
|
---|
235 | lodash.xor = array.xor;
|
---|
236 | lodash.xorBy = array.xorBy;
|
---|
237 | lodash.xorWith = array.xorWith;
|
---|
238 | lodash.zip = array.zip;
|
---|
239 | lodash.zipObject = array.zipObject;
|
---|
240 | lodash.zipObjectDeep = array.zipObjectDeep;
|
---|
241 | lodash.zipWith = array.zipWith;
|
---|
242 |
|
---|
243 | // Add aliases.
|
---|
244 | lodash.entries = object.toPairs;
|
---|
245 | lodash.entriesIn = object.toPairsIn;
|
---|
246 | lodash.extend = object.assignIn;
|
---|
247 | lodash.extendWith = object.assignInWith;
|
---|
248 |
|
---|
249 | // Add methods to `lodash.prototype`.
|
---|
250 | mixin(lodash, lodash);
|
---|
251 |
|
---|
252 | // Add methods that return unwrapped values in chain sequences.
|
---|
253 | lodash.add = math.add;
|
---|
254 | lodash.attempt = util.attempt;
|
---|
255 | lodash.camelCase = string.camelCase;
|
---|
256 | lodash.capitalize = string.capitalize;
|
---|
257 | lodash.ceil = math.ceil;
|
---|
258 | lodash.clamp = number.clamp;
|
---|
259 | lodash.clone = lang.clone;
|
---|
260 | lodash.cloneDeep = lang.cloneDeep;
|
---|
261 | lodash.cloneDeepWith = lang.cloneDeepWith;
|
---|
262 | lodash.cloneWith = lang.cloneWith;
|
---|
263 | lodash.conformsTo = lang.conformsTo;
|
---|
264 | lodash.deburr = string.deburr;
|
---|
265 | lodash.defaultTo = util.defaultTo;
|
---|
266 | lodash.divide = math.divide;
|
---|
267 | lodash.endsWith = string.endsWith;
|
---|
268 | lodash.eq = lang.eq;
|
---|
269 | lodash.escape = string.escape;
|
---|
270 | lodash.escapeRegExp = string.escapeRegExp;
|
---|
271 | lodash.every = collection.every;
|
---|
272 | lodash.find = collection.find;
|
---|
273 | lodash.findIndex = array.findIndex;
|
---|
274 | lodash.findKey = object.findKey;
|
---|
275 | lodash.findLast = collection.findLast;
|
---|
276 | lodash.findLastIndex = array.findLastIndex;
|
---|
277 | lodash.findLastKey = object.findLastKey;
|
---|
278 | lodash.floor = math.floor;
|
---|
279 | lodash.forEach = collection.forEach;
|
---|
280 | lodash.forEachRight = collection.forEachRight;
|
---|
281 | lodash.forIn = object.forIn;
|
---|
282 | lodash.forInRight = object.forInRight;
|
---|
283 | lodash.forOwn = object.forOwn;
|
---|
284 | lodash.forOwnRight = object.forOwnRight;
|
---|
285 | lodash.get = object.get;
|
---|
286 | lodash.gt = lang.gt;
|
---|
287 | lodash.gte = lang.gte;
|
---|
288 | lodash.has = object.has;
|
---|
289 | lodash.hasIn = object.hasIn;
|
---|
290 | lodash.head = array.head;
|
---|
291 | lodash.identity = identity;
|
---|
292 | lodash.includes = collection.includes;
|
---|
293 | lodash.indexOf = array.indexOf;
|
---|
294 | lodash.inRange = number.inRange;
|
---|
295 | lodash.invoke = object.invoke;
|
---|
296 | lodash.isArguments = lang.isArguments;
|
---|
297 | lodash.isArray = isArray;
|
---|
298 | lodash.isArrayBuffer = lang.isArrayBuffer;
|
---|
299 | lodash.isArrayLike = lang.isArrayLike;
|
---|
300 | lodash.isArrayLikeObject = lang.isArrayLikeObject;
|
---|
301 | lodash.isBoolean = lang.isBoolean;
|
---|
302 | lodash.isBuffer = lang.isBuffer;
|
---|
303 | lodash.isDate = lang.isDate;
|
---|
304 | lodash.isElement = lang.isElement;
|
---|
305 | lodash.isEmpty = lang.isEmpty;
|
---|
306 | lodash.isEqual = lang.isEqual;
|
---|
307 | lodash.isEqualWith = lang.isEqualWith;
|
---|
308 | lodash.isError = lang.isError;
|
---|
309 | lodash.isFinite = lang.isFinite;
|
---|
310 | lodash.isFunction = lang.isFunction;
|
---|
311 | lodash.isInteger = lang.isInteger;
|
---|
312 | lodash.isLength = lang.isLength;
|
---|
313 | lodash.isMap = lang.isMap;
|
---|
314 | lodash.isMatch = lang.isMatch;
|
---|
315 | lodash.isMatchWith = lang.isMatchWith;
|
---|
316 | lodash.isNaN = lang.isNaN;
|
---|
317 | lodash.isNative = lang.isNative;
|
---|
318 | lodash.isNil = lang.isNil;
|
---|
319 | lodash.isNull = lang.isNull;
|
---|
320 | lodash.isNumber = lang.isNumber;
|
---|
321 | lodash.isObject = isObject;
|
---|
322 | lodash.isObjectLike = lang.isObjectLike;
|
---|
323 | lodash.isPlainObject = lang.isPlainObject;
|
---|
324 | lodash.isRegExp = lang.isRegExp;
|
---|
325 | lodash.isSafeInteger = lang.isSafeInteger;
|
---|
326 | lodash.isSet = lang.isSet;
|
---|
327 | lodash.isString = lang.isString;
|
---|
328 | lodash.isSymbol = lang.isSymbol;
|
---|
329 | lodash.isTypedArray = lang.isTypedArray;
|
---|
330 | lodash.isUndefined = lang.isUndefined;
|
---|
331 | lodash.isWeakMap = lang.isWeakMap;
|
---|
332 | lodash.isWeakSet = lang.isWeakSet;
|
---|
333 | lodash.join = array.join;
|
---|
334 | lodash.kebabCase = string.kebabCase;
|
---|
335 | lodash.last = last;
|
---|
336 | lodash.lastIndexOf = array.lastIndexOf;
|
---|
337 | lodash.lowerCase = string.lowerCase;
|
---|
338 | lodash.lowerFirst = string.lowerFirst;
|
---|
339 | lodash.lt = lang.lt;
|
---|
340 | lodash.lte = lang.lte;
|
---|
341 | lodash.max = math.max;
|
---|
342 | lodash.maxBy = math.maxBy;
|
---|
343 | lodash.mean = math.mean;
|
---|
344 | lodash.meanBy = math.meanBy;
|
---|
345 | lodash.min = math.min;
|
---|
346 | lodash.minBy = math.minBy;
|
---|
347 | lodash.stubArray = util.stubArray;
|
---|
348 | lodash.stubFalse = util.stubFalse;
|
---|
349 | lodash.stubObject = util.stubObject;
|
---|
350 | lodash.stubString = util.stubString;
|
---|
351 | lodash.stubTrue = util.stubTrue;
|
---|
352 | lodash.multiply = math.multiply;
|
---|
353 | lodash.nth = array.nth;
|
---|
354 | lodash.noop = util.noop;
|
---|
355 | lodash.now = date.now;
|
---|
356 | lodash.pad = string.pad;
|
---|
357 | lodash.padEnd = string.padEnd;
|
---|
358 | lodash.padStart = string.padStart;
|
---|
359 | lodash.parseInt = string.parseInt;
|
---|
360 | lodash.random = number.random;
|
---|
361 | lodash.reduce = collection.reduce;
|
---|
362 | lodash.reduceRight = collection.reduceRight;
|
---|
363 | lodash.repeat = string.repeat;
|
---|
364 | lodash.replace = string.replace;
|
---|
365 | lodash.result = object.result;
|
---|
366 | lodash.round = math.round;
|
---|
367 | lodash.sample = collection.sample;
|
---|
368 | lodash.size = collection.size;
|
---|
369 | lodash.snakeCase = string.snakeCase;
|
---|
370 | lodash.some = collection.some;
|
---|
371 | lodash.sortedIndex = array.sortedIndex;
|
---|
372 | lodash.sortedIndexBy = array.sortedIndexBy;
|
---|
373 | lodash.sortedIndexOf = array.sortedIndexOf;
|
---|
374 | lodash.sortedLastIndex = array.sortedLastIndex;
|
---|
375 | lodash.sortedLastIndexBy = array.sortedLastIndexBy;
|
---|
376 | lodash.sortedLastIndexOf = array.sortedLastIndexOf;
|
---|
377 | lodash.startCase = string.startCase;
|
---|
378 | lodash.startsWith = string.startsWith;
|
---|
379 | lodash.subtract = math.subtract;
|
---|
380 | lodash.sum = math.sum;
|
---|
381 | lodash.sumBy = math.sumBy;
|
---|
382 | lodash.template = string.template;
|
---|
383 | lodash.times = util.times;
|
---|
384 | lodash.toFinite = lang.toFinite;
|
---|
385 | lodash.toInteger = toInteger;
|
---|
386 | lodash.toLength = lang.toLength;
|
---|
387 | lodash.toLower = string.toLower;
|
---|
388 | lodash.toNumber = lang.toNumber;
|
---|
389 | lodash.toSafeInteger = lang.toSafeInteger;
|
---|
390 | lodash.toString = lang.toString;
|
---|
391 | lodash.toUpper = string.toUpper;
|
---|
392 | lodash.trim = string.trim;
|
---|
393 | lodash.trimEnd = string.trimEnd;
|
---|
394 | lodash.trimStart = string.trimStart;
|
---|
395 | lodash.truncate = string.truncate;
|
---|
396 | lodash.unescape = string.unescape;
|
---|
397 | lodash.uniqueId = util.uniqueId;
|
---|
398 | lodash.upperCase = string.upperCase;
|
---|
399 | lodash.upperFirst = string.upperFirst;
|
---|
400 |
|
---|
401 | // Add aliases.
|
---|
402 | lodash.each = collection.forEach;
|
---|
403 | lodash.eachRight = collection.forEachRight;
|
---|
404 | lodash.first = array.head;
|
---|
405 |
|
---|
406 | mixin(lodash, (function() {
|
---|
407 | var source = {};
|
---|
408 | baseForOwn(lodash, function(func, methodName) {
|
---|
409 | if (!hasOwnProperty.call(lodash.prototype, methodName)) {
|
---|
410 | source[methodName] = func;
|
---|
411 | }
|
---|
412 | });
|
---|
413 | return source;
|
---|
414 | }()), { 'chain': false });
|
---|
415 |
|
---|
416 | /**
|
---|
417 | * The semantic version number.
|
---|
418 | *
|
---|
419 | * @static
|
---|
420 | * @memberOf _
|
---|
421 | * @type {string}
|
---|
422 | */
|
---|
423 | lodash.VERSION = VERSION;
|
---|
424 | (lodash.templateSettings = string.templateSettings).imports._ = lodash;
|
---|
425 |
|
---|
426 | // Assign default placeholders.
|
---|
427 | arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
|
---|
428 | lodash[methodName].placeholder = lodash;
|
---|
429 | });
|
---|
430 |
|
---|
431 | // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
|
---|
432 | arrayEach(['drop', 'take'], function(methodName, index) {
|
---|
433 | LazyWrapper.prototype[methodName] = function(n) {
|
---|
434 | n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
|
---|
435 |
|
---|
436 | var result = (this.__filtered__ && !index)
|
---|
437 | ? new LazyWrapper(this)
|
---|
438 | : this.clone();
|
---|
439 |
|
---|
440 | if (result.__filtered__) {
|
---|
441 | result.__takeCount__ = nativeMin(n, result.__takeCount__);
|
---|
442 | } else {
|
---|
443 | result.__views__.push({
|
---|
444 | 'size': nativeMin(n, MAX_ARRAY_LENGTH),
|
---|
445 | 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
|
---|
446 | });
|
---|
447 | }
|
---|
448 | return result;
|
---|
449 | };
|
---|
450 |
|
---|
451 | LazyWrapper.prototype[methodName + 'Right'] = function(n) {
|
---|
452 | return this.reverse()[methodName](n).reverse();
|
---|
453 | };
|
---|
454 | });
|
---|
455 |
|
---|
456 | // Add `LazyWrapper` methods that accept an `iteratee` value.
|
---|
457 | arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
|
---|
458 | var type = index + 1,
|
---|
459 | isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
|
---|
460 |
|
---|
461 | LazyWrapper.prototype[methodName] = function(iteratee) {
|
---|
462 | var result = this.clone();
|
---|
463 | result.__iteratees__.push({
|
---|
464 | 'iteratee': baseIteratee(iteratee, 3),
|
---|
465 | 'type': type
|
---|
466 | });
|
---|
467 | result.__filtered__ = result.__filtered__ || isFilter;
|
---|
468 | return result;
|
---|
469 | };
|
---|
470 | });
|
---|
471 |
|
---|
472 | // Add `LazyWrapper` methods for `_.head` and `_.last`.
|
---|
473 | arrayEach(['head', 'last'], function(methodName, index) {
|
---|
474 | var takeName = 'take' + (index ? 'Right' : '');
|
---|
475 |
|
---|
476 | LazyWrapper.prototype[methodName] = function() {
|
---|
477 | return this[takeName](1).value()[0];
|
---|
478 | };
|
---|
479 | });
|
---|
480 |
|
---|
481 | // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
|
---|
482 | arrayEach(['initial', 'tail'], function(methodName, index) {
|
---|
483 | var dropName = 'drop' + (index ? '' : 'Right');
|
---|
484 |
|
---|
485 | LazyWrapper.prototype[methodName] = function() {
|
---|
486 | return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
|
---|
487 | };
|
---|
488 | });
|
---|
489 |
|
---|
490 | LazyWrapper.prototype.compact = function() {
|
---|
491 | return this.filter(identity);
|
---|
492 | };
|
---|
493 |
|
---|
494 | LazyWrapper.prototype.find = function(predicate) {
|
---|
495 | return this.filter(predicate).head();
|
---|
496 | };
|
---|
497 |
|
---|
498 | LazyWrapper.prototype.findLast = function(predicate) {
|
---|
499 | return this.reverse().find(predicate);
|
---|
500 | };
|
---|
501 |
|
---|
502 | LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
|
---|
503 | if (typeof path == 'function') {
|
---|
504 | return new LazyWrapper(this);
|
---|
505 | }
|
---|
506 | return this.map(function(value) {
|
---|
507 | return baseInvoke(value, path, args);
|
---|
508 | });
|
---|
509 | });
|
---|
510 |
|
---|
511 | LazyWrapper.prototype.reject = function(predicate) {
|
---|
512 | return this.filter(negate(baseIteratee(predicate)));
|
---|
513 | };
|
---|
514 |
|
---|
515 | LazyWrapper.prototype.slice = function(start, end) {
|
---|
516 | start = toInteger(start);
|
---|
517 |
|
---|
518 | var result = this;
|
---|
519 | if (result.__filtered__ && (start > 0 || end < 0)) {
|
---|
520 | return new LazyWrapper(result);
|
---|
521 | }
|
---|
522 | if (start < 0) {
|
---|
523 | result = result.takeRight(-start);
|
---|
524 | } else if (start) {
|
---|
525 | result = result.drop(start);
|
---|
526 | }
|
---|
527 | if (end !== undefined) {
|
---|
528 | end = toInteger(end);
|
---|
529 | result = end < 0 ? result.dropRight(-end) : result.take(end - start);
|
---|
530 | }
|
---|
531 | return result;
|
---|
532 | };
|
---|
533 |
|
---|
534 | LazyWrapper.prototype.takeRightWhile = function(predicate) {
|
---|
535 | return this.reverse().takeWhile(predicate).reverse();
|
---|
536 | };
|
---|
537 |
|
---|
538 | LazyWrapper.prototype.toArray = function() {
|
---|
539 | return this.take(MAX_ARRAY_LENGTH);
|
---|
540 | };
|
---|
541 |
|
---|
542 | // Add `LazyWrapper` methods to `lodash.prototype`.
|
---|
543 | baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
---|
544 | var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
|
---|
545 | isTaker = /^(?:head|last)$/.test(methodName),
|
---|
546 | lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
|
---|
547 | retUnwrapped = isTaker || /^find/.test(methodName);
|
---|
548 |
|
---|
549 | if (!lodashFunc) {
|
---|
550 | return;
|
---|
551 | }
|
---|
552 | lodash.prototype[methodName] = function() {
|
---|
553 | var value = this.__wrapped__,
|
---|
554 | args = isTaker ? [1] : arguments,
|
---|
555 | isLazy = value instanceof LazyWrapper,
|
---|
556 | iteratee = args[0],
|
---|
557 | useLazy = isLazy || isArray(value);
|
---|
558 |
|
---|
559 | var interceptor = function(value) {
|
---|
560 | var result = lodashFunc.apply(lodash, arrayPush([value], args));
|
---|
561 | return (isTaker && chainAll) ? result[0] : result;
|
---|
562 | };
|
---|
563 |
|
---|
564 | if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
|
---|
565 | // Avoid lazy use if the iteratee has a "length" value other than `1`.
|
---|
566 | isLazy = useLazy = false;
|
---|
567 | }
|
---|
568 | var chainAll = this.__chain__,
|
---|
569 | isHybrid = !!this.__actions__.length,
|
---|
570 | isUnwrapped = retUnwrapped && !chainAll,
|
---|
571 | onlyLazy = isLazy && !isHybrid;
|
---|
572 |
|
---|
573 | if (!retUnwrapped && useLazy) {
|
---|
574 | value = onlyLazy ? value : new LazyWrapper(this);
|
---|
575 | var result = func.apply(value, args);
|
---|
576 | result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
|
---|
577 | return new LodashWrapper(result, chainAll);
|
---|
578 | }
|
---|
579 | if (isUnwrapped && onlyLazy) {
|
---|
580 | return func.apply(this, args);
|
---|
581 | }
|
---|
582 | result = this.thru(interceptor);
|
---|
583 | return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
|
---|
584 | };
|
---|
585 | });
|
---|
586 |
|
---|
587 | // Add `Array` methods to `lodash.prototype`.
|
---|
588 | arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
|
---|
589 | var func = arrayProto[methodName],
|
---|
590 | chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
|
---|
591 | retUnwrapped = /^(?:pop|shift)$/.test(methodName);
|
---|
592 |
|
---|
593 | lodash.prototype[methodName] = function() {
|
---|
594 | var args = arguments;
|
---|
595 | if (retUnwrapped && !this.__chain__) {
|
---|
596 | var value = this.value();
|
---|
597 | return func.apply(isArray(value) ? value : [], args);
|
---|
598 | }
|
---|
599 | return this[chainName](function(value) {
|
---|
600 | return func.apply(isArray(value) ? value : [], args);
|
---|
601 | });
|
---|
602 | };
|
---|
603 | });
|
---|
604 |
|
---|
605 | // Map minified method names to their real names.
|
---|
606 | baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
---|
607 | var lodashFunc = lodash[methodName];
|
---|
608 | if (lodashFunc) {
|
---|
609 | var key = lodashFunc.name + '';
|
---|
610 | if (!hasOwnProperty.call(realNames, key)) {
|
---|
611 | realNames[key] = [];
|
---|
612 | }
|
---|
613 | realNames[key].push({ 'name': methodName, 'func': lodashFunc });
|
---|
614 | }
|
---|
615 | });
|
---|
616 |
|
---|
617 | realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
|
---|
618 | 'name': 'wrapper',
|
---|
619 | 'func': undefined
|
---|
620 | }];
|
---|
621 |
|
---|
622 | // Add methods to `LazyWrapper`.
|
---|
623 | LazyWrapper.prototype.clone = lazyClone;
|
---|
624 | LazyWrapper.prototype.reverse = lazyReverse;
|
---|
625 | LazyWrapper.prototype.value = lazyValue;
|
---|
626 |
|
---|
627 | // Add chain sequence methods to the `lodash` wrapper.
|
---|
628 | lodash.prototype.at = seq.at;
|
---|
629 | lodash.prototype.chain = seq.wrapperChain;
|
---|
630 | lodash.prototype.commit = seq.commit;
|
---|
631 | lodash.prototype.next = seq.next;
|
---|
632 | lodash.prototype.plant = seq.plant;
|
---|
633 | lodash.prototype.reverse = seq.reverse;
|
---|
634 | lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = seq.value;
|
---|
635 |
|
---|
636 | // Add lazy aliases.
|
---|
637 | lodash.prototype.first = lodash.prototype.head;
|
---|
638 |
|
---|
639 | if (symIterator) {
|
---|
640 | lodash.prototype[symIterator] = seq.toIterator;
|
---|
641 | }
|
---|
642 |
|
---|
643 | export default lodash;
|
---|