...**/!(*.map|*.min.js)Size
Gzip
Dependencies
Publish
Install
Publish
Install
@@ -1,62 +1,20 @@ | |||
| 1 | { | 1 | { |
| 2 | "name": "lodash", | 2 | "name": "lodash", |
| 3 | "version": "2.4.2", | ||
| 4 | "description": "A utility library delivering consistency, customization, performance, & extras.", | ||
| 5 | "homepage": "http://lodash.com/", | 3 | "version": "3.0.0", |
| 4 | "description": "The modern build of lodash modular utilities.", | ||
| 5 | "homepage": "https://lodash.com/", | ||
| 6 | "icon": "https://lodash.com/icon.svg", | ||
| 6 | "license": "MIT", | 7 | "license": "MIT", |
| 7 | "main": "dist/lodash.js", | ||
| 8 | "keywords": ["amd", "browser", "client", "customize", "functional", "server", "util"], | 8 | "main": "index.js", |
| 9 | "keywords": "modules, stdlib, util", | ||
| 9 | "author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | 10 | "author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", |
| 10 | "contributors": [ | 11 | "contributors": [ |
| 11 | "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", | 12 | "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)", |
| 13 | "Benjamin Tan <demoneaux@gmail.com> (https://d10.github.io/)", | ||
| 12 | "Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)", | 14 | "Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)", |
| 13 | "Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)", | 15 | "Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)", |
| 14 | "Mathias Bynens <mathias@qiwi.be> (http://mathiasbynens.be/)" | 16 | "Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)" |
| 15 | ], | 17 | ], |
| 16 | "bugs": "https://github.com/lodash/lodash/issues", | ||
| 17 | "repository": { "type": "git", "url": "https://github.com/lodash/lodash.git" }, | ||
| 18 | "engines": ["node", "rhino"], | ||
| 19 | "files": [ | ||
| 20 | "LICENSE.txt", | ||
| 21 | "lodash.js", | ||
| 22 | "dist/lodash.js", | ||
| 23 | "dist/lodash.min.js", | ||
| 24 | "dist/lodash.compat.js", | ||
| 25 | "dist/lodash.compat.min.js", | ||
| 26 | "dist/lodash.underscore.js", | ||
| 27 | "dist/lodash.underscore.min.js" | ||
| 28 | ], | ||
| 29 | "jam": { | ||
| 30 | "main": "dist/lodash.compat.js", | ||
| 31 | "include": [ | ||
| 32 | "LICENSE.txt", | ||
| 33 | "dist/lodash.js", | ||
| 34 | "dist/lodash.min.js", | ||
| 35 | "dist/lodash.compat.js", | ||
| 36 | "dist/lodash.compat.min.js", | ||
| 37 | "dist/lodash.underscore.js", | ||
| 38 | "dist/lodash.underscore.min.js" | ||
| 39 | ] | ||
| 40 | }, | ||
| 41 | "volo": { | ||
| 42 | "type": "directory", | ||
| 43 | "ignore": [ | ||
| 44 | ".*", | ||
| 45 | "*.custom.*", | ||
| 46 | "*.min.*", | ||
| 47 | "*.template.*", | ||
| 48 | "*.map", | ||
| 49 | "*.md", | ||
| 50 | "lodash.js", | ||
| 51 | "index.js", | ||
| 52 | "bower.json", | ||
| 53 | "component.json", | ||
| 54 | "doc", | ||
| 55 | "modularize", | ||
| 56 | "node_modules", | ||
| 57 | "perf", | ||
| 58 | "test", | ||
| 59 | "vendor" | ||
| 60 | ] | ||
| 61 | } | 18 | "repository": "lodash/lodash", |
| 19 | "scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" } | ||
| 62 | } | 20 | } |
@@ -1,5 +1,5 @@ | |||
| 1 | Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/> | ||
| 2 | Based on Underscore.js 1.5.2, copyright 2009-2013 Jeremy Ashkenas, | 1 | Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> |
| 2 | Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, | ||
| 3 | DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> | 3 | DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> |
| 4 | 4 | ||
| 5 | Permission is hereby granted, free of charge, to any person obtaining | 5 | Permission is hereby granted, free of charge, to any person obtaining |
@@ -19,4 +19,4 @@ | |||
| 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@@ -0,0 +1,42 @@ | |
| 1 | module.exports = { |
| 2 | 'all': require('./collection/all'), |
| 3 | 'any': require('./collection/any'), |
| 4 | 'at': require('./collection/at'), |
| 5 | 'collect': require('./collection/collect'), |
| 6 | 'contains': require('./collection/contains'), |
| 7 | 'countBy': require('./collection/countBy'), |
| 8 | 'detect': require('./collection/detect'), |
| 9 | 'each': require('./collection/each'), |
| 10 | 'eachRight': require('./collection/eachRight'), |
| 11 | 'every': require('./collection/every'), |
| 12 | 'filter': require('./collection/filter'), |
| 13 | 'find': require('./collection/find'), |
| 14 | 'findLast': require('./collection/findLast'), |
| 15 | 'findWhere': require('./collection/findWhere'), |
| 16 | 'foldl': require('./collection/foldl'), |
| 17 | 'foldr': require('./collection/foldr'), |
| 18 | 'forEach': require('./collection/forEach'), |
| 19 | 'forEachRight': require('./collection/forEachRight'), |
| 20 | 'groupBy': require('./collection/groupBy'), |
| 21 | 'include': require('./collection/include'), |
| 22 | 'includes': require('./collection/includes'), |
| 23 | 'indexBy': require('./collection/indexBy'), |
| 24 | 'inject': require('./collection/inject'), |
| 25 | 'invoke': require('./collection/invoke'), |
| 26 | 'map': require('./collection/map'), |
| 27 | 'max': require('./collection/max'), |
| 28 | 'min': require('./collection/min'), |
| 29 | 'partition': require('./collection/partition'), |
| 30 | 'pluck': require('./collection/pluck'), |
| 31 | 'reduce': require('./collection/reduce'), |
| 32 | 'reduceRight': require('./collection/reduceRight'), |
| 33 | 'reject': require('./collection/reject'), |
| 34 | 'sample': require('./collection/sample'), |
| 35 | 'select': require('./collection/select'), |
| 36 | 'shuffle': require('./collection/shuffle'), |
| 37 | 'size': require('./collection/size'), |
| 38 | 'some': require('./collection/some'), |
| 39 | 'sortBy': require('./collection/sortBy'), |
| 40 | 'sortByAll': require('./collection/sortByAll'), |
| 41 | 'where': require('./collection/where') |
| 42 | }; |
@@ -0,0 +1,25 @@ | |
| 1 | module.exports = { |
| 2 | 'after': require('./function/after'), |
| 3 | 'ary': require('./function/ary'), |
| 4 | 'backflow': require('./function/backflow'), |
| 5 | 'before': require('./function/before'), |
| 6 | 'bind': require('./function/bind'), |
| 7 | 'bindAll': require('./function/bindAll'), |
| 8 | 'bindKey': require('./function/bindKey'), |
| 9 | 'compose': require('./function/compose'), |
| 10 | 'curry': require('./function/curry'), |
| 11 | 'curryRight': require('./function/curryRight'), |
| 12 | 'debounce': require('./function/debounce'), |
| 13 | 'defer': require('./function/defer'), |
| 14 | 'delay': require('./function/delay'), |
| 15 | 'flow': require('./function/flow'), |
| 16 | 'flowRight': require('./function/flowRight'), |
| 17 | 'memoize': require('./function/memoize'), |
| 18 | 'negate': require('./function/negate'), |
| 19 | 'once': require('./function/once'), |
| 20 | 'partial': require('./function/partial'), |
| 21 | 'partialRight': require('./function/partialRight'), |
| 22 | 'rearg': require('./function/rearg'), |
| 23 | 'throttle': require('./function/throttle'), |
| 24 | 'wrap': require('./function/wrap') |
| 25 | }; |
@@ -0,0 +1,12 @@ | |
| 1 | module.exports = { |
| 2 | 'chain': require('./chain/chain'), |
| 3 | 'lodash': require('./chain/lodash'), |
| 4 | 'reverse': require('./chain/reverse'), |
| 5 | 'tap': require('./chain/tap'), |
| 6 | 'thru': require('./chain/thru'), |
| 7 | 'toJSON': require('./chain/toJSON'), |
| 8 | 'toString': require('./chain/toString'), |
| 9 | 'value': require('./chain/value'), |
| 10 | 'valueOf': require('./chain/valueOf'), |
| 11 | 'wrapperChain': require('./chain/wrapperChain') |
| 12 | }; |
@@ -0,0 +1,27 @@ | |
| 1 | module.exports = { |
| 2 | 'clone': require('./lang/clone'), |
| 3 | 'cloneDeep': require('./lang/cloneDeep'), |
| 4 | 'isArguments': require('./lang/isArguments'), |
| 5 | 'isArray': require('./lang/isArray'), |
| 6 | 'isBoolean': require('./lang/isBoolean'), |
| 7 | 'isDate': require('./lang/isDate'), |
| 8 | 'isElement': require('./lang/isElement'), |
| 9 | 'isEmpty': require('./lang/isEmpty'), |
| 10 | 'isEqual': require('./lang/isEqual'), |
| 11 | 'isError': require('./lang/isError'), |
| 12 | 'isFinite': require('./lang/isFinite'), |
| 13 | 'isFunction': require('./lang/isFunction'), |
| 14 | 'isMatch': require('./lang/isMatch'), |
| 15 | 'isNaN': require('./lang/isNaN'), |
| 16 | 'isNative': require('./lang/isNative'), |
| 17 | 'isNull': require('./lang/isNull'), |
| 18 | 'isNumber': require('./lang/isNumber'), |
| 19 | 'isObject': require('./lang/isObject'), |
| 20 | 'isPlainObject': require('./lang/isPlainObject'), |
| 21 | 'isRegExp': require('./lang/isRegExp'), |
| 22 | 'isString': require('./lang/isString'), |
| 23 | 'isTypedArray': require('./lang/isTypedArray'), |
| 24 | 'isUndefined': require('./lang/isUndefined'), |
| 25 | 'toArray': require('./lang/toArray'), |
| 26 | 'toPlainObject': require('./lang/toPlainObject') |
| 27 | }; |
@@ -0,0 +1,27 @@ | |
| 1 | module.exports = { |
| 2 | 'assign': require('./object/assign'), |
| 3 | 'create': require('./object/create'), |
| 4 | 'defaults': require('./object/defaults'), |
| 5 | 'extend': require('./object/extend'), |
| 6 | 'findKey': require('./object/findKey'), |
| 7 | 'findLastKey': require('./object/findLastKey'), |
| 8 | 'forIn': require('./object/forIn'), |
| 9 | 'forInRight': require('./object/forInRight'), |
| 10 | 'forOwn': require('./object/forOwn'), |
| 11 | 'forOwnRight': require('./object/forOwnRight'), |
| 12 | 'functions': require('./object/functions'), |
| 13 | 'has': require('./object/has'), |
| 14 | 'invert': require('./object/invert'), |
| 15 | 'keys': require('./object/keys'), |
| 16 | 'keysIn': require('./object/keysIn'), |
| 17 | 'mapValues': require('./object/mapValues'), |
| 18 | 'merge': require('./object/merge'), |
| 19 | 'methods': require('./object/methods'), |
| 20 | 'omit': require('./object/omit'), |
| 21 | 'pairs': require('./object/pairs'), |
| 22 | 'pick': require('./object/pick'), |
| 23 | 'result': require('./object/result'), |
| 24 | 'transform': require('./object/transform'), |
| 25 | 'values': require('./object/values'), |
| 26 | 'valuesIn': require('./object/valuesIn') |
| 27 | }; |
@@ -0,0 +1,24 @@ | |
| 1 | module.exports = { |
| 2 | 'camelCase': require('./string/camelCase'), |
| 3 | 'capitalize': require('./string/capitalize'), |
| 4 | 'deburr': require('./string/deburr'), |
| 5 | 'endsWith': require('./string/endsWith'), |
| 6 | 'escape': require('./string/escape'), |
| 7 | 'escapeRegExp': require('./string/escapeRegExp'), |
| 8 | 'kebabCase': require('./string/kebabCase'), |
| 9 | 'pad': require('./string/pad'), |
| 10 | 'padLeft': require('./string/padLeft'), |
| 11 | 'padRight': require('./string/padRight'), |
| 12 | 'parseInt': require('./string/parseInt'), |
| 13 | 'repeat': require('./string/repeat'), |
| 14 | 'snakeCase': require('./string/snakeCase'), |
| 15 | 'startsWith': require('./string/startsWith'), |
| 16 | 'template': require('./string/template'), |
| 17 | 'templateSettings': require('./string/templateSettings'), |
| 18 | 'trim': require('./string/trim'), |
| 19 | 'trimLeft': require('./string/trimLeft'), |
| 20 | 'trimRight': require('./string/trimRight'), |
| 21 | 'trunc': require('./string/trunc'), |
| 22 | 'unescape': require('./string/unescape'), |
| 23 | 'words': require('./string/words') |
| 24 | }; |
@@ -0,0 +1,41 @@ | |
| 1 | module.exports = { |
| 2 | 'chunk': require('./array/chunk'), |
| 3 | 'compact': require('./array/compact'), |
| 4 | 'difference': require('./array/difference'), |
| 5 | 'drop': require('./array/drop'), |
| 6 | 'dropRight': require('./array/dropRight'), |
| 7 | 'dropRightWhile': require('./array/dropRightWhile'), |
| 8 | 'dropWhile': require('./array/dropWhile'), |
| 9 | 'findIndex': require('./array/findIndex'), |
| 10 | 'findLastIndex': require('./array/findLastIndex'), |
| 11 | 'first': require('./array/first'), |
| 12 | 'flatten': require('./array/flatten'), |
| 13 | 'flattenDeep': require('./array/flattenDeep'), |
| 14 | 'head': require('./array/head'), |
| 15 | 'indexOf': require('./array/indexOf'), |
| 16 | 'initial': require('./array/initial'), |
| 17 | 'intersection': require('./array/intersection'), |
| 18 | 'last': require('./array/last'), |
| 19 | 'lastIndexOf': require('./array/lastIndexOf'), |
| 20 | 'object': require('./array/object'), |
| 21 | 'pull': require('./array/pull'), |
| 22 | 'pullAt': require('./array/pullAt'), |
| 23 | 'remove': require('./array/remove'), |
| 24 | 'rest': require('./array/rest'), |
| 25 | 'slice': require('./array/slice'), |
| 26 | 'sortedIndex': require('./array/sortedIndex'), |
| 27 | 'sortedLastIndex': require('./array/sortedLastIndex'), |
| 28 | 'tail': require('./array/tail'), |
| 29 | 'take': require('./array/take'), |
| 30 | 'takeRight': require('./array/takeRight'), |
| 31 | 'takeRightWhile': require('./array/takeRightWhile'), |
| 32 | 'takeWhile': require('./array/takeWhile'), |
| 33 | 'union': require('./array/union'), |
| 34 | 'uniq': require('./array/uniq'), |
| 35 | 'unique': require('./array/unique'), |
| 36 | 'unzip': require('./array/unzip'), |
| 37 | 'without': require('./array/without'), |
| 38 | 'xor': require('./array/xor'), |
| 39 | 'zip': require('./array/zip'), |
| 40 | 'zipObject': require('./array/zipObject') |
| 41 | }; |
@@ -0,0 +1,15 @@ | |
| 1 | module.exports = { |
| 2 | 'attempt': require('./utility/attempt'), |
| 3 | 'callback': require('./utility/callback'), |
| 4 | 'constant': require('./utility/constant'), |
| 5 | 'identity': require('./utility/identity'), |
| 6 | 'iteratee': require('./utility/iteratee'), |
| 7 | 'matches': require('./utility/matches'), |
| 8 | 'mixin': require('./utility/mixin'), |
| 9 | 'noop': require('./utility/noop'), |
| 10 | 'property': require('./utility/property'), |
| 11 | 'propertyOf': require('./utility/propertyOf'), |
| 12 | 'range': require('./utility/range'), |
| 13 | 'times': require('./utility/times'), |
| 14 | 'uniqueId': require('./utility/uniqueId') |
| 15 | }; |
@@ -0,0 +1,75 @@ | |
| 1 | var isNative = require('./lang/isNative'); |
| 2 | |
| 3 | /** Used to detect functions containing a `this` reference. */ |
| 4 | var reThis = /\bthis\b/; |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** Used to detect DOM support. */ |
| 10 | var document = (document = global.window) && document.document; |
| 11 | |
| 12 | /** Native method references. */ |
| 13 | var propertyIsEnumerable = objectProto.propertyIsEnumerable; |
| 14 | |
| 15 | /** |
| 16 | * An object environment feature flags. |
| 17 | * |
| 18 | * @static |
| 19 | * @memberOf _ |
| 20 | * @type Object |
| 21 | */ |
| 22 | var support = {}; |
| 23 | |
| 24 | (function(x) { |
| 25 | |
| 26 | /** |
| 27 | * Detect if functions can be decompiled by `Function#toString` |
| 28 | * (all but Firefox OS certified apps, older Opera mobile browsers, and |
| 29 | * the PlayStation 3; forced `false` for Windows 8 apps). |
| 30 | * |
| 31 | * @memberOf _.support |
| 32 | * @type boolean |
| 33 | */ |
| 34 | support.funcDecomp = !isNative(global.WinRTError) && reThis.test(function() { return this; }); |
| 35 | |
| 36 | /** |
| 37 | * Detect if `Function#name` is supported (all but IE). |
| 38 | * |
| 39 | * @memberOf _.support |
| 40 | * @type boolean |
| 41 | */ |
| 42 | support.funcNames = typeof Function.name == 'string'; |
| 43 | |
| 44 | /** |
| 45 | * Detect if the DOM is supported. |
| 46 | * |
| 47 | * @memberOf _.support |
| 48 | * @type boolean |
| 49 | */ |
| 50 | try { |
| 51 | support.dom = document.createDocumentFragment().nodeType === 11; |
| 52 | } catch(e) { |
| 53 | support.dom = false; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Detect if `arguments` object indexes are non-enumerable. |
| 58 | * |
| 59 | * In Firefox < 4, IE < 9, PhantomJS, and Safari < 5.1 `arguments` object |
| 60 | * indexes are non-enumerable. Chrome < 25 and Node.js < 0.11.0 treat |
| 61 | * `arguments` object indexes as non-enumerable and fail `hasOwnProperty` |
| 62 | * checks for indexes that exceed their function's formal parameters with |
| 63 | * associated values of `0`. |
| 64 | * |
| 65 | * @memberOf _.support |
| 66 | * @type boolean |
| 67 | */ |
| 68 | try { |
| 69 | support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1); |
| 70 | } catch(e) { |
| 71 | support.nonEnumArgs = true; |
| 72 | } |
| 73 | }(0, 0)); |
| 74 | |
| 75 | module.exports = support; |
@@ -0,0 +1,65 @@ | |
| 1 | var baseClone = require('../internal/baseClone'), |
| 2 | bindCallback = require('../internal/bindCallback'), |
| 3 | isIterateeCall = require('../internal/isIterateeCall'); |
| 4 | |
| 5 | /** |
| 6 | * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, |
| 7 | * otherwise they are assigned by reference. If `customizer` is provided it is |
| 8 | * invoked to produce the cloned values. If `customizer` returns `undefined` |
| 9 | * cloning is handled by the method instead. The `customizer` is bound to |
| 10 | * `thisArg` and invoked with two argument; (value [, index|key, object]). |
| 11 | * |
| 12 | * **Note:** This method is loosely based on the structured clone algorithm. |
| 13 | * The enumerable properties of `arguments` objects and objects created by |
| 14 | * constructors other than `Object` are cloned to plain `Object` objects. An |
| 15 | * empty object is returned for uncloneable values such as functions, DOM nodes, |
| 16 | * Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) |
| 17 | * for more details. |
| 18 | * |
| 19 | * @static |
| 20 | * @memberOf _ |
| 21 | * @category Lang |
| 22 | * @param {*} value The value to clone. |
| 23 | * @param {boolean} [isDeep] Specify a deep clone. |
| 24 | * @param {Function} [customizer] The function to customize cloning values. |
| 25 | * @param {*} [thisArg] The `this` binding of `customizer`. |
| 26 | * @returns {*} Returns the cloned value. |
| 27 | * @example |
| 28 | * |
| 29 | * var users = [ |
| 30 | * { 'user': 'barney' }, |
| 31 | * { 'user': 'fred' } |
| 32 | * ]; |
| 33 | * |
| 34 | * var shallow = _.clone(users); |
| 35 | * shallow[0] === users[0]; |
| 36 | * // => true |
| 37 | * |
| 38 | * var deep = _.clone(users, true); |
| 39 | * deep[0] === users[0]; |
| 40 | * // => false |
| 41 | * |
| 42 | * // using a customizer callback |
| 43 | * var body = _.clone(document.body, function(value) { |
| 44 | * return _.isElement(value) ? value.cloneNode(false) : undefined; |
| 45 | * }); |
| 46 | * |
| 47 | * body === document.body |
| 48 | * // => false |
| 49 | * body.nodeName |
| 50 | * // => BODY |
| 51 | * body.childNodes.length; |
| 52 | * // => 0 |
| 53 | */ |
| 54 | function clone(value, isDeep, customizer, thisArg) { |
| 55 | // Juggle arguments. |
| 56 | if (typeof isDeep != 'boolean' && isDeep != null) { |
| 57 | thisArg = customizer; |
| 58 | customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep; |
| 59 | isDeep = false; |
| 60 | } |
| 61 | customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); |
| 62 | return baseClone(value, isDeep, customizer); |
| 63 | } |
| 64 | |
| 65 | module.exports = clone; |
@@ -0,0 +1,37 @@ | |
| 1 | var isObjectLike = require('../internal/isObjectLike'); |
| 2 | |
| 3 | /** `Object#toString` result references. */ |
| 4 | var errorTag = '[object Error]'; |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** |
| 10 | * Used to resolve the `toStringTag` of values. |
| 11 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 12 | * for more details. |
| 13 | */ |
| 14 | var objToString = objectProto.toString; |
| 15 | |
| 16 | /** |
| 17 | * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, |
| 18 | * `SyntaxError`, `TypeError`, or `URIError` object. |
| 19 | * |
| 20 | * @static |
| 21 | * @memberOf _ |
| 22 | * @category Lang |
| 23 | * @param {*} value The value to check. |
| 24 | * @returns {boolean} Returns `true` if `value` is an error object, else `false`. |
| 25 | * @example |
| 26 | * |
| 27 | * _.isError(new Error); |
| 28 | * // => true |
| 29 | * |
| 30 | * _.isError(Error); |
| 31 | * // => false |
| 32 | */ |
| 33 | function isError(value) { |
| 34 | return (isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag) || false; |
| 35 | } |
| 36 | |
| 37 | module.exports = isError; |
@@ -0,0 +1,40 @@ | |
| 1 | var isNative = require('./isNative'); |
| 2 | |
| 3 | /* Native method references for those with the same name as other `lodash` methods. */ |
| 4 | var nativeIsFinite = global.isFinite, |
| 5 | nativeNumIsFinite = isNative(nativeNumIsFinite = Number.isFinite) && nativeNumIsFinite; |
| 6 | |
| 7 | /** |
| 8 | * Checks if `value` is a finite primitive number. |
| 9 | * |
| 10 | * **Note:** This method is based on ES `Number.isFinite`. See the |
| 11 | * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite) |
| 12 | * for more details. |
| 13 | * |
| 14 | * @static |
| 15 | * @memberOf _ |
| 16 | * @category Lang |
| 17 | * @param {*} value The value to check. |
| 18 | * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. |
| 19 | * @example |
| 20 | * |
| 21 | * _.isFinite(10); |
| 22 | * // => true |
| 23 | * |
| 24 | * _.isFinite('10'); |
| 25 | * // => false |
| 26 | * |
| 27 | * _.isFinite(true); |
| 28 | * // => false |
| 29 | * |
| 30 | * _.isFinite(Object(10)); |
| 31 | * // => false |
| 32 | * |
| 33 | * _.isFinite(Infinity); |
| 34 | * // => false |
| 35 | */ |
| 36 | var isFinite = nativeNumIsFinite || function(value) { |
| 37 | return typeof value == 'number' && nativeIsFinite(value); |
| 38 | }; |
| 39 | |
| 40 | module.exports = isFinite; |
@@ -0,0 +1,50 @@ | |
| 1 | var isNative = require('./isNative'); |
| 2 | |
| 3 | /** `Object#toString` result references. */ |
| 4 | var funcTag = '[object Function]'; |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** |
| 10 | * Used to resolve the `toStringTag` of values. |
| 11 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 12 | * for more details. |
| 13 | */ |
| 14 | var objToString = objectProto.toString; |
| 15 | |
| 16 | /** Native method references. */ |
| 17 | var Uint8Array = isNative(Uint8Array = global.Uint8Array) && Uint8Array; |
| 18 | |
| 19 | /** |
| 20 | * Checks if `value` is classified as a `Function` object. |
| 21 | * |
| 22 | * @static |
| 23 | * @memberOf _ |
| 24 | * @category Lang |
| 25 | * @param {*} value The value to check. |
| 26 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. |
| 27 | * @example |
| 28 | * |
| 29 | * _.isFunction(_); |
| 30 | * // => true |
| 31 | * |
| 32 | * _.isFunction(/abc/); |
| 33 | * // => false |
| 34 | */ |
| 35 | function isFunction(value) { |
| 36 | // Avoid a Chakra JIT bug in compatibility modes of IE 11. |
| 37 | // See https://github.com/jashkenas/underscore/issues/1621 for more details. |
| 38 | return typeof value == 'function' || false; |
| 39 | } |
| 40 | // Fallback for environments that return incorrect `typeof` operator results. |
| 41 | if (isFunction(/x/) || (Uint8Array && !isFunction(Uint8Array))) { |
| 42 | isFunction = function(value) { |
| 43 | // The use of `Object#toString` avoids issues with the `typeof` operator |
| 44 | // in older versions of Chrome and Safari which return 'function' for regexes |
| 45 | // and Safari 8 equivalents which return 'object' for typed array constructors. |
| 46 | return objToString.call(value) == funcTag; |
| 47 | }; |
| 48 | } |
| 49 | |
| 50 | module.exports = isFunction; |
@@ -0,0 +1,54 @@ | |
| 1 | var baseIsEqual = require('../internal/baseIsEqual'), |
| 2 | bindCallback = require('../internal/bindCallback'), |
| 3 | isStrictComparable = require('../internal/isStrictComparable'); |
| 4 | |
| 5 | /** |
| 6 | * Performs a deep comparison between two values to determine if they are |
| 7 | * equivalent. If `customizer` is provided it is invoked to compare values. |
| 8 | * If `customizer` returns `undefined` comparisons are handled by the method |
| 9 | * instead. The `customizer` is bound to `thisArg` and invoked with three |
| 10 | * arguments; (value, other [, index|key]). |
| 11 | * |
| 12 | * **Note:** This method supports comparing arrays, booleans, `Date` objects, |
| 13 | * numbers, `Object` objects, regexes, and strings. Functions and DOM nodes |
| 14 | * are **not** supported. Provide a customizer function to extend support |
| 15 | * for comparing other values. |
| 16 | * |
| 17 | * @static |
| 18 | * @memberOf _ |
| 19 | * @category Lang |
| 20 | * @param {*} value The value to compare. |
| 21 | * @param {*} other The other value to compare. |
| 22 | * @param {Function} [customizer] The function to customize comparing values. |
| 23 | * @param {*} [thisArg] The `this` binding of `customizer`. |
| 24 | * @returns {boolean} Returns `true` if the values are equivalent, else `false`. |
| 25 | * @example |
| 26 | * |
| 27 | * var object = { 'user': 'fred' }; |
| 28 | * var other = { 'user': 'fred' }; |
| 29 | * |
| 30 | * object == other; |
| 31 | * // => false |
| 32 | * |
| 33 | * _.isEqual(object, other); |
| 34 | * // => true |
| 35 | * |
| 36 | * // using a customizer callback |
| 37 | * var array = ['hello', 'goodbye']; |
| 38 | * var other = ['hi', 'goodbye']; |
| 39 | * |
| 40 | * _.isEqual(array, other, function(value, other) { |
| 41 | * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; |
| 42 | * }); |
| 43 | * // => true |
| 44 | */ |
| 45 | function isEqual(value, other, customizer, thisArg) { |
| 46 | customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); |
| 47 | if (!customizer && isStrictComparable(value) && isStrictComparable(other)) { |
| 48 | return value === other; |
| 49 | } |
| 50 | var result = customizer ? customizer(value, other) : undefined; |
| 51 | return typeof result == 'undefined' ? baseIsEqual(value, other, customizer) : !!result; |
| 52 | } |
| 53 | |
| 54 | module.exports = isEqual; |
@@ -0,0 +1,35 @@ | |
| 1 | var isNumber = require('./isNumber'); |
| 2 | |
| 3 | /** |
| 4 | * Checks if `value` is `NaN`. |
| 5 | * |
| 6 | * **Note:** This method is not the same as native `isNaN` which returns `true` |
| 7 | * for `undefined` and other non-numeric values. See the [ES5 spec](https://es5.github.io/#x15.1.2.4) |
| 8 | * for more details. |
| 9 | * |
| 10 | * @static |
| 11 | * @memberOf _ |
| 12 | * @category Lang |
| 13 | * @param {*} value The value to check. |
| 14 | * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. |
| 15 | * @example |
| 16 | * |
| 17 | * _.isNaN(NaN); |
| 18 | * // => true |
| 19 | * |
| 20 | * _.isNaN(new Number(NaN)); |
| 21 | * // => true |
| 22 | * |
| 23 | * isNaN(undefined); |
| 24 | * // => true |
| 25 | * |
| 26 | * _.isNaN(undefined); |
| 27 | * // => false |
| 28 | */ |
| 29 | function isNaN(value) { |
| 30 | // An `NaN` primitive is the only value that is not equal to itself. |
| 31 | // Perform the `toStringTag` check first to avoid errors with some host objects in IE. |
| 32 | return isNumber(value) && value != +value; |
| 33 | } |
| 34 | |
| 35 | module.exports = isNaN; |
@@ -0,0 +1,55 @@ | |
| 1 | var escapeRegExp = require('../string/escapeRegExp'), |
| 2 | isObjectLike = require('../internal/isObjectLike'); |
| 3 | |
| 4 | /** `Object#toString` result references. */ |
| 5 | var funcTag = '[object Function]'; |
| 6 | |
| 7 | /** Used to detect host constructors (Safari > 5). */ |
| 8 | var reHostCtor = /^\[object .+?Constructor\]$/; |
| 9 | |
| 10 | /** Used for native method references. */ |
| 11 | var objectProto = Object.prototype; |
| 12 | |
| 13 | /** Used to resolve the decompiled source of functions. */ |
| 14 | var fnToString = Function.prototype.toString; |
| 15 | |
| 16 | /** |
| 17 | * Used to resolve the `toStringTag` of values. |
| 18 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 19 | * for more details. |
| 20 | */ |
| 21 | var objToString = objectProto.toString; |
| 22 | |
| 23 | /** Used to detect if a method is native. */ |
| 24 | var reNative = RegExp('^' + |
| 25 | escapeRegExp(objToString) |
| 26 | .replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' |
| 27 | ); |
| 28 | |
| 29 | /** |
| 30 | * Checks if `value` is a native function. |
| 31 | * |
| 32 | * @static |
| 33 | * @memberOf _ |
| 34 | * @category Lang |
| 35 | * @param {*} value The value to check. |
| 36 | * @returns {boolean} Returns `true` if `value` is a native function, else `false`. |
| 37 | * @example |
| 38 | * |
| 39 | * _.isNative(Array.prototype.push); |
| 40 | * // => true |
| 41 | * |
| 42 | * _.isNative(_); |
| 43 | * // => false |
| 44 | */ |
| 45 | function isNative(value) { |
| 46 | if (value == null) { |
| 47 | return false; |
| 48 | } |
| 49 | if (objToString.call(value) == funcTag) { |
| 50 | return reNative.test(fnToString.call(value)); |
| 51 | } |
| 52 | return (isObjectLike(value) && reHostCtor.test(value)) || false; |
| 53 | } |
| 54 | |
| 55 | module.exports = isNative; |
@@ -0,0 +1,21 @@ | |
| 1 | /** |
| 2 | * Checks if `value` is `null`. |
| 3 | * |
| 4 | * @static |
| 5 | * @memberOf _ |
| 6 | * @category Lang |
| 7 | * @param {*} value The value to check. |
| 8 | * @returns {boolean} Returns `true` if `value` is `null`, else `false`. |
| 9 | * @example |
| 10 | * |
| 11 | * _.isNull(null); |
| 12 | * // => true |
| 13 | * |
| 14 | * _.isNull(void 0); |
| 15 | * // => false |
| 16 | */ |
| 17 | function isNull(value) { |
| 18 | return value === null; |
| 19 | } |
| 20 | |
| 21 | module.exports = isNull; |
@@ -0,0 +1,42 @@ | |
| 1 | var isObjectLike = require('../internal/isObjectLike'); |
| 2 | |
| 3 | /** `Object#toString` result references. */ |
| 4 | var numberTag = '[object Number]'; |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** |
| 10 | * Used to resolve the `toStringTag` of values. |
| 11 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 12 | * for more details. |
| 13 | */ |
| 14 | var objToString = objectProto.toString; |
| 15 | |
| 16 | /** |
| 17 | * Checks if `value` is classified as a `Number` primitive or object. |
| 18 | * |
| 19 | * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified |
| 20 | * as numbers, use the `_.isFinite` method. |
| 21 | * |
| 22 | * @static |
| 23 | * @memberOf _ |
| 24 | * @category Lang |
| 25 | * @param {*} value The value to check. |
| 26 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. |
| 27 | * @example |
| 28 | * |
| 29 | * _.isNumber(8.4); |
| 30 | * // => true |
| 31 | * |
| 32 | * _.isNumber(NaN); |
| 33 | * // => true |
| 34 | * |
| 35 | * _.isNumber('8.4'); |
| 36 | * // => false |
| 37 | */ |
| 38 | function isNumber(value) { |
| 39 | return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag) || false; |
| 40 | } |
| 41 | |
| 42 | module.exports = isNumber; |
@@ -0,0 +1,30 @@ | |
| 1 | /** |
| 2 | * Checks if `value` is the language type of `Object`. |
| 3 | * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) |
| 4 | * |
| 5 | * **Note:** See the [ES5 spec](https://es5.github.io/#x8) for more details. |
| 6 | * |
| 7 | * @static |
| 8 | * @memberOf _ |
| 9 | * @category Lang |
| 10 | * @param {*} value The value to check. |
| 11 | * @returns {boolean} Returns `true` if `value` is an object, else `false`. |
| 12 | * @example |
| 13 | * |
| 14 | * _.isObject({}); |
| 15 | * // => true |
| 16 | * |
| 17 | * _.isObject([1, 2, 3]); |
| 18 | * // => true |
| 19 | * |
| 20 | * _.isObject(1); |
| 21 | * // => false |
| 22 | */ |
| 23 | function isObject(value) { |
| 24 | // Avoid a V8 JIT bug in Chrome 19-20. |
| 25 | // See https://code.google.com/p/v8/issues/detail?id=2291 for more details. |
| 26 | var type = typeof value; |
| 27 | return type == 'function' || (value && type == 'object') || false; |
| 28 | } |
| 29 | |
| 30 | module.exports = isObject; |
@@ -0,0 +1,48 @@ | |
| 1 | var isArguments = require('./isArguments'), |
| 2 | isArray = require('./isArray'), |
| 3 | isFunction = require('./isFunction'), |
| 4 | isLength = require('../internal/isLength'), |
| 5 | isObjectLike = require('../internal/isObjectLike'), |
| 6 | isString = require('./isString'), |
| 7 | keys = require('../object/keys'); |
| 8 | |
| 9 | /** |
| 10 | * Checks if a value is empty. A value is considered empty unless it is an |
| 11 | * `arguments` object, array, string, or jQuery-like collection with a length |
| 12 | * greater than `0` or an object with own enumerable properties. |
| 13 | * |
| 14 | * @static |
| 15 | * @memberOf _ |
| 16 | * @category Lang |
| 17 | * @param {Array|Object|string} value The value to inspect. |
| 18 | * @returns {boolean} Returns `true` if `value` is empty, else `false`. |
| 19 | * @example |
| 20 | * |
| 21 | * _.isEmpty(null); |
| 22 | * // => true |
| 23 | * |
| 24 | * _.isEmpty(true); |
| 25 | * // => true |
| 26 | * |
| 27 | * _.isEmpty(1); |
| 28 | * // => true |
| 29 | * |
| 30 | * _.isEmpty([1, 2, 3]); |
| 31 | * // => false |
| 32 | * |
| 33 | * _.isEmpty({ 'a': 1 }); |
| 34 | * // => false |
| 35 | */ |
| 36 | function isEmpty(value) { |
| 37 | if (value == null) { |
| 38 | return true; |
| 39 | } |
| 40 | var length = value.length; |
| 41 | if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) || |
| 42 | (isObjectLike(value) && isFunction(value.splice)))) { |
| 43 | return !length; |
| 44 | } |
| 45 | return !keys(value).length; |
| 46 | } |
| 47 | |
| 48 | module.exports = isEmpty; |
@@ -0,0 +1,62 @@ | |
| 1 | var isNative = require('./isNative'), |
| 2 | shimIsPlainObject = require('../internal/shimIsPlainObject'); |
| 3 | |
| 4 | /** `Object#toString` result references. */ |
| 5 | var objectTag = '[object Object]'; |
| 6 | |
| 7 | /** Used for native method references. */ |
| 8 | var objectProto = Object.prototype; |
| 9 | |
| 10 | /** |
| 11 | * Used to resolve the `toStringTag` of values. |
| 12 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 13 | * for more details. |
| 14 | */ |
| 15 | var objToString = objectProto.toString; |
| 16 | |
| 17 | /** Native method references. */ |
| 18 | var getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf; |
| 19 | |
| 20 | /** |
| 21 | * Checks if `value` is a plain object, that is, an object created by the |
| 22 | * `Object` constructor or one with a `[[Prototype]]` of `null`. |
| 23 | * |
| 24 | * **Note:** This method assumes objects created by the `Object` constructor |
| 25 | * have no inherited enumerable properties. |
| 26 | * |
| 27 | * @static |
| 28 | * @memberOf _ |
| 29 | * @category Lang |
| 30 | * @param {*} value The value to check. |
| 31 | * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. |
| 32 | * @example |
| 33 | * |
| 34 | * function Foo() { |
| 35 | * this.a = 1; |
| 36 | * } |
| 37 | * |
| 38 | * _.isPlainObject(new Foo); |
| 39 | * // => false |
| 40 | * |
| 41 | * _.isPlainObject([1, 2, 3]); |
| 42 | * // => false |
| 43 | * |
| 44 | * _.isPlainObject({ 'x': 0, 'y': 0 }); |
| 45 | * // => true |
| 46 | * |
| 47 | * _.isPlainObject(Object.create(null)); |
| 48 | * // => true |
| 49 | */ |
| 50 | var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) { |
| 51 | if (!(value && objToString.call(value) == objectTag)) { |
| 52 | return false; |
| 53 | } |
| 54 | var valueOf = value.valueOf, |
| 55 | objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto); |
| 56 | |
| 57 | return objProto |
| 58 | ? (value == objProto || getPrototypeOf(value) == objProto) |
| 59 | : shimIsPlainObject(value); |
| 60 | }; |
| 61 | |
| 62 | module.exports = isPlainObject; |
@@ -0,0 +1,42 @@ | |
| 1 | var isObjectLike = require('../internal/isObjectLike'), |
| 2 | isPlainObject = require('./isPlainObject'), |
| 3 | support = require('../support'); |
| 4 | |
| 5 | /** Used for native method references. */ |
| 6 | var objectProto = Object.prototype; |
| 7 | |
| 8 | /** |
| 9 | * Used to resolve the `toStringTag` of values. |
| 10 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 11 | * for more details. |
| 12 | */ |
| 13 | var objToString = objectProto.toString; |
| 14 | |
| 15 | /** |
| 16 | * Checks if `value` is a DOM element. |
| 17 | * |
| 18 | * @static |
| 19 | * @memberOf _ |
| 20 | * @category Lang |
| 21 | * @param {*} value The value to check. |
| 22 | * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. |
| 23 | * @example |
| 24 | * |
| 25 | * _.isElement(document.body); |
| 26 | * // => true |
| 27 | * |
| 28 | * _.isElement('<body>'); |
| 29 | * // => false |
| 30 | */ |
| 31 | function isElement(value) { |
| 32 | return (value && value.nodeType === 1 && isObjectLike(value) && |
| 33 | objToString.call(value).indexOf('Element') > -1) || false; |
| 34 | } |
| 35 | // Fallback for environments without DOM support. |
| 36 | if (!support.dom) { |
| 37 | isElement = function(value) { |
| 38 | return (value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value)) || false; |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | module.exports = isElement; |
@@ -0,0 +1,36 @@ | |
| 1 | var isObjectLike = require('../internal/isObjectLike'); |
| 2 | |
| 3 | /** `Object#toString` result references. */ |
| 4 | var regexpTag = '[object RegExp]'; |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** |
| 10 | * Used to resolve the `toStringTag` of values. |
| 11 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 12 | * for more details. |
| 13 | */ |
| 14 | var objToString = objectProto.toString; |
| 15 | |
| 16 | /** |
| 17 | * Checks if `value` is classified as a `RegExp` object. |
| 18 | * |
| 19 | * @static |
| 20 | * @memberOf _ |
| 21 | * @category Lang |
| 22 | * @param {*} value The value to check. |
| 23 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. |
| 24 | * @example |
| 25 | * |
| 26 | * _.isRegExp(/abc/); |
| 27 | * // => true |
| 28 | * |
| 29 | * _.isRegExp('/abc/'); |
| 30 | * // => false |
| 31 | */ |
| 32 | function isRegExp(value) { |
| 33 | return (isObjectLike(value) && objToString.call(value) == regexpTag) || false; |
| 34 | } |
| 35 | |
| 36 | module.exports = isRegExp; |
@@ -0,0 +1,36 @@ | |
| 1 | var isObjectLike = require('../internal/isObjectLike'); |
| 2 | |
| 3 | /** `Object#toString` result references. */ |
| 4 | var dateTag = '[object Date]'; |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** |
| 10 | * Used to resolve the `toStringTag` of values. |
| 11 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 12 | * for more details. |
| 13 | */ |
| 14 | var objToString = objectProto.toString; |
| 15 | |
| 16 | /** |
| 17 | * Checks if `value` is classified as a `Date` object. |
| 18 | * |
| 19 | * @static |
| 20 | * @memberOf _ |
| 21 | * @category Lang |
| 22 | * @param {*} value The value to check. |
| 23 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. |
| 24 | * @example |
| 25 | * |
| 26 | * _.isDate(new Date); |
| 27 | * // => true |
| 28 | * |
| 29 | * _.isDate('Mon April 23 2012'); |
| 30 | * // => false |
| 31 | */ |
| 32 | function isDate(value) { |
| 33 | return (isObjectLike(value) && objToString.call(value) == dateTag) || false; |
| 34 | } |
| 35 | |
| 36 | module.exports = isDate; |
@@ -0,0 +1,36 @@ | |
| 1 | var isObjectLike = require('../internal/isObjectLike'); |
| 2 | |
| 3 | /** `Object#toString` result references. */ |
| 4 | var stringTag = '[object String]'; |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** |
| 10 | * Used to resolve the `toStringTag` of values. |
| 11 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 12 | * for more details. |
| 13 | */ |
| 14 | var objToString = objectProto.toString; |
| 15 | |
| 16 | /** |
| 17 | * Checks if `value` is classified as a `String` primitive or object. |
| 18 | * |
| 19 | * @static |
| 20 | * @memberOf _ |
| 21 | * @category Lang |
| 22 | * @param {*} value The value to check. |
| 23 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. |
| 24 | * @example |
| 25 | * |
| 26 | * _.isString('abc'); |
| 27 | * // => true |
| 28 | * |
| 29 | * _.isString(1); |
| 30 | * // => false |
| 31 | */ |
| 32 | function isString(value) { |
| 33 | return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag) || false; |
| 34 | } |
| 35 | |
| 36 | module.exports = isString; |
@@ -0,0 +1,36 @@ | |
| 1 | var isObjectLike = require('../internal/isObjectLike'); |
| 2 | |
| 3 | /** `Object#toString` result references. */ |
| 4 | var boolTag = '[object Boolean]'; |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** |
| 10 | * Used to resolve the `toStringTag` of values. |
| 11 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 12 | * for more details. |
| 13 | */ |
| 14 | var objToString = objectProto.toString; |
| 15 | |
| 16 | /** |
| 17 | * Checks if `value` is classified as a boolean primitive or object. |
| 18 | * |
| 19 | * @static |
| 20 | * @memberOf _ |
| 21 | * @category Lang |
| 22 | * @param {*} value The value to check. |
| 23 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. |
| 24 | * @example |
| 25 | * |
| 26 | * _.isBoolean(false); |
| 27 | * // => true |
| 28 | * |
| 29 | * _.isBoolean(null); |
| 30 | * // => false |
| 31 | */ |
| 32 | function isBoolean(value) { |
| 33 | return (value === true || value === false || isObjectLike(value) && objToString.call(value) == boolTag) || false; |
| 34 | } |
| 35 | |
| 36 | module.exports = isBoolean; |
@@ -0,0 +1,75 @@ | |
| 1 | var isLength = require('../internal/isLength'), |
| 2 | isObjectLike = require('../internal/isObjectLike'); |
| 3 | |
| 4 | /** `Object#toString` result references. */ |
| 5 | var argsTag = '[object Arguments]', |
| 6 | arrayTag = '[object Array]', |
| 7 | boolTag = '[object Boolean]', |
| 8 | dateTag = '[object Date]', |
| 9 | errorTag = '[object Error]', |
| 10 | funcTag = '[object Function]', |
| 11 | mapTag = '[object Map]', |
| 12 | numberTag = '[object Number]', |
| 13 | objectTag = '[object Object]', |
| 14 | regexpTag = '[object RegExp]', |
| 15 | setTag = '[object Set]', |
| 16 | stringTag = '[object String]', |
| 17 | weakMapTag = '[object WeakMap]'; |
| 18 | |
| 19 | var arrayBufferTag = '[object ArrayBuffer]', |
| 20 | float32Tag = '[object Float32Array]', |
| 21 | float64Tag = '[object Float64Array]', |
| 22 | int8Tag = '[object Int8Array]', |
| 23 | int16Tag = '[object Int16Array]', |
| 24 | int32Tag = '[object Int32Array]', |
| 25 | uint8Tag = '[object Uint8Array]', |
| 26 | uint8ClampedTag = '[object Uint8ClampedArray]', |
| 27 | uint16Tag = '[object Uint16Array]', |
| 28 | uint32Tag = '[object Uint32Array]'; |
| 29 | |
| 30 | /** Used to identify `toStringTag` values of typed arrays. */ |
| 31 | var typedArrayTags = {}; |
| 32 | typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = |
| 33 | typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = |
| 34 | typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = |
| 35 | typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = |
| 36 | typedArrayTags[uint32Tag] = true; |
| 37 | typedArrayTags[argsTag] = typedArrayTags[arrayTag] = |
| 38 | typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = |
| 39 | typedArrayTags[dateTag] = typedArrayTags[errorTag] = |
| 40 | typedArrayTags[funcTag] = typedArrayTags[mapTag] = |
| 41 | typedArrayTags[numberTag] = typedArrayTags[objectTag] = |
| 42 | typedArrayTags[regexpTag] = typedArrayTags[setTag] = |
| 43 | typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; |
| 44 | |
| 45 | /** Used for native method references. */ |
| 46 | var objectProto = Object.prototype; |
| 47 | |
| 48 | /** |
| 49 | * Used to resolve the `toStringTag` of values. |
| 50 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 51 | * for more details. |
| 52 | */ |
| 53 | var objToString = objectProto.toString; |
| 54 | |
| 55 | /** |
| 56 | * Checks if `value` is classified as a typed array. |
| 57 | * |
| 58 | * @static |
| 59 | * @memberOf _ |
| 60 | * @category Lang |
| 61 | * @param {*} value The value to check. |
| 62 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. |
| 63 | * @example |
| 64 | * |
| 65 | * _.isTypedArray(new Uint8Array); |
| 66 | * // => true |
| 67 | * |
| 68 | * _.isTypedArray([]); |
| 69 | * // => false |
| 70 | */ |
| 71 | function isTypedArray(value) { |
| 72 | return (isObjectLike(value) && isLength(value.length) && typedArrayTags[objToString.call(value)]) || false; |
| 73 | } |
| 74 | |
| 75 | module.exports = isTypedArray; |
@@ -0,0 +1,41 @@ | |
| 1 | var isLength = require('../internal/isLength'), |
| 2 | isNative = require('./isNative'), |
| 3 | isObjectLike = require('../internal/isObjectLike'); |
| 4 | |
| 5 | /** `Object#toString` result references. */ |
| 6 | var arrayTag = '[object Array]'; |
| 7 | |
| 8 | /** Used for native method references. */ |
| 9 | var objectProto = Object.prototype; |
| 10 | |
| 11 | /** |
| 12 | * Used to resolve the `toStringTag` of values. |
| 13 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 14 | * for more details. |
| 15 | */ |
| 16 | var objToString = objectProto.toString; |
| 17 | |
| 18 | /* Native method references for those with the same name as other `lodash` methods. */ |
| 19 | var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray; |
| 20 | |
| 21 | /** |
| 22 | * Checks if `value` is classified as an `Array` object. |
| 23 | * |
| 24 | * @static |
| 25 | * @memberOf _ |
| 26 | * @category Lang |
| 27 | * @param {*} value The value to check. |
| 28 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. |
| 29 | * @example |
| 30 | * |
| 31 | * _.isArray([1, 2, 3]); |
| 32 | * // => true |
| 33 | * |
| 34 | * (function() { return _.isArray(arguments); })(); |
| 35 | * // => false |
| 36 | */ |
| 37 | var isArray = nativeIsArray || function(value) { |
| 38 | return (isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag) || false; |
| 39 | }; |
| 40 | |
| 41 | module.exports = isArray; |
@@ -0,0 +1,21 @@ | |
| 1 | /** |
| 2 | * Checks if `value` is `undefined`. |
| 3 | * |
| 4 | * @static |
| 5 | * @memberOf _ |
| 6 | * @category Lang |
| 7 | * @param {*} value The value to check. |
| 8 | * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. |
| 9 | * @example |
| 10 | * |
| 11 | * _.isUndefined(void 0); |
| 12 | * // => true |
| 13 | * |
| 14 | * _.isUndefined(null); |
| 15 | * // => false |
| 16 | */ |
| 17 | function isUndefined(value) { |
| 18 | return typeof value == 'undefined'; |
| 19 | } |
| 20 | |
| 21 | module.exports = isUndefined; |
@@ -0,0 +1,38 @@ | |
| 1 | var isLength = require('../internal/isLength'), |
| 2 | isObjectLike = require('../internal/isObjectLike'); |
| 3 | |
| 4 | /** `Object#toString` result references. */ |
| 5 | var argsTag = '[object Arguments]'; |
| 6 | |
| 7 | /** Used for native method references. */ |
| 8 | var objectProto = Object.prototype; |
| 9 | |
| 10 | /** |
| 11 | * Used to resolve the `toStringTag` of values. |
| 12 | * See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) |
| 13 | * for more details. |
| 14 | */ |
| 15 | var objToString = objectProto.toString; |
| 16 | |
| 17 | /** |
| 18 | * Checks if `value` is classified as an `arguments` object. |
| 19 | * |
| 20 | * @static |
| 21 | * @memberOf _ |
| 22 | * @category Lang |
| 23 | * @param {*} value The value to check. |
| 24 | * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. |
| 25 | * @example |
| 26 | * |
| 27 | * (function() { return _.isArguments(arguments); })(); |
| 28 | * // => true |
| 29 | * |
| 30 | * _.isArguments([1, 2, 3]); |
| 31 | * // => false |
| 32 | */ |
| 33 | function isArguments(value) { |
| 34 | var length = isObjectLike(value) ? value.length : undefined; |
| 35 | return (isLength(length) && objToString.call(value) == argsTag) || false; |
| 36 | } |
| 37 | |
| 38 | module.exports = isArguments; |
@@ -0,0 +1,29 @@ | |
| 1 | var arrayCopy = require('../internal/arrayCopy'), |
| 2 | isLength = require('../internal/isLength'), |
| 3 | values = require('../object/values'); |
| 4 | |
| 5 | /** |
| 6 | * Converts `value` to an array. |
| 7 | * |
| 8 | * @static |
| 9 | * @memberOf _ |
| 10 | * @category Lang |
| 11 | * @param {*} value The value to convert. |
| 12 | * @returns {Array} Returns the converted array. |
| 13 | * @example |
| 14 | * |
| 15 | * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3); |
| 16 | * // => [2, 3] |
| 17 | */ |
| 18 | function toArray(value) { |
| 19 | var length = value ? value.length : 0; |
| 20 | if (!isLength(length)) { |
| 21 | return values(value); |
| 22 | } |
| 23 | if (!length) { |
| 24 | return []; |
| 25 | } |
| 26 | return arrayCopy(value); |
| 27 | } |
| 28 | |
| 29 | module.exports = toArray; |
@@ -0,0 +1,52 @@ | |
| 1 | var baseClone = require('../internal/baseClone'), |
| 2 | bindCallback = require('../internal/bindCallback'); |
| 3 | |
| 4 | /** |
| 5 | * Creates a deep clone of `value`. If `customizer` is provided it is invoked |
| 6 | * to produce the cloned values. If `customizer` returns `undefined` cloning |
| 7 | * is handled by the method instead. The `customizer` is bound to `thisArg` |
| 8 | * and invoked with two argument; (value [, index|key, object]). |
| 9 | * |
| 10 | * **Note:** This method is loosely based on the structured clone algorithm. |
| 11 | * The enumerable properties of `arguments` objects and objects created by |
| 12 | * constructors other than `Object` are cloned to plain `Object` objects. An |
| 13 | * empty object is returned for uncloneable values such as functions, DOM nodes, |
| 14 | * Maps, Sets, and WeakMaps. See the [HTML5 specification](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm) |
| 15 | * for more details. |
| 16 | * |
| 17 | * @static |
| 18 | * @memberOf _ |
| 19 | * @category Lang |
| 20 | * @param {*} value The value to deep clone. |
| 21 | * @param {Function} [customizer] The function to customize cloning values. |
| 22 | * @param {*} [thisArg] The `this` binding of `customizer`. |
| 23 | * @returns {*} Returns the deep cloned value. |
| 24 | * @example |
| 25 | * |
| 26 | * var users = [ |
| 27 | * { 'user': 'barney' }, |
| 28 | * { 'user': 'fred' } |
| 29 | * ]; |
| 30 | * |
| 31 | * var deep = _.cloneDeep(users); |
| 32 | * deep[0] === users[0]; |
| 33 | * // => false |
| 34 | * |
| 35 | * // using a customizer callback |
| 36 | * var el = _.cloneDeep(document.body, function(value) { |
| 37 | * return _.isElement(value) ? value.cloneNode(true) : undefined; |
| 38 | * }); |
| 39 | * |
| 40 | * body === document.body |
| 41 | * // => false |
| 42 | * body.nodeName |
| 43 | * // => BODY |
| 44 | * body.childNodes.length; |
| 45 | * // => 20 |
| 46 | */ |
| 47 | function cloneDeep(value, customizer, thisArg) { |
| 48 | customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); |
| 49 | return baseClone(value, true, customizer); |
| 50 | } |
| 51 | |
| 52 | module.exports = cloneDeep; |
@@ -0,0 +1,31 @@ | |
| 1 | var baseCopy = require('../internal/baseCopy'), |
| 2 | keysIn = require('../object/keysIn'); |
| 3 | |
| 4 | /** |
| 5 | * Converts `value` to a plain object flattening inherited enumerable |
| 6 | * properties of `value` to own properties of the plain object. |
| 7 | * |
| 8 | * @static |
| 9 | * @memberOf _ |
| 10 | * @category Lang |
| 11 | * @param {*} value The value to convert. |
| 12 | * @returns {Object} Returns the converted plain object. |
| 13 | * @example |
| 14 | * |
| 15 | * function Foo() { |
| 16 | * this.b = 2; |
| 17 | * } |
| 18 | * |
| 19 | * Foo.prototype.c = 3; |
| 20 | * |
| 21 | * _.assign({ 'a': 1 }, new Foo); |
| 22 | * // => { 'a': 1, 'b': 2 } |
| 23 | * |
| 24 | * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); |
| 25 | * // => { 'a': 1, 'b': 2, 'c': 3 } |
| 26 | */ |
| 27 | function toPlainObject(value) { |
| 28 | return baseCopy(value, keysIn(value)); |
| 29 | } |
| 30 | |
| 31 | module.exports = toPlainObject; |
@@ -0,0 +1,74 @@ | |
| 1 | var baseIsMatch = require('../internal/baseIsMatch'), |
| 2 | bindCallback = require('../internal/bindCallback'), |
| 3 | isStrictComparable = require('../internal/isStrictComparable'), |
| 4 | keys = require('../object/keys'); |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** Used to check objects for own properties. */ |
| 10 | var hasOwnProperty = objectProto.hasOwnProperty; |
| 11 | |
| 12 | /** |
| 13 | * Performs a deep comparison between `object` and `source` to determine if |
| 14 | * `object` contains equivalent property values. If `customizer` is provided |
| 15 | * it is invoked to compare values. If `customizer` returns `undefined` |
| 16 | * comparisons are handled by the method instead. The `customizer` is bound |
| 17 | * to `thisArg` and invoked with three arguments; (value, other, index|key). |
| 18 | * |
| 19 | * **Note:** This method supports comparing properties of arrays, booleans, |
| 20 | * `Date` objects, numbers, `Object` objects, regexes, and strings. Functions |
| 21 | * and DOM nodes are **not** supported. Provide a customizer function to extend |
| 22 | * support for comparing other values. |
| 23 | * |
| 24 | * @static |
| 25 | * @memberOf _ |
| 26 | * @category Lang |
| 27 | * @param {Object} source The object to inspect. |
| 28 | * @param {Object} source The object of property values to match. |
| 29 | * @param {Function} [customizer] The function to customize comparing values. |
| 30 | * @param {*} [thisArg] The `this` binding of `customizer`. |
| 31 | * @returns {boolean} Returns `true` if `object` is a match, else `false`. |
| 32 | * @example |
| 33 | * |
| 34 | * var object = { 'user': 'fred', 'age': 40 }; |
| 35 | * |
| 36 | * _.isMatch(object, { 'age': 40 }); |
| 37 | * // => true |
| 38 | * |
| 39 | * _.isMatch(object, { 'age': 36 }); |
| 40 | * // => false |
| 41 | * |
| 42 | * // using a customizer callback |
| 43 | * var object = { 'greeting': 'hello' }; |
| 44 | * var source = { 'greeting': 'hi' }; |
| 45 | * |
| 46 | * _.isMatch(object, source, function(value, other) { |
| 47 | * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; |
| 48 | * }); |
| 49 | * // => true |
| 50 | */ |
| 51 | function isMatch(object, source, customizer, thisArg) { |
| 52 | var props = keys(source), |
| 53 | length = props.length; |
| 54 | |
| 55 | customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); |
| 56 | if (!customizer && length == 1) { |
| 57 | var key = props[0], |
| 58 | value = source[key]; |
| 59 | |
| 60 | if (isStrictComparable(value)) { |
| 61 | return object != null && value === object[key] && hasOwnProperty.call(object, key); |
| 62 | } |
| 63 | } |
| 64 | var values = Array(length), |
| 65 | strictCompareFlags = Array(length); |
| 66 | |
| 67 | while (length--) { |
| 68 | value = values[length] = source[props[length]]; |
| 69 | strictCompareFlags[length] = isStrictComparable(value); |
| 70 | } |
| 71 | return baseIsMatch(object, props, values, strictCompareFlags, customizer); |
| 72 | } |
| 73 | |
| 74 | module.exports = isMatch; |
@@ -0,0 +1,22 @@ | |
| 1 | var isNative = require('../lang/isNative'); |
| 2 | |
| 3 | /* Native method references for those with the same name as other `lodash` methods. */ |
| 4 | var nativeNow = isNative(nativeNow = Date.now) && nativeNow; |
| 5 | |
| 6 | /** |
| 7 | * Gets the number of milliseconds that have elapsed since the Unix epoch |
| 8 | * (1 January 1970 00:00:00 UTC). |
| 9 | * |
| 10 | * @static |
| 11 | * @memberOf _ |
| 12 | * @category Date |
| 13 | * @example |
| 14 | * |
| 15 | * _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); |
| 16 | * // => logs the number of milliseconds it took for the deferred function to be invoked |
| 17 | */ |
| 18 | var now = nativeNow || function() { |
| 19 | return new Date().getTime(); |
| 20 | }; |
| 21 | |
| 22 | module.exports = now; |
@@ -0,0 +1,70 @@ | |
| 1 | var baseRandom = require('../internal/baseRandom'), |
| 2 | isIterateeCall = require('../internal/isIterateeCall'); |
| 3 | |
| 4 | /* Native method references for those with the same name as other `lodash` methods. */ |
| 5 | var nativeMin = Math.min, |
| 6 | nativeRandom = Math.random; |
| 7 | |
| 8 | /** |
| 9 | * Produces a random number between `min` and `max` (inclusive). If only one |
| 10 | * argument is provided a number between `0` and the given number is returned. |
| 11 | * If `floating` is `true`, or either `min` or `max` are floats, a floating-point |
| 12 | * number is returned instead of an integer. |
| 13 | * |
| 14 | * @static |
| 15 | * @memberOf _ |
| 16 | * @category Number |
| 17 | * @param {number} [min=0] The minimum possible value. |
| 18 | * @param {number} [max=1] The maximum possible value. |
| 19 | * @param {boolean} [floating] Specify returning a floating-point number. |
| 20 | * @returns {number} Returns the random number. |
| 21 | * @example |
| 22 | * |
| 23 | * _.random(0, 5); |
| 24 | * // => an integer between 0 and 5 |
| 25 | * |
| 26 | * _.random(5); |
| 27 | * // => also an integer between 0 and 5 |
| 28 | * |
| 29 | * _.random(5, true); |
| 30 | * // => a floating-point number between 0 and 5 |
| 31 | * |
| 32 | * _.random(1.2, 5.2); |
| 33 | * // => a floating-point number between 1.2 and 5.2 |
| 34 | */ |
| 35 | function random(min, max, floating) { |
| 36 | if (floating && isIterateeCall(min, max, floating)) { |
| 37 | max = floating = null; |
| 38 | } |
| 39 | var noMin = min == null, |
| 40 | noMax = max == null; |
| 41 | |
| 42 | if (floating == null) { |
| 43 | if (noMax && typeof min == 'boolean') { |
| 44 | floating = min; |
| 45 | min = 1; |
| 46 | } |
| 47 | else if (typeof max == 'boolean') { |
| 48 | floating = max; |
| 49 | noMax = true; |
| 50 | } |
| 51 | } |
| 52 | if (noMin && noMax) { |
| 53 | max = 1; |
| 54 | noMax = false; |
| 55 | } |
| 56 | min = +min || 0; |
| 57 | if (noMax) { |
| 58 | max = min; |
| 59 | min = 0; |
| 60 | } else { |
| 61 | max = +max || 0; |
| 62 | } |
| 63 | if (floating || min % 1 || max % 1) { |
| 64 | var rand = nativeRandom(); |
| 65 | return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand + '').length - 1)))), max); |
| 66 | } |
| 67 | return baseRandom(min, max); |
| 68 | } |
| 69 | |
| 70 | module.exports = random; |
@@ -0,0 +1,33 @@ | |
| 1 | var lodash = require('./lodash'); |
| 2 | |
| 3 | /** |
| 4 | * Creates a `lodash` object that wraps `value` with explicit method |
| 5 | * chaining enabled. |
| 6 | * |
| 7 | * @static |
| 8 | * @memberOf _ |
| 9 | * @category Chain |
| 10 | * @param {*} value The value to wrap. |
| 11 | * @returns {Object} Returns the new `lodash` object. |
| 12 | * @example |
| 13 | * |
| 14 | * var users = [ |
| 15 | * { 'user': 'barney', 'age': 36 }, |
| 16 | * { 'user': 'fred', 'age': 40 }, |
| 17 | * { 'user': 'pebbles', 'age': 1 } |
| 18 | * ]; |
| 19 | * |
| 20 | * var youngest = _.chain(users) |
| 21 | * .sortBy('age') |
| 22 | * .map(function(chr) { return chr.user + ' is ' + chr.age; }) |
| 23 | * .first() |
| 24 | * .value(); |
| 25 | * // => 'pebbles is 1' |
| 26 | */ |
| 27 | function chain(value) { |
| 28 | var result = lodash(value); |
| 29 | result.__chain__ = true; |
| 30 | return result; |
| 31 | } |
| 32 | |
| 33 | module.exports = chain; |
@@ -0,0 +1,27 @@ | |
| 1 | /** |
| 2 | * This method invokes `interceptor` and returns `value`. The interceptor is |
| 3 | * bound to `thisArg` and invoked with one argument; (value). The purpose of |
| 4 | * this method is to "tap into" a method chain in order to perform operations |
| 5 | * on intermediate results within the chain. |
| 6 | * |
| 7 | * @static |
| 8 | * @memberOf _ |
| 9 | * @category Chain |
| 10 | * @param {*} value The value to provide to `interceptor`. |
| 11 | * @param {Function} interceptor The function to invoke. |
| 12 | * @param {*} [thisArg] The `this` binding of `interceptor`. |
| 13 | * @returns {*} Returns `value`. |
| 14 | * @example |
| 15 | * |
| 16 | * _([1, 2, 3]) |
| 17 | * .tap(function(array) { array.pop(); }) |
| 18 | * .reverse() |
| 19 | * .value(); |
| 20 | * // => [2, 1] |
| 21 | */ |
| 22 | function tap(value, interceptor, thisArg) { |
| 23 | interceptor.call(thisArg, value); |
| 24 | return value; |
| 25 | } |
| 26 | |
| 27 | module.exports = tap; |
@@ -0,0 +1,23 @@ | |
| 1 | /** |
| 2 | * This method is like `_.tap` except that it returns the result of `interceptor`. |
| 3 | * |
| 4 | * @static |
| 5 | * @memberOf _ |
| 6 | * @category Chain |
| 7 | * @param {*} value The value to provide to `interceptor`. |
| 8 | * @param {Function} interceptor The function to invoke. |
| 9 | * @param {*} [thisArg] The `this` binding of `interceptor`. |
| 10 | * @returns {*} Returns the result of `interceptor`. |
| 11 | * @example |
| 12 | * |
| 13 | * _([1, 2, 3]) |
| 14 | * .last() |
| 15 | * .thru(function(value) { return [value]; }) |
| 16 | * .value(); |
| 17 | * // => [3] |
| 18 | */ |
| 19 | function thru(value, interceptor, thisArg) { |
| 20 | return interceptor.call(thisArg, value); |
| 21 | } |
| 22 | |
| 23 | module.exports = thru; |
@@ -0,0 +1,1 @@ | |
| 1 | module.exports = require('./wrapperValue'); |
@@ -0,0 +1,1 @@ | |
| 1 | module.exports = require('./wrapperReverse'); |
@@ -0,0 +1,1 @@ | |
| 1 | module.exports = require('./wrapperValue'); |
@@ -0,0 +1,1 @@ | |
| 1 | module.exports = require('./wrapperValue'); |
@@ -0,0 +1,32 @@ | |
| 1 | var chain = require('./chain'); |
| 2 | |
| 3 | /** |
| 4 | * Enables explicit method chaining on the wrapper object. |
| 5 | * |
| 6 | * @name chain |
| 7 | * @memberOf _ |
| 8 | * @category Chain |
| 9 | * @returns {*} Returns the `lodash` object. |
| 10 | * @example |
| 11 | * |
| 12 | * var users = [ |
| 13 | * { 'user': 'barney', 'age': 36 }, |
| 14 | * { 'user': 'fred', 'age': 40 } |
| 15 | * ]; |
| 16 | * |
| 17 | * // without explicit chaining |
| 18 | * _(users).first(); |
| 19 | * // => { 'user': 'barney', 'age': 36 } |
| 20 | * |
| 21 | * // with explicit chaining |
| 22 | * _(users).chain() |
| 23 | * .first() |
| 24 | * .pick('user') |
| 25 | * .value(); |
| 26 | * // => { 'user': 'barney' } |
| 27 | */ |
| 28 | function wrapperChain() { |
| 29 | return chain(this); |
| 30 | } |
| 31 | |
| 32 | module.exports = wrapperChain; |
@@ -0,0 +1,35 @@ | |
| 1 | var LazyWrapper = require('../internal/LazyWrapper'), |
| 2 | LodashWrapper = require('../internal/LodashWrapper'), |
| 3 | thru = require('./thru'); |
| 4 | |
| 5 | /** |
| 6 | * Reverses the wrapped array so the first element becomes the last, the |
| 7 | * second element becomes the second to last, and so on. |
| 8 | * |
| 9 | * **Note:** This method mutates the wrapped array. |
| 10 | * |
| 11 | * @name reverse |
| 12 | * @memberOf _ |
| 13 | * @category Chain |
| 14 | * @returns {Object} Returns the new reversed `lodash` object. |
| 15 | * @example |
| 16 | * |
| 17 | * var array = [1, 2, 3]; |
| 18 | * |
| 19 | * _(array).reverse().value() |
| 20 | * // => [3, 2, 1] |
| 21 | * |
| 22 | * console.log(array); |
| 23 | * // => [3, 2, 1] |
| 24 | */ |
| 25 | function wrapperReverse() { |
| 26 | var value = this.__wrapped__; |
| 27 | if (value instanceof LazyWrapper) { |
| 28 | return new LodashWrapper(value.reverse()); |
| 29 | } |
| 30 | return this.thru(function(value) { |
| 31 | return value.reverse(); |
| 32 | }); |
| 33 | } |
| 34 | |
| 35 | module.exports = wrapperReverse; |
@@ -0,0 +1,17 @@ | |
| 1 | /** |
| 2 | * Produces the result of coercing the unwrapped value to a string. |
| 3 | * |
| 4 | * @name toString |
| 5 | * @memberOf _ |
| 6 | * @category Chain |
| 7 | * @returns {string} Returns the coerced string value. |
| 8 | * @example |
| 9 | * |
| 10 | * _([1, 2, 3]).toString(); |
| 11 | * // => '1,2,3' |
| 12 | */ |
| 13 | function wrapperToString() { |
| 14 | return (this.value() + ''); |
| 15 | } |
| 16 | |
| 17 | module.exports = wrapperToString; |
@@ -0,0 +1,109 @@ | |
| 1 | var LodashWrapper = require('../internal/LodashWrapper'), |
| 2 | arrayCopy = require('../internal/arrayCopy'), |
| 3 | isArray = require('../lang/isArray'), |
| 4 | isObjectLike = require('../internal/isObjectLike'); |
| 5 | |
| 6 | /** Used for native method references. */ |
| 7 | var objectProto = Object.prototype; |
| 8 | |
| 9 | /** Used to check objects for own properties. */ |
| 10 | var hasOwnProperty = objectProto.hasOwnProperty; |
| 11 | |
| 12 | /** |
| 13 | * Creates a `lodash` object which wraps `value` to enable intuitive chaining. |
| 14 | * Methods that operate on and return arrays, collections, and functions can |
| 15 | * be chained together. Methods that return a boolean or single value will |
| 16 | * automatically end the chain returning the unwrapped value. Explicit chaining |
| 17 | * may be enabled using `_.chain`. The execution of chained methods is lazy, |
| 18 | * that is, execution is deferred until `_#value` is implicitly or explicitly |
| 19 | * called. |
| 20 | * |
| 21 | * Lazy evaluation allows several methods to support shortcut fusion. Shortcut |
| 22 | * fusion is an optimization that merges iteratees to avoid creating intermediate |
| 23 | * arrays and reduce the number of iteratee executions. |
| 24 | * |
| 25 | * Chaining is supported in custom builds as long as the `_#value` method is |
| 26 | * directly or indirectly included in the build. |
| 27 | * |
| 28 | * In addition to lodash methods, wrappers also have the following `Array` methods: |
| 29 | * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, |
| 30 | * and `unshift` |
| 31 | * |
| 32 | * The wrapper functions that support shortcut fusion are: |
| 33 | * `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `first`, |
| 34 | * `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, `slice`, |
| 35 | * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `where` |
| 36 | * |
| 37 | * The chainable wrapper functions are: |
| 38 | * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`, |
| 39 | * `callback`, `chain`, `chunk`, `compact`, `concat`, `constant`, `countBy`, |
| 40 | * `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`, |
| 41 | * `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `flatten`, |
| 42 | * `flattenDeep`, `flow`, `flowRight`, `forEach`, `forEachRight`, `forIn`, |
| 43 | * `forInRight`, `forOwn`, `forOwnRight`, `functions`, `groupBy`, `indexBy`, |
| 44 | * `initial`, `intersection`, `invert`, `invoke`, `keys`, `keysIn`, `map`, |
| 45 | * `mapValues`, `matches`, `memoize`, `merge`, `mixin`, `negate`, `noop`, |
| 46 | * `omit`, `once`, `pairs`, `partial`, `partialRight`, `partition`, `pick`, |
| 47 | * `pluck`, `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, |
| 48 | * `rearg`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, |
| 49 | * `sortBy`, `sortByAll`, `splice`, `take`, `takeRight`, `takeRightWhile`, |
| 50 | * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, |
| 51 | * `transform`, `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, |
| 52 | * `where`, `without`, `wrap`, `xor`, `zip`, and `zipObject` |
| 53 | * |
| 54 | * The wrapper functions that are **not** chainable by default are: |
| 55 | * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, |
| 56 | * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, |
| 57 | * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, |
| 58 | * `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, |
| 59 | * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, |
| 60 | * `isFunction`, `isMatch` , `isNative`, `isNaN`, `isNull`, `isNumber`, |
| 61 | * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, |
| 62 | * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`, |
| 63 | * `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, |
| 64 | * `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`, |
| 65 | * `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, |
| 66 | * `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, |
| 67 | * `unescape`, `uniqueId`, `value`, and `words` |
| 68 | * |
| 69 | * The wrapper function `sample` will return a wrapped value when `n` is provided, |
| 70 | * otherwise an unwrapped value is returned. |
| 71 | * |
| 72 | * @name _ |
| 73 | * @constructor |
| 74 | * @category Chain |
| 75 | * @param {*} value The value to wrap in a `lodash` instance. |
| 76 | * @returns {Object} Returns a `lodash` instance. |
| 77 | * @example |
| 78 | * |
| 79 | * var wrapped = _([1, 2, 3]); |
| 80 | * |
| 81 | * // returns an unwrapped value |
| 82 | * wrapped.reduce(function(sum, n) { return sum + n; }); |
| 83 | * // => 6 |
| 84 | * |
| 85 | * // returns a wrapped value |
| 86 | * var squares = wrapped.map(function(n) { return n * n; }); |
| 87 | * |
| 88 | * _.isArray(squares); |
| 89 | * // => false |
| 90 | * |
| 91 | * _.isArray(squares.value()); |
| 92 | * // => true |
| 93 | */ |
| 94 | function lodash(value) { |
| 95 | if (isObjectLike(value) && !isArray(value)) { |
| 96 | if (value instanceof LodashWrapper) { |
| 97 | return value; |
| 98 | } |
| 99 | if (hasOwnProperty.call(value, '__wrapped__')) { |
| 100 | return new LodashWrapper(value.__wrapped__, value.__chain__, arrayCopy(value.__actions__)); |
| 101 | } |
| 102 | } |
| 103 | return new LodashWrapper(value); |
| 104 | } |
| 105 | |
| 106 | // Ensure `new LodashWrapper` is an instance of `lodash`. |
| 107 | LodashWrapper.prototype = lodash.prototype; |
| 108 | |
| 109 | module.exports = lodash; |
@@ -0,0 +1,20 @@ | |
| 1 | var baseWrapperValue = require('../internal/baseWrapperValue'); |
| 2 | |
| 3 | /** |
| 4 | * Executes the chained sequence to extract the unwrapped value. |
| 5 | * |
| 6 | * @name value |
| 7 | * @memberOf _ |
| 8 | * @alias toJSON, valueOf |
| 9 | * @category Chain |
| 10 | * @returns {*} Returns the resolved unwrapped value. |
| 11 | * @example |
| 12 | * |
| 13 | * _([1, 2, 3]).value(); |
| 14 | * // => [1, 2, 3] |
| 15 | */ |
| 16 | function wrapperValue() { |
| 17 | return baseWrapperValue(this.__wrapped__, this.__actions__); |
| 18 | } |
| 19 | |
| 20 | module.exports = wrapperValue; |
@@ -0,0 +1,1 @@ | |
| 1 | module.exports = require('./wrapperToString'); |
@@ -0,0 +1,35 @@ | |
| 1 | var baseAssign = require('../internal/baseAssign'), |
| 2 | createAssigner = require('../internal/createAssigner'); |
| 3 | |
| 4 | /** |
| 5 | * Assigns own enumerable properties of source object(s) to the destination |
| 6 | * object. Subsequent sources overwrite property assignments of previous sources. |
| 7 | * If `customizer` is provided it is invoked to produce the assigned values. |
| 8 | * The `customizer` is bound to `thisArg` and invoked with five arguments; |
| 9 | * (objectValue, sourceValue, key, object, source). |
| 10 | * |
| 11 | * @static |
| 12 | * @memberOf _ |
| 13 | * @alias extend |
| 14 | * @category Object |
| 15 | * @param {Object} object The destination object. |
| 16 | * @param {...Object} [sources] The source objects. |
| 17 | * @param {Function} [customizer] The function to customize assigning values. |
| 18 | * @param {*} [thisArg] The `this` binding of `customizer`. |
| 19 | * @returns {Object} Returns `object`. |
| 20 | * @example |
| 21 | * |
| 22 | * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' }); |
| 23 | * // => { 'user': 'fred', 'age': 40 } |
| 24 | * |
| 25 | * // using a customizer callback |
| 26 | * var defaults = _.partialRight(_.assign, function(value, other) { |
| 27 | * return typeof value == 'undefined' ? other : value; |
| 28 | * }); |
| 29 | * |
| 30 | * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); |
| 31 | * // => { 'user': 'barney', 'age': 36 } |
| 32 | */ |
| 33 | var assign = createAssigner(baseAssign); |
| 34 | |
| 35 | module.exports = assign; |
@@ -0,0 +1,28 @@ | |
| 1 | var baseForRight = require('../internal/baseForRight'), |
| 2 | bindCallback = require('../internal/bindCallback'), |
| 3 | keys = require('./keys'); |
| 4 | |
| 5 | /** |
| 6 | * This method is like `_.forOwn` except that it iterates over properties of |
| 7 | * `object` in the opposite order. |
| 8 | * |
| 9 | * @static |
| 10 | * @memberOf _ |
| 11 | * @category Object |
| 12 | * @param {Object} object The object to iterate over. |
| 13 | * @param {Function} [iteratee=_.identity] The function invoked per iteration. |
| 14 | * @param {*} [thisArg] The `this` binding of `iteratee`. |
| 15 | * @returns {Object} Returns `object`. |
| 16 | * @example |
| 17 | * |
| 18 | * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { |
| 19 | * console.log(key); |
| 20 | * }); |
| 21 | * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' |
| 22 | */ |
| 23 | function forOwnRight(object, iteratee, thisArg) { |
| 24 | iteratee = bindCallback(iteratee, thisArg, 3); |
| 25 | return baseForRight(object, iteratee, keys); |
| 26 | } |
| 27 | |
| 28 | module.exports = forOwnRight; |
@@ -0,0 +1,23 @@ | |
| 1 | var baseFunctions = require('../internal/baseFunctions'), |
| 2 | keysIn = require('./keysIn'); |
| 3 | |
| 4 | /** |
| 5 | * Creates an array of function property names from all enumerable properties, |
| 6 | * own and inherited, of `object`. |
| 7 | * |
| 8 | * @static |
| 9 | * @memberOf _ |
| 10 | * @alias methods |
| 11 | * @category Object |
| 12 | * @param {Object} object The object to inspect. |
| 13 | * @returns {Array} Returns the new array of property names. |
| 14 | * @example |
| 15 | * |
| 16 | * _.functions(_); |
| 17 | * // => ['all', 'any', 'bind', ...] |
| 18 | */ |
| 19 | function functions(object) { |
| 20 | return baseFunctions(object, keysIn(object)); |
| 21 | } |
| 22 | |
| 23 | module.exports = functions; |
@@ -0,0 +1,26 @@ | |
| 1 | /** Used for native method references. */ |
| 2 | var objectProto = Object.prototype; |
| 3 | |
| 4 | /** Used to check objects for own properties. */ |
| 5 | var hasOwnProperty = objectProto.hasOwnProperty; |
| 6 | |
| 7 | /** |
| 8 | * Checks if `key` exists as a direct property of `object` instead of an |
| 9 | * inherited property. |
| 10 | * |
| 11 | * @static |
| 12 | * @memberOf _ |
| 13 | * @category Object |
| 14 | * @param {Object} object The object to inspect. |
| 15 | * @param {string} key The key to check. |
| 16 | * @returns {boolean} Returns `true` if `key` is a direct property, else `false`. |
| 17 | * @example |
| 18 | * |
| 19 | * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); |
| 20 | * // => true |
| 21 | */ |
| 22 | function has(object, key) { |
| 23 | return object ? hasOwnProperty.call(object, key) : false; |
| 24 | } |
| 25 | |
| 26 | module.exports = has; |
@@ -0,0 +1,31 @@ | |
| 1 | var baseForOwn = require('../internal/baseForOwn'), |
| 2 | bindCallback = require('../internal/bindCallback'); |
| 3 | |
| 4 | /** |
| 5 | * Iterates over own enumerable properties of an object invoking `iteratee` |
| 6 | * for each property. The `iteratee` is bound to `thisArg` and invoked with |
| 7 | * three arguments; (value, key, object). Iterator functions may exit iteration |
| 8 | * early by explicitly returning `false`. |
| 9 | * |
| 10 | * @static |
| 11 | * @memberOf _ |
| 12 | * @category Object |
| 13 | * @param {Object} object The object to iterate over. |
| 14 | * @param {Function} [iteratee=_.identity] The function invoked per iteration. |
| 15 | * @param {*} [thisArg] The `this` binding of `iteratee`. |
| 16 | * @returns {Object} Returns `object`. |
| 17 | * @example |
| 18 | * |
| 19 | * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { |
| 20 | * console.log(key); |
| 21 | * }); |
| 22 | * // => logs '0', '1', and 'length' (iteration order is not guaranteed) |
| 23 | */ |
| 24 | function forOwn(object, iteratee, thisArg) { |
| 25 | if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { |
| 26 | iteratee = bindCallback(iteratee, thisArg, 3); |
| 27 | } |
| 28 | return baseForOwn(object, iteratee); |
| 29 | } |
| 30 | |
| 31 | module.exports = forOwn; |
@@ -0,0 +1,48 @@ | |
| 1 | var isLength = require('../internal/isLength'), |
| 2 | isNative = require('../lang/isNative'), |
| 3 | isObject = require('../lang/isObject'), |
| 4 | shimKeys = require('../internal/shimKeys'); |
| 5 | |
| 6 | /* Native method references for those with the same name as other `lodash` methods. */ |
| 7 | var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys; |
| 8 | |
| 9 | /** |
| 10 | * Creates an array of the own enumerable property names of `object`. |
| 11 | * |
| 12 | * **Note:** Non-object values are coerced to objects. See the |
| 13 | * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys) |
| 14 | * for more details. |
| 15 | * |
| 16 | * @static |
| 17 | * @memberOf _ |
| 18 | * @category Object |
| 19 | * @param {Object} object The object to inspect. |
| 20 | * @returns {Array} Returns the array of property names. |
| 21 | * @example |
| 22 | * |
| 23 | * function Foo() { |
| 24 | * this.a = 1; |
| 25 | * this.b = 2; |
| 26 | * } |
| 27 | * |
| 28 | * Foo.prototype.c = 3; |
| 29 | * |
| 30 | * _.keys(new Foo); |
| 31 | * // => ['a', 'b'] (iteration order is not guaranteed) |
| 32 | * |
| 33 | * _.keys('hi'); |
| 34 | * // => ['0', '1'] |
| 35 | */ |
| 36 | var keys = !nativeKeys ? shimKeys : function(object) { |
| 37 | if (object) { |
| 38 | var Ctor = object.constructor, |
| 39 | length = object.length; |
| 40 | } |
| 41 | if ((typeof Ctor == 'function' && Ctor.prototype === object) || |
| 42 | (typeof object != 'function' && (length && isLength(length)))) { |
| 43 | return shimKeys(object); |
| 44 | } |
| 45 | return isObject(object) ? nativeKeys(object) : []; |
| 46 | }; |
| 47 | |
| 48 | module.exports = keys; |