react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / chain / lodash.js
80742 viewsvar LazyWrapper = require('../internal/LazyWrapper'),1LodashWrapper = require('../internal/LodashWrapper'),2baseLodash = require('../internal/baseLodash'),3isArray = require('../lang/isArray'),4isObjectLike = require('../internal/isObjectLike'),5wrapperClone = require('../internal/wrapperClone');67/** Used for native method references. */8var objectProto = Object.prototype;910/** Used to check objects for own properties. */11var hasOwnProperty = objectProto.hasOwnProperty;1213/**14* Creates a `lodash` object which wraps `value` to enable implicit chaining.15* Methods that operate on and return arrays, collections, and functions can16* be chained together. Methods that return a boolean or single value will17* automatically end the chain returning the unwrapped value. Explicit chaining18* may be enabled using `_.chain`. The execution of chained methods is lazy,19* that is, execution is deferred until `_#value` is implicitly or explicitly20* called.21*22* Lazy evaluation allows several methods to support shortcut fusion. Shortcut23* fusion is an optimization that merges iteratees to avoid creating intermediate24* arrays and reduce the number of iteratee executions.25*26* Chaining is supported in custom builds as long as the `_#value` method is27* directly or indirectly included in the build.28*29* In addition to lodash methods, wrappers have `Array` and `String` methods.30*31* The wrapper `Array` methods are:32* `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,33* `splice`, and `unshift`34*35* The wrapper `String` methods are:36* `replace` and `split`37*38* The wrapper methods that support shortcut fusion are:39* `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,40* `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`,41* `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`,42* and `where`43*44* The chainable wrapper methods are:45* `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,46* `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,47* `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`,48* `difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`,49* `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,50* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,51* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,52* `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,53* `memoize`, `merge`, `method`, `methodOf`, `mixin`, `negate`, `omit`, `once`,54* `pairs`, `partial`, `partialRight`, `partition`, `pick`, `plant`, `pluck`,55* `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, `rearg`,56* `reject`, `remove`, `rest`, `restParam`, `reverse`, `set`, `shuffle`,57* `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, `spread`,58* `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,59* `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`,60* `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, `where`, `without`,61* `wrap`, `xor`, `zip`, `zipObject`, `zipWith`62*63* The wrapper methods that are **not** chainable by default are:64* `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,65* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,66* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `get`,67* `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`,68* `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`,69* `isFinite` `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,70* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,71* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lt`, `lte`,72* `max`, `min`, `noConflict`, `noop`, `now`, `pad`, `padLeft`, `padRight`,73* `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`,74* `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,75* `sortedLastIndex`, `startCase`, `startsWith`, `sum`, `template`, `trim`,76* `trimLeft`, `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words`77*78* The wrapper method `sample` will return a wrapped value when `n` is provided,79* otherwise an unwrapped value is returned.80*81* @name _82* @constructor83* @category Chain84* @param {*} value The value to wrap in a `lodash` instance.85* @returns {Object} Returns the new `lodash` wrapper instance.86* @example87*88* var wrapped = _([1, 2, 3]);89*90* // returns an unwrapped value91* wrapped.reduce(function(total, n) {92* return total + n;93* });94* // => 695*96* // returns a wrapped value97* var squares = wrapped.map(function(n) {98* return n * n;99* });100*101* _.isArray(squares);102* // => false103*104* _.isArray(squares.value());105* // => true106*/107function lodash(value) {108if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {109if (value instanceof LodashWrapper) {110return value;111}112if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {113return wrapperClone(value);114}115}116return new LodashWrapper(value);117}118119// Ensure wrappers are instances of `baseLodash`.120lodash.prototype = baseLodash.prototype;121122module.exports = lodash;123124125