diff --git a/.gitignore b/.gitignore index d415f6fe22..6c0346f687 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ .DS_Store *.custom.* -*.min.* *.template.* *.map +/*.min.* modularize node_modules dist/*.backbone.* diff --git a/.jamignore b/.jamignore deleted file mode 100644 index 20ea2891e3..0000000000 --- a/.jamignore +++ /dev/null @@ -1,12 +0,0 @@ -.* -*.md -/lodash.js -index.js -bower.json -component.json -doc -modularize -node_modules -perf -test -vendor diff --git a/.travis.yml b/.travis.yml index a2028d32cb..eaf350b998 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,23 @@ language: node_js node_js: - "0.6" + - "0.8" - "0.10" env: - - TEST_COMMAND="istanbul cover ./test/test.js" - - TEST_COMMAND="phantomjs ./test/test.js ../dist/lodash.compat.js" - - TEST_COMMAND="phantomjs ./test/test.js ../dist/lodash.compat.min.js" - - TEST_COMMAND="node ./test/test.js ../dist/lodash.js" - - TEST_COMMAND="node ./test/test.js ../dist/lodash.min.js" + global: + - BIN="node" BUILD=false MAKE=false + matrix: + - BUILD="compat" + - BUILD="modern" + - BUILD="legacy" MAKE=true + - BUILD="mobile" MAKE=true + - BIN="phantomjs" BUILD="compat" + - BIN="phantomjs" BUILD="legacy" MAKE=true + - BIN="phantomjs" BUILD="mobile" MAKE=true +matrix: + include: + - node_js: "0.10" + env: BIN="istanbul" git: depth: 1 branches: @@ -16,4 +26,10 @@ branches: before_script: - "npm install -g istanbul" script: - - $TEST_COMMAND + - "[ $BIN == 'istanbul' ] && $BIN cover ./test/test.js || true" + - "[ $MAKE != false ] && git clone --depth=1 --branch=master git://github.com/lodash/lodash-cli.git ./node_modules/lodash-cli || true" + - "[ $MAKE != false ] && mkdir ./node_modules/lodash-cli/node_modules && cd ./node_modules/lodash-cli/node_modules/ && ln -s ../../../ ./lodash && cd ../ && npm i . && cd ../../ || true" + - "[ $MAKE != false ] && node ./node_modules/lodash-cli/bin/lodash $BUILD -o ./dist/lodash.$BUILD.js || true" + - "[ $BUILD != false ] && cd ./test || true" + - "[ $BUILD != false ] && $BIN ./test.js ../dist/lodash.$BUILD.js || true" + - "[ $BUILD != false ] && $BIN ./test.js ../dist/lodash.$BUILD.min.js || true" diff --git a/README.md b/README.md index 7207586921..45f2cd3293 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,29 @@ -# Lo-Dash v2.0.0 +# Lo-Dash v2.1.0 A utility library delivering consistency, [customization](http://lodash.com/custom-builds), [performance](http://lodash.com/benchmarks), & [extras](http://lodash.com/#features). ## Download -* Modern builds: -[Development](https://raw.github.com/lodash/lodash/2.0.0/dist/lodash.js) & -[Production](https://raw.github.com/lodash/lodash/2.0.0/dist/lodash.min.js) +* Modern builds perfect for newer browsers/environments:
+[Development](https://raw.github.com/lodash/lodash/2.1.0/dist/lodash.js) & +[Production](https://raw.github.com/lodash/lodash/2.1.0/dist/lodash.min.js) -* Compatibility builds: -[Development](https://raw.github.com/lodash/lodash/2.0.0/dist/lodash.compat.js) & -[Production](https://raw.github.com/lodash/lodash/2.0.0/dist/lodash.compat.min.js) +* Compatibility builds for older environment support too:
+[Development](https://raw.github.com/lodash/lodash/2.1.0/dist/lodash.compat.js) & +[Production](https://raw.github.com/lodash/lodash/2.1.0/dist/lodash.compat.min.js) -* Underscore builds: -[Development](https://raw.github.com/lodash/lodash/2.0.0/dist/lodash.underscore.js) & -[Production](https://raw.github.com/lodash/lodash/2.0.0/dist/lodash.underscore.min.js) +* Underscore builds to use as a drop-in replacement:
+[Development](https://raw.github.com/lodash/lodash/2.1.0/dist/lodash.underscore.js) & +[Production](https://raw.github.com/lodash/lodash/2.1.0/dist/lodash.underscore.min.js) +CDN copies are available on [cdnjs](http://cdnjs.com/libraries/lodash.js/) & [jsDelivr](http://www.jsdelivr.com/#!lodash).
+For smaller file sizes, create [custom builds](http://lodash.com/custom-builds) with only the features needed.
Love modules? We’ve got you covered with [lodash-amd](https://npmjs.org/package/lodash-amd), [lodash-node](https://npmjs.org/package/lodash-node), and [npm packages](https://npmjs.org/browse/author/jdalton) per method. -CDN copies are available on [cdnjs](http://cdnjs.com/) & [jsDelivr](http://www.jsdelivr.com/#!lodash).
-For smaller file sizes, create [custom builds](http://lodash.com/custom-builds) with only the features needed. - ## Dive in -There’s plenty of [documentation](http://lodash.com/docs), [unit tests](http://lodash.com/tests), & [benchmarks](http://lodash.com/benchmarks). - -For a list of upcoming features, check out our [roadmap](https://github.com/lodash/lodash/wiki/Roadmap). +There’s plenty of [documentation](http://lodash.com/docs), [unit tests](http://lodash.com/tests), & [benchmarks](http://lodash.com/benchmarks).
+For a list of upcoming features, check out our [roadmap](https://github.com/lodash/lodash/wiki/Roadmap).
+The full changelog for this release is available on our [wiki](https://github.com/lodash/lodash/wiki/Changelog). ## Features *not* in Underscore @@ -47,6 +46,7 @@ For a list of upcoming features, check out our [roadmap](https://github.com/loda * [_.parseInt](http://lodash.com/docs#parseInt) for consistent behavior * [_.partialRight](http://lodash.com/docs#partialRight) for [partial application](http://lodash.com/docs#partial) from the right * [_.pull](http://lodash.com/docs#pull) & [_.remove](http://lodash.com/docs#remove) for mutating arrays + * [_.random](http://lodash.com/docs#random) supports returning floating-point numbers * [_.runInContext](http://lodash.com/docs#runInContext) for easier mocking * [_.support](http://lodash.com/docs#support) for flagging environment features * [_.template](http://lodash.com/docs#template) supports [*“imports”*](http://lodash.com/docs#templateSettings_imports) options & [ES6 template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6) @@ -78,7 +78,7 @@ For a list of upcoming features, check out our [roadmap](https://github.com/loda ## Support -Tested in Chrome 5~29, Firefox 2~23, IE 6-10, Opera 9.25~15, Safari 3-6, Node.js 0.6.8-0.10.18, Narwhal 0.3.2, PhantomJS 1.9.1, RingoJS 0.9, & Rhino 1.7RC5. +Tested in Chrome 5~29, Firefox 2~24, IE 6-10, Opera 9.25~16, Safari 3-6, Node.js 0.6.8-0.10.18, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, & Rhino 1.7RC5. ## Installation & usage @@ -91,10 +91,10 @@ In browsers: Using [`npm`](http://npmjs.org/): ```bash -npm i lodash +npm i --save lodash {sudo} npm i -g lodash -npm link lodash +npm ln lodash ``` In [Node.js](http://nodejs.org/) & [Ringo](http://ringojs.org/): @@ -129,60 +129,6 @@ require({ }); ``` -## Release Notes - -### v2.0.0 - -#### Compatibility Warnings - - * Aligned `_.after` with Underscore 1.5.0, making it always return a function - -#### Noteable Changes - - * Created Lo-Dash methods as `npm` packages & AMD/Node.js modules - * Made `_.chain` force chaining for all methods, even those that normally return unwrapped values - * Moved the build utility to [lodash-cli](https://npmjs.org/package/lodash-cli) - * Optimized `_.contains`, `_.debounce`, `_.isArguments`, `_.throttle`, `_.where`,
- & functions created by `_.bind`, `_.bindKey`, `_.curry`, `_.partial`, & `_.partialRight` - * Added [`_.curry`](http://lodash.com/docs#curry), [`_.forEachRight`](http://lodash.com/docs#forEachRight), - [`_.indexBy`](http://lodash.com/docs#indexBy), [`_.findLast`](http://lodash.com/docs#findLast), - [`_.findLastIndex`](http://lodash.com/docs#findLastIndex),
- [`_.findLastKey`](http://lodash.com/docs#findLastKey), [`_.forInRight`](http://lodash.com/docs#forInRight), - [`_.forOwnRight`](http://lodash.com/docs#forOwnRight), [`_.pull`](http://lodash.com/docs#pull), - [`_.remove`](http://lodash.com/docs#remove), & [`_.sample`](http://lodash.com/docs#sample) - -#### Other Changes - - * Added Curl & Dojo module loaders to the unit tests - * Added the `modularize` build option - * Added support for the `iife` command to be used without an `%output%` token - * Added support for `_.mixin` to accept a destination object - * Added support for `_.range` to accept a `step` of `0` - * Added `_.eachRight` as an alias for `_.forEachRight` - * Ensured *“Arrays”* methods support `arguments` objects - * Ensured *“Functions”* methods throw when not passed functions - * Ensured `_.at` works as a `callback` for `_.map` - * Ensured `_.createCallback` works when no `argCount` is specified - * Ensured `_.first` & `_.last` return arrays when passed a falsey `array` with an `n` value - * Ensured `_.flatten` works with `arguments` objects - * Ensured minified files work with Dojo’s builder - * Ensured `_.zipObject` skips falsey elements - * Improved dead code removal from builds - * Improved JSDoc syntax - * Made `_.memoize` avoid prefixing `cache` keys when using a `resolver` function - * Made `_.unzip` an alias of `_.zip` - * Removed local `clearTimeout` & `setTimeout` variables from the `underscore` build - * Reduced the size of the repo & `npm` package - * Simplified the bailout in `createCache` - * Updated sourceURL & sourceMappingURL syntax - * Updated `underscore` build compatibility to v1.5.2 - -The full changelog is available [here](https://github.com/lodash/lodash/wiki/Changelog). - -## BestieJS - -Lo-Dash is part of the [BestieJS](https://github.com/bestiejs) *“Best in Class”* module collection. This means it promotes solid environment support, ES5+ precedents, unit testing, & plenty of documentation. - ## Author | [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](http://twitter.com/jdalton "Follow @jdalton on Twitter") | diff --git a/bower.json b/bower.json index 1af2905f1e..1fb9348bcb 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "lodash", - "version": "2.0.0", - "main": "./dist/lodash.compat.js", + "version": "2.1.0", + "main": "dist/lodash.compat.js", "ignore": [ ".*", "*.custom.*", diff --git a/component.json b/component.json index af014a9373..506d978bf3 100644 --- a/component.json +++ b/component.json @@ -1,8 +1,8 @@ { "name": "lodash", "repo": "lodash/lodash", - "version": "2.0.0", - "description": "A utility library delivering consistency, customization, performance, and extras.", + "version": "2.1.0", + "description": "A utility library delivering consistency, customization, performance, & extras.", "license": "MIT", "keywords": ["amd", "browser", "client", "customize", "functional", "performance", "server", "speed", "util"], "scripts": [ diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 5ec3c8cc21..a0248551ac 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.0.0 (Custom Build) + * Lo-Dash 2.1.0 (Custom Build) * Build: `lodash -o ./dist/lodash.compat.js` * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.5.2 @@ -70,7 +70,7 @@ var reNoMatch = /($^)/; /** Used to detect functions containing a `this` reference */ - var reThis = (reThis = /\bthis\b/) && reThis.test(runInContext) && reThis; + var reThis = /\bthis\b/; /** Used to match unescaped characters in compiled string literals */ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; @@ -136,10 +136,13 @@ var root = (objectTypes[typeof window] && window) || this; /** Detect free variable `exports` */ - var freeExports = objectTypes[typeof exports] && exports; + var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; /** Detect free variable `module` */ - var freeModule = objectTypes[typeof module] && module && module.exports == freeExports && module; + var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; + + /** Detect the popular CommonJS extension `module.exports` */ + var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ var freeGlobal = objectTypes[typeof global] && global; @@ -199,7 +202,7 @@ } /** - * Adds a given `value` to the corresponding cache object. + * Adds a given value to the corresponding cache object. * * @private * @param {*} value The value to add to the cache. @@ -278,9 +281,11 @@ var index = -1, length = array.length, first = array[0], + mid = array[(length / 2) | 0], last = array[length - 1]; - if (first && typeof first == 'object' && last && typeof last == 'object') { + if (first && typeof first == 'object' && + mid && typeof mid == 'object' && last && typeof last == 'object') { return false; } var cache = getObject(); @@ -441,7 +446,7 @@ /*--------------------------------------------------------------------------*/ /** - * Create a new `lodash` function using the given `context` object. + * Create a new `lodash` function using the given context object. * * @static * @memberOf _ @@ -668,20 +673,20 @@ for (prop in arguments) { } /** - * Detect if `arguments` objects are `Object` objects (all but Narwhal and Opera < 10.5). + * Detect if an `arguments` object's [[Class]] is resolvable (all but Firefox < 4, IE < 9). * * @memberOf _.support * @type boolean */ - support.argsObject = arguments.constructor == Object && !(arguments instanceof Array); + support.argsClass = toString.call(arguments) == argsClass; /** - * Detect if an `arguments` object's [[Class]] is resolvable (all but Firefox < 4, IE < 9). + * Detect if `arguments` objects are `Object` objects (all but Narwhal and Opera < 10.5). * * @memberOf _.support * @type boolean */ - support.argsClass = toString.call(arguments) == argsClass; + support.argsObject = arguments.constructor == Object && !(arguments instanceof Array); /** * Detect if `name` or `message` properties of `Error.prototype` are @@ -714,20 +719,21 @@ support.fastBind = nativeBind && !isV8; /** - * Detect if `Function#name` is supported (all but IE). + * Detect if functions can be decompiled by `Function#toString` + * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps). * * @memberOf _.support * @type boolean */ - support.funcNames = typeof Function.name == 'string'; + support.funcDecomp = !reNative.test(context.WinRTError) && reThis.test(runInContext); /** - * Detect if own properties are iterated after inherited properties (all but IE < 9). + * Detect if `Function#name` is supported (all but IE). * * @memberOf _.support * @type boolean */ - support.ownLast = props[0] != 'x'; + support.funcNames = typeof Function.name == 'string'; /** * Detect if `arguments` object indexes are non-enumerable @@ -749,6 +755,14 @@ */ support.nonEnumShadows = !/valueOf/.test(props); + /** + * Detect if own properties are iterated after inherited properties (all but IE < 9). + * + * @memberOf _.support + * @type boolean + */ + support.ownLast = props[0] != 'x'; + /** * Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. * @@ -958,7 +972,7 @@ * * @private * @param {*} value The value to clone. - * @param {boolean} [deep=false] A flag to indicate a deep clone. + * @param {boolean} [deep=false] Specify a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {Array} [stackA=[]] Tracks traversed source objects. * @param {Array} [stackB=[]] Associates clones with source counterparts. @@ -1068,7 +1082,7 @@ } if (support.funcNames || !bindData) { // checks if `func` references the `this` keyword and stores the result - bindData = !reThis || reThis.test(source); + bindData = !support.funcDecomp || reThis.test(source); setBindData(func, bindData); } } @@ -1111,9 +1125,21 @@ while (++index < length) { var value = array[index]; - // recursively flatten arrays (susceptible to call stack limits) - if (value && typeof value == 'object' && (isArray(value) || isArguments(value))) { - push.apply(result, isShallow ? value : baseFlatten(value, isShallow, isArgArrays)); + + if (value && typeof value == 'object' && typeof value.length == 'number' + && (isArray(value) || isArguments(value))) { + // recursively flatten arrays (susceptible to call stack limits) + if (!isShallow) { + value = baseFlatten(value, isShallow, isArgArrays); + } + var valIndex = -1, + valLength = value.length, + resIndex = result.length; + + result.length += valLength; + while (++valIndex < valLength) { + result[resIndex++] = value[valIndex]; + } } else if (!isArgArrays) { result.push(value); } @@ -1734,12 +1760,14 @@ * // => false */ function isArguments(value) { - return (value && typeof value == 'object') ? toString.call(value) == argsClass : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == argsClass || false; } // fallback for browsers that can't detect `arguments` objects by [[Class]] if (!support.argsClass) { isArguments = function(value) { - return (value && typeof value == 'object') ? hasOwnProperty.call(value, 'callee') : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + hasOwnProperty.call(value, 'callee') || false; }; } @@ -1761,7 +1789,8 @@ * // => true */ var isArray = nativeIsArray || function(value) { - return (value && typeof value == 'object') ? toString.call(value) == arrayClass : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == arrayClass || false; }; /** @@ -1929,7 +1958,7 @@ * @memberOf _ * @category Objects * @param {*} value The value to clone. - * @param {boolean} [deep=false] A flag to indicate a deep clone. + * @param {boolean} [deep=false] Specify a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the cloned `value`. @@ -3563,10 +3592,11 @@ } /** - * Retrieves the maximum value of an array. If a callback is provided it - * will be executed for each value in the array to generate the criterion by - * which the value is ranked. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the maximum value of a collection. If the collection is empty or + * falsey `-Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style * callback will return the property value of the given element. @@ -3632,10 +3662,11 @@ } /** - * Retrieves the minimum value of an array. If a callback is provided it - * will be executed for each value in the array to generate the criterion by - * which the value is ranked. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the minimum value of a collection. If the collection is empty or + * falsey `Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style * callback will return the property value of the given element. @@ -4091,16 +4122,16 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Object} properties The object of property values to filter by. - * @returns {Array} Returns a new array of elements that have the given `properties`. + * @returns {Array} Returns a new array of elements that have the given properties. * @example * * var stooges = [ * { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - * { 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] } + * { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } * ]; * * _.where(stooges, { 'age': 40 }); - * // => [{ 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] }] + * // => [{ 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] }] * * _.where(stooges, { 'quotes': ['Poifect!'] }); * // => [{ 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }] @@ -5252,7 +5283,7 @@ */ function compose() { var funcs = arguments, - length = funcs.length || 1; + length = funcs.length; while (length--) { if (!isFunction(funcs[length])) { @@ -5519,7 +5550,7 @@ return setTimeout(function() { func.apply(undefined, args); }, 1); } // use `setImmediate` if available in Node.js - if (isV8 && freeModule && typeof setImmediate == 'function') { + if (isV8 && moduleExports && typeof setImmediate == 'function') { defer = function(func) { if (!isFunction(func)) { throw new TypeError; @@ -5884,7 +5915,7 @@ } /** - * Converts the given `value` into an integer of the specified `radix`. + * Converts the given value into an integer of the specified radix. * If `radix` is `undefined` or `0` a `radix` of `10` is used unless the * `value` is a hexadecimal, in which case a `radix` of `16` is used. * @@ -5910,35 +5941,56 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one * argument is provided a number between `0` and the given number will be - * returned. + * returned. If `floating` is truey or either `min` or `max` are floats a + * floating-point number will be returned instead of an integer. * * @static * @memberOf _ * @category Utilities * @param {number} [min=0] The minimum possible value. * @param {number} [max=1] The maximum possible value. + * @param {boolean} [floating=false] Specify returning a floating-point number. * @returns {number} Returns a random number. * @example * * _.random(0, 5); - * // => a number between 0 and 5 + * // => an integer between 0 and 5 * * _.random(5); - * // => also a number between 0 and 5 + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 */ - function random(min, max) { - if (min == null && max == null) { + function random(min, max, floating) { + var noMin = min == null, + noMax = max == null; + + if (floating == null) { + if (typeof min == 'boolean' && noMax) { + floating = min; + min = 1; + } + else if (!noMax && typeof max == 'boolean') { + floating = max; + noMax = true; + } + } + if (noMin && noMax) { max = 1; } min = +min || 0; - if (max == null) { + if (noMax) { max = min; min = 0; } else { max = +max || 0; } var rand = nativeRandom(); - return (min % 1 || max % 1) + return (floating || min % 1 || max % 1) ? min + nativeMin(rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1))), max) : min + floor(rand * (max - min + 1)); } @@ -6037,8 +6089,8 @@ * // => 'hello mustache!' * * // using the `imports` option to import jQuery - * var list = '<% $.each(people, function(name) { %>
  • <%= name %>
  • <% }); %>'; - * _.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery }); + * var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; + * _.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery } }); * // => '
  • moe
  • larry
  • ' * * // using the `sourceURL` option to specify a custom sourceURL for the template @@ -6156,7 +6208,7 @@ if (data) { return result(data); } - // provide the compiled function's source via its `toString` method, in + // provide the compiled function's source by its `toString` method, in // supported environments, or the `source` property as a convenience for // inlining compiled templates during the build process result.source = source; @@ -6241,7 +6293,7 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps the given `value`. + * Creates a `lodash` object that wraps the given value. * * @static * @memberOf _ @@ -6542,7 +6594,7 @@ * @memberOf _ * @type string */ - lodash.VERSION = '2.0.0'; + lodash.VERSION = '2.1.0'; // add "Chaining" functions to the wrapper lodash.prototype.chain = wrapperChain; @@ -6615,7 +6667,7 @@ // Expose Lo-Dash to the global object even when an AMD loader is present in // case Lo-Dash was injected by a third-party script and not intended to be // loaded as a module. The global assignment can be reverted in the Lo-Dash - // module via its `noConflict()` method. + // module by its `noConflict()` method. root._ = _; // define as an anonymous module so, through path mapping, it can be @@ -6625,12 +6677,12 @@ }); } // check for `exports` after `define` in case a build optimizer adds an `exports` object - else if (freeExports && !freeExports.nodeType) { - // in Node.js or RingoJS v0.8.0+ - if (freeModule) { + else if (freeExports && freeModule) { + // in Node.js or RingoJS + if (moduleExports) { (freeModule.exports = _)._ = _; } - // in Narwhal or RingoJS v0.7.0- + // in Narwhal or Rhino -require else { freeExports._ = _; } diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index a5c67058a5..087902f062 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -1,56 +1,56 @@ /** * @license - * Lo-Dash 2.0.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE + * Lo-Dash 2.1.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE * Build: `lodash -o ./dist/lodash.compat.js` */ -;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++er||typeof e=="undefined")return 1;if(er||typeof e=="undefined")return 1;if(ee?0:e);++r=w&&l===n,h=u||g?i():c;if(g){var v=o(h);v?(l=t,h=v):(g=!1,h=u?h:(p(h),c))}for(;++al(h,y))&&((u||g)&&h.push(y),c.push(v))}return g?(p(h.b),s(h)):u&&p(h),c}function ut(n){return function(t,e,r){var u={};if(e=y.createCallback(e,r,3),qe(t)){r=-1;for(var o=t.length;++r=w&&l===n,h=u||g?i():c;if(g){var v=o(h);v?(l=t,h=v):(g=!1,h=u?h:(p(h),c))}for(;++al(h,y))&&((u||g)&&h.push(y),c.push(v))}return g?(p(h.b),s(h)):u&&p(h),c}function ut(n){return function(t,e,r){var u={}; +if(e=y.createCallback(e,r,3),qe(t)){r=-1;for(var o=t.length;++rk;k++)r+="n='"+n.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",n.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+n.g+"}"; -r+="}"}return(n.b||Le.nonEnumArgs)&&(r+="}"),r+=n.c+";return E",t=t("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",e+r+"}"),s(n),t(Q,K,oe,ve,_,st,qe,_t,n.f,ae,V,ze,H,ie,we)}function it(n){return mt(n)?Ce(n):{}}function lt(n){return He[n]}function ft(){var t=(t=y.indexOf)===Rt?n:t;return t}function ct(n){var t,e;return!n||we.call(n)!=J||(t=n.constructor,yt(t)&&!(t instanceof t))||!Le.argsClass&&st(n)||!Le.nodeClass&&f(n)?!1:Le.ownLast?(nr(n,function(n,t,r){return e=ve.call(r,t),!1}),false!==e):(nr(n,function(n,t){e=t -}),typeof e=="undefined"||ve.call(n,e))}function pt(n){return Ue[n]}function st(n){return n&&typeof n=="object"?we.call(n)==z:!1}function gt(n,t,e){var r=We(n),u=r.length;for(t=Q(t,e,3);u--&&(e=r[u],false!==t(n[e],e,n)););return n}function ht(n){var t=[];return nr(n,function(n,e){yt(n)&&t.push(e)}),t.sort()}function vt(n){for(var t=-1,e=We(n),r=e.length,u={};++te?Ie(0,o+e):e)||0,qe(n)?a=-1o&&(o=i)}}else t=!t&&_t(n)?r:y.createCallback(t,e,3),Xe(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function At(n,t,e,r){var u=3>arguments.length;if(t=Q(t,r,4),qe(n)){var o=-1,a=n.length;for(u&&(e=n[++o]);++oarguments.length;return t=Q(t,r,4),Et(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function Bt(n){var t=-1,e=n?n.length:0,r=Ut(typeof e=="number"?e:0); -return Ct(n,function(n){var e=Mt(++t);r[t]=r[e],r[e]=n}),r}function Nt(n,t,e){var r;if(t=y.createCallback(t,e,3),qe(n)){e=-1;for(var u=n.length;++e=w&&u===n;if(f){var c=o(i);c?(u=t,i=c):f=!1}for(;++ru(i,c)&&l.push(c);return f&&s(i),l}function Pt(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=y.createCallback(t,e,3);++or?Ie(0,u+r):r||0}else if(r)return r=$t(t,e),t[r]===e?r:-1;return n(t,e,r)}function Ft(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=y.createCallback(t,e,3);++u>>1,e(n[r])e?Ie(0,o+e):e)||0,qe(n)?a=-1o&&(o=i)}}else t=!t&&bt(n)?r:y.createCallback(t,e,3),Xe(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function At(n,t,e,r){var u=3>arguments.length;if(t=Q(t,r,4),qe(n)){var o=-1,a=n.length;for(u&&(e=n[++o]);++oarguments.length;return t=Q(t,r,4),Et(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function Nt(n){var t=-1,e=n?n.length:0,r=Ut(typeof e=="number"?e:0); +return Ct(n,function(n){var e=Mt(++t);r[t]=r[e],r[e]=n}),r}function Bt(n,t,e){var r;if(t=y.createCallback(t,e,3),qe(n)){e=-1;for(var u=n.length;++e=w&&u===n;if(f){var c=o(i);c?(u=t,i=c):f=!1}for(;++ru(i,c)&&l.push(c);return f&&s(i),l}function Pt(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=y.createCallback(t,e,3);++or?Ie(0,u+r):r||0}else if(r)return r=$t(t,e),t[r]===e?r:-1;return n(t,e,r)}function Ft(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=y.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:B,variable:"",imports:{_:y}},Ce||(it=function(n){if(mt(n)){c.prototype=n;var t=new c;c.prototype=null}return t||{}});var Te=ke?function(n,t){var e=l();e.value=t,ke(n,"__bindData__",e),s(e)}:c;Le.argsClass||(st=function(n){return n&&typeof n=="object"?ve.call(n,"callee"):!1});var qe=Ee||function(n){return n&&typeof n=="object"?we.call(n)==L:!1 +}function u(){var e=t-(new Qt-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:y}},Ce||(it=function(n){if(mt(n)){c.prototype=n;var t=new c;c.prototype=null}return t||{}});var Te=xe?function(n,t){var e=l();e.value=t,xe(n,"__bindData__",e),s(e)}:c;Le.argsClass||(st=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ve.call(n,"callee")||!1});var qe=Ee||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&we.call(n)==L||!1 },Ke=at({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),We=Ae?function(n){return mt(n)?Le.enumPrototypes&&typeof n=="function"||Le.nonEnumArgs&&n.length&&st(n)?Ke(n):Ae(n):[]}:Ke,Ge={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:We,g:"if(e(t[n],n,g)===false)return E"},Je={a:"z,H,l",i:"var a=arguments,b=0,c=typeof l=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Ue=vt(He),Ve=te("("+We(Ue).join("|")+")","g"),Qe=te("["+We(He).join("")+"]","g"),Xe=at(Ge),Ye=at(Je,{i:Je.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),Ze=at(Je),nr=at(Ge,Me,{j:!1}),tr=at(Ge,Me); -yt(/x/)&&(yt=function(n){return typeof n=="function"&&we.call(n)==W});var er=he?function(n){if(!n||we.call(n)!=J||!Le.argsClass&&st(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=he(t))&&he(e);return e?n==e||he(n)==e:ct(n)}:ct,rr=ut(function(n,t,e){ve.call(n,e)?n[e]++:n[e]=1}),ur=ut(function(n,t,e){(ve.call(n,e)?n[e]:n[e]=[]).push(t)}),or=ut(function(n,t,e){n[e]=t}),ar=Ot;Fe&&Z&&typeof de=="function"&&(Wt=function(n){if(!yt(n))throw new re;return de.apply(e,arguments)});var ir=8==Ne(x+"08")?Ne:function(n,t){return Ne(_t(n)?n.replace(N,""):n,t||0) -};return y.after=function(n,t){if(!yt(t))throw new re;return function(){return 1>--n?t.apply(this,arguments):void 0}},y.assign=Ye,y.at=function(n){var t=arguments,e=-1,r=Y(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Ut(t);for(Le.unindexedChars&&_t(n)&&(n=n.split(""));++e=w&&o(a?r[a]:v)}n:for(;++f(m?t(m,y):c(v,y))){for(a=u,(m||v).push(y);--a;)if(m=l[a],0>(m?t(m,y):c(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=l[u])&&s(m);return p(l),p(v),h},y.invert=vt,y.invoke=function(n,t){var e=Pe.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Ut(typeof o=="number"?o:0);return Ct(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},y.keys=We,y.map=Ot,y.max=St,y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):b+arguments[0]; -return ve.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!yt(n))throw new re;return e.cache={},e},y.merge=function(n){var t=arguments,e=2;if(!mt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3--n?t.apply(this,arguments):void 0}},y.assign=Ye,y.at=function(n){var t=arguments,e=-1,r=Y(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Ut(t);for(Le.unindexedChars&&bt(n)&&(n=n.split(""));++e=w&&o(a?r[a]:v)}n:for(;++f(m?t(m,y):c(v,y))){for(a=u,(m||v).push(y);--a;)if(m=l[a],0>(m?t(m,y):c(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=l[u])&&s(m);return p(l),p(v),h},y.invert=vt,y.invoke=function(n,t){var e=Pe.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Ut(typeof o=="number"?o:0);return Ct(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},y.keys=We,y.map=Ot,y.max=St,y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):_+arguments[0]; +return ve.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!yt(n))throw new re;return e.cache={},e},y.merge=function(n){var t=arguments,e=2;if(!mt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},y.once=function(n){var t,e;if(!yt(n))throw new re;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},y.pairs=function(n){for(var t=-1,e=We(n),r=e.length,u=Ut(r);++te?Ie(0,r+e):Be(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},y.mixin=Jt,y.noConflict=function(){return e._=le,this},y.parseInt=ir,y.random=Mt,y.reduce=At,y.reduceRight=It,y.result=function(n,t){if(n){var e=n[t];return yt(e)?n[t]():e}},y.runInContext=h,y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:We(n).length},y.some=Nt,y.sortedIndex=$t,y.template=function(n,t,e){var r=y.templateSettings; -n||(n=""),e=Ze({},e,r);var u,o=Ze({},e.imports,r.imports),r=We(o),o=bt(o),i=0,l=e.interpolate||D,f="__p+='",l=te((e.escape||D).source+"|"+l.source+"|"+(l===B?S:D).source+"|"+(e.evaluate||D).source+"|$","g");n.replace(l,function(t,e,r,o,l,c){return r||(r=o),f+=n.slice(i,c).replace(R,a),e&&(f+="'+__e("+e+")+'"),l&&(u=!0,f+="';"+l+";__p+='"),r&&(f+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),f+="';\n",l=e=e.variable,l||(e="obj",f="with("+e+"){"+f+"}"),f=(u?f.replace(C,""):f).replace(E,"$1").replace(O,"$1;"),f="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}"; -try{var c=Xt(r,"return "+f).apply(v,o)}catch(p){throw p.source=f,p}return t?c(t):(c.source=f,c)},y.unescape=function(n){return null==n?"":ee(n).replace(Ve,pt)},y.uniqueId=function(n){var t=++d;return ee(null==n?"":n)+t},y.all=jt,y.any=Nt,y.detect=xt,y.findWhere=xt,y.foldl=At,y.foldr=It,y.include=wt,y.inject=At,tr(y,function(n,t){y.prototype[t]||(y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return ye.apply(t,arguments),t=n.apply(y,t),e?new m(t,e):t})}),y.first=Pt,y.last=function(n,t,e){var r=0,u=n?n.length:0; -if(typeof t!="number"&&null!=t){var o=u;for(t=y.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:v;return g(n,Ie(0,u-r))},y.sample=function(n,t,e){var r=n?n.length:0;return typeof r!="number"?n=bt(n):Le.unindexedChars&&_t(n)&&(n=n.split("")),null==t||e?n?n[Mt(r-1)]:v:(n=Bt(n),n.length=Be(Ie(0,t),n.length),n)},y.take=Pt,y.head=Pt,tr(y,function(n,t){var e="sample"!==t;y.prototype[t]||(y.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new m(o,u):o -})}),y.VERSION="2.0.0",y.prototype.chain=function(){return this.__chain__=!0,this},y.prototype.toString=function(){return ee(this.__wrapped__)},y.prototype.value=Ht,y.prototype.valueOf=Ht,Xe(["join","pop","shift"],function(n){var t=ue[n];y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new m(e,n):e}}),Xe(["push","reverse","sort","unshift"],function(n){var t=ue[n];y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Xe(["concat","slice","splice"],function(n){var t=ue[n]; -y.prototype[n]=function(){return new m(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Le.spliceObjects||Xe(["pop","shift","splice"],function(n){var t=ue[n],e="splice"==n;y.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments);return 0===r.length&&delete r[0],n||e?new m(u,n):u}}),y}var v,y=[],m=[],d=0,_={},b=+new Date+"",w=75,j=40,x=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",C=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,O=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,I=/^function[ \n\r\t]+\w/,B=/<%=([\s\S]+?)%>/g,N=RegExp("^["+x+"]*0+(?=.$)"),D=/($^)/,P=(P=/\bthis\b/)&&P.test(h)&&P,R=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),$="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),z="[object Arguments]",L="[object Array]",T="[object Boolean]",q="[object Date]",K="[object Error]",W="[object Function]",G="[object Number]",J="[object Object]",M="[object RegExp]",H="[object String]",U={}; -U[W]=!1,U[z]=U[L]=U[T]=U[q]=U[G]=U[J]=U[M]=U[H]=!0;var V={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Q={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},X=V[typeof window]&&window||this,Y=V[typeof exports]&&exports,Z=V[typeof module]&&module&&module.exports==Y&&module,nt=V[typeof global]&&global;!nt||nt.global!==nt&&nt.window!==nt||(X=nt);var tt=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(X._=tt, define(function(){return tt -})):Y&&!Y.nodeType?Z?(Z.exports=tt)._=tt:Y._=tt:X._=tt}).call(this); \ No newline at end of file +},y.isEmpty=function(n){var t=!0;if(!n)return t;var e=we.call(n),r=n.length;return e==L||e==H||(Le.argsClass?e==z:st(n))||e==J&&typeof r=="number"&&yt(n.splice)?!r:(tr(n,function(){return t=!1}),t)},y.isEqual=function(n,t,e,r){return Z(n,t,typeof e=="function"&&Q(e,r,2))},y.isFinite=function(n){return Oe(n)&&!Se(parseFloat(n))},y.isFunction=yt,y.isNaN=function(n){return dt(n)&&n!=+n},y.isNull=function(n){return null===n},y.isNumber=dt,y.isObject=mt,y.isPlainObject=er,y.isRegExp=function(n){return n&&V[typeof n]?we.call(n)==M:!1 +},y.isString=bt,y.isUndefined=function(n){return typeof n=="undefined"},y.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?Ie(0,r+e):Ne(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},y.mixin=Jt,y.noConflict=function(){return e._=le,this},y.parseInt=ir,y.random=Mt,y.reduce=At,y.reduceRight=It,y.result=function(n,t){if(n){var e=n[t];return yt(e)?n[t]():e}},y.runInContext=h,y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:We(n).length},y.some=Bt,y.sortedIndex=$t,y.template=function(n,t,e){var r=y.templateSettings; +n||(n=""),e=Ze({},e,r);var u,o=Ze({},e.imports,r.imports),r=We(o),o=_t(o),i=0,l=e.interpolate||D,f="__p+='",l=te((e.escape||D).source+"|"+l.source+"|"+(l===N?S:D).source+"|"+(e.evaluate||D).source+"|$","g");n.replace(l,function(t,e,r,o,l,c){return r||(r=o),f+=n.slice(i,c).replace(R,a),e&&(f+="'+__e("+e+")+'"),l&&(u=!0,f+="';"+l+";__p+='"),r&&(f+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),f+="';\n",l=e=e.variable,l||(e="obj",f="with("+e+"){"+f+"}"),f=(u?f.replace(C,""):f).replace(E,"$1").replace(O,"$1;"),f="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}"; +try{var c=Xt(r,"return "+f).apply(v,o)}catch(p){throw p.source=f,p}return t?c(t):(c.source=f,c)},y.unescape=function(n){return null==n?"":ee(n).replace(Ve,pt)},y.uniqueId=function(n){var t=++d;return ee(null==n?"":n)+t},y.all=jt,y.any=Bt,y.detect=kt,y.findWhere=kt,y.foldl=At,y.foldr=It,y.include=wt,y.inject=At,tr(y,function(n,t){y.prototype[t]||(y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return ye.apply(t,arguments),t=n.apply(y,t),e?new m(t,e):t})}),y.first=Pt,y.last=function(n,t,e){var r=0,u=n?n.length:0; +if(typeof t!="number"&&null!=t){var o=u;for(t=y.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:v;return g(n,Ie(0,u-r))},y.sample=function(n,t,e){var r=n?n.length:0;return typeof r!="number"?n=_t(n):Le.unindexedChars&&bt(n)&&(n=n.split("")),null==t||e?n?n[Mt(r-1)]:v:(n=Nt(n),n.length=Ne(Ie(0,t),n.length),n)},y.take=Pt,y.head=Pt,tr(y,function(n,t){var e="sample"!==t;y.prototype[t]||(y.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new m(o,u):o +})}),y.VERSION="2.1.0",y.prototype.chain=function(){return this.__chain__=!0,this},y.prototype.toString=function(){return ee(this.__wrapped__)},y.prototype.value=Ht,y.prototype.valueOf=Ht,Xe(["join","pop","shift"],function(n){var t=ue[n];y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new m(e,n):e}}),Xe(["push","reverse","sort","unshift"],function(n){var t=ue[n];y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Xe(["concat","slice","splice"],function(n){var t=ue[n]; +y.prototype[n]=function(){return new m(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Le.spliceObjects||Xe(["pop","shift","splice"],function(n){var t=ue[n],e="splice"==n;y.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments);return 0===r.length&&delete r[0],n||e?new m(u,n):u}}),y}var v,y=[],m=[],d=0,b={},_=+new Date+"",w=75,j=40,x=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",C=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,O=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,I=/^function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,B=RegExp("^["+x+"]*0+(?=.$)"),D=/($^)/,P=/\bthis\b/,R=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),$="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),z="[object Arguments]",L="[object Array]",T="[object Boolean]",q="[object Date]",K="[object Error]",W="[object Function]",G="[object Number]",J="[object Object]",M="[object RegExp]",H="[object String]",U={}; +U[W]=!1,U[z]=U[L]=U[T]=U[q]=U[G]=U[J]=U[M]=U[H]=!0;var V={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Q={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},X=V[typeof window]&&window||this,Y=V[typeof exports]&&exports&&!exports.nodeType&&exports,Z=V[typeof module]&&module&&!module.nodeType&&module,nt=Z&&Z.exports===Y&&Y,tt=V[typeof global]&&global;!tt||tt.global!==tt&&tt.window!==tt||(X=tt);var et=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(X._=et, define(function(){return et +})):Y&&Z?nt?(Z.exports=et)._=et:Y._=et:X._=et}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 387923c217..fe73c4486b 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.0.0 (Custom Build) + * Lo-Dash 2.1.0 (Custom Build) * Build: `lodash modern -o ./dist/lodash.js` * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.5.2 @@ -67,7 +67,7 @@ var reNoMatch = /($^)/; /** Used to detect functions containing a `this` reference */ - var reThis = (reThis = /\bthis\b/) && reThis.test(runInContext) && reThis; + var reThis = /\bthis\b/; /** Used to match unescaped characters in compiled string literals */ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; @@ -126,10 +126,13 @@ var root = (objectTypes[typeof window] && window) || this; /** Detect free variable `exports` */ - var freeExports = objectTypes[typeof exports] && exports; + var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; /** Detect free variable `module` */ - var freeModule = objectTypes[typeof module] && module && module.exports == freeExports && module; + var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; + + /** Detect the popular CommonJS extension `module.exports` */ + var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ var freeGlobal = objectTypes[typeof global] && global; @@ -189,7 +192,7 @@ } /** - * Adds a given `value` to the corresponding cache object. + * Adds a given value to the corresponding cache object. * * @private * @param {*} value The value to add to the cache. @@ -268,9 +271,11 @@ var index = -1, length = array.length, first = array[0], + mid = array[(length / 2) | 0], last = array[length - 1]; - if (first && typeof first == 'object' && last && typeof last == 'object') { + if (first && typeof first == 'object' && + mid && typeof mid == 'object' && last && typeof last == 'object') { return false; } var cache = getObject(); @@ -409,7 +414,7 @@ /*--------------------------------------------------------------------------*/ /** - * Create a new `lodash` function using the given `context` object. + * Create a new `lodash` function using the given context object. * * @static * @memberOf _ @@ -612,6 +617,15 @@ */ support.fastBind = nativeBind && !isV8; + /** + * Detect if functions can be decompiled by `Function#toString` + * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps). + * + * @memberOf _.support + * @type boolean + */ + support.funcDecomp = !reNative.test(context.WinRTError) && reThis.test(runInContext); + /** * Detect if `Function#name` is supported (all but IE). * @@ -689,7 +703,7 @@ * * @private * @param {*} value The value to clone. - * @param {boolean} [deep=false] A flag to indicate a deep clone. + * @param {boolean} [deep=false] Specify a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {Array} [stackA=[]] Tracks traversed source objects. * @param {Array} [stackB=[]] Associates clones with source counterparts. @@ -799,7 +813,7 @@ } if (support.funcNames || !bindData) { // checks if `func` references the `this` keyword and stores the result - bindData = !reThis || reThis.test(source); + bindData = !support.funcDecomp || reThis.test(source); setBindData(func, bindData); } } @@ -842,9 +856,21 @@ while (++index < length) { var value = array[index]; - // recursively flatten arrays (susceptible to call stack limits) - if (value && typeof value == 'object' && (isArray(value) || isArguments(value))) { - push.apply(result, isShallow ? value : baseFlatten(value, isShallow, isArgArrays)); + + if (value && typeof value == 'object' && typeof value.length == 'number' + && (isArray(value) || isArguments(value))) { + // recursively flatten arrays (susceptible to call stack limits) + if (!isShallow) { + value = baseFlatten(value, isShallow, isArgArrays); + } + var valIndex = -1, + valLength = value.length, + resIndex = result.length; + + result.length += valLength; + while (++valIndex < valLength) { + result[resIndex++] = value[valIndex]; + } } else if (!isArgArrays) { result.push(value); } @@ -1325,7 +1351,7 @@ * @param {Function} func The function to set data on. * @param {*} value The value to set. */ - var setBindData = function(func, value) { + var setBindData = !defineProperty ? noop : function(func, value) { var descriptor = getObject(); descriptor.value = value; defineProperty(func, '__bindData__', descriptor); @@ -1390,7 +1416,8 @@ * // => false */ function isArguments(value) { - return (value && typeof value == 'object') ? toString.call(value) == argsClass : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == argsClass || false; } /** @@ -1411,7 +1438,8 @@ * // => true */ var isArray = nativeIsArray || function(value) { - return (value && typeof value == 'object') ? toString.call(value) == arrayClass : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == arrayClass || false; }; /** @@ -1548,7 +1576,7 @@ * @memberOf _ * @category Objects * @param {*} value The value to clone. - * @param {boolean} [deep=false] A flag to indicate a deep clone. + * @param {boolean} [deep=false] Specify a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the cloned `value`. @@ -3209,10 +3237,11 @@ } /** - * Retrieves the maximum value of an array. If a callback is provided it - * will be executed for each value in the array to generate the criterion by - * which the value is ranked. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the maximum value of a collection. If the collection is empty or + * falsey `-Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style * callback will return the property value of the given element. @@ -3278,10 +3307,11 @@ } /** - * Retrieves the minimum value of an array. If a callback is provided it - * will be executed for each value in the array to generate the criterion by - * which the value is ranked. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the minimum value of a collection. If the collection is empty or + * falsey `Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style * callback will return the property value of the given element. @@ -3745,16 +3775,16 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Object} properties The object of property values to filter by. - * @returns {Array} Returns a new array of elements that have the given `properties`. + * @returns {Array} Returns a new array of elements that have the given properties. * @example * * var stooges = [ * { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - * { 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] } + * { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } * ]; * * _.where(stooges, { 'age': 40 }); - * // => [{ 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] }] + * // => [{ 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] }] * * _.where(stooges, { 'quotes': ['Poifect!'] }); * // => [{ 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }] @@ -4906,7 +4936,7 @@ */ function compose() { var funcs = arguments, - length = funcs.length || 1; + length = funcs.length; while (length--) { if (!isFunction(funcs[length])) { @@ -5173,7 +5203,7 @@ return setTimeout(function() { func.apply(undefined, args); }, 1); } // use `setImmediate` if available in Node.js - if (isV8 && freeModule && typeof setImmediate == 'function') { + if (isV8 && moduleExports && typeof setImmediate == 'function') { defer = function(func) { if (!isFunction(func)) { throw new TypeError; @@ -5538,7 +5568,7 @@ } /** - * Converts the given `value` into an integer of the specified `radix`. + * Converts the given value into an integer of the specified radix. * If `radix` is `undefined` or `0` a `radix` of `10` is used unless the * `value` is a hexadecimal, in which case a `radix` of `16` is used. * @@ -5564,35 +5594,56 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one * argument is provided a number between `0` and the given number will be - * returned. + * returned. If `floating` is truey or either `min` or `max` are floats a + * floating-point number will be returned instead of an integer. * * @static * @memberOf _ * @category Utilities * @param {number} [min=0] The minimum possible value. * @param {number} [max=1] The maximum possible value. + * @param {boolean} [floating=false] Specify returning a floating-point number. * @returns {number} Returns a random number. * @example * * _.random(0, 5); - * // => a number between 0 and 5 + * // => an integer between 0 and 5 * * _.random(5); - * // => also a number between 0 and 5 + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 */ - function random(min, max) { - if (min == null && max == null) { + function random(min, max, floating) { + var noMin = min == null, + noMax = max == null; + + if (floating == null) { + if (typeof min == 'boolean' && noMax) { + floating = min; + min = 1; + } + else if (!noMax && typeof max == 'boolean') { + floating = max; + noMax = true; + } + } + if (noMin && noMax) { max = 1; } min = +min || 0; - if (max == null) { + if (noMax) { max = min; min = 0; } else { max = +max || 0; } var rand = nativeRandom(); - return (min % 1 || max % 1) + return (floating || min % 1 || max % 1) ? min + nativeMin(rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1))), max) : min + floor(rand * (max - min + 1)); } @@ -5691,8 +5742,8 @@ * // => 'hello mustache!' * * // using the `imports` option to import jQuery - * var list = '<% $.each(people, function(name) { %>
  • <%= name %>
  • <% }); %>'; - * _.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery }); + * var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; + * _.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery } }); * // => '
  • moe
  • larry
  • ' * * // using the `sourceURL` option to specify a custom sourceURL for the template @@ -5810,7 +5861,7 @@ if (data) { return result(data); } - // provide the compiled function's source via its `toString` method, in + // provide the compiled function's source by its `toString` method, in // supported environments, or the `source` property as a convenience for // inlining compiled templates during the build process result.source = source; @@ -5895,7 +5946,7 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps the given `value`. + * Creates a `lodash` object that wraps the given value. * * @static * @memberOf _ @@ -6196,7 +6247,7 @@ * @memberOf _ * @type string */ - lodash.VERSION = '2.0.0'; + lodash.VERSION = '2.1.0'; // add "Chaining" functions to the wrapper lodash.prototype.chain = wrapperChain; @@ -6247,7 +6298,7 @@ // Expose Lo-Dash to the global object even when an AMD loader is present in // case Lo-Dash was injected by a third-party script and not intended to be // loaded as a module. The global assignment can be reverted in the Lo-Dash - // module via its `noConflict()` method. + // module by its `noConflict()` method. root._ = _; // define as an anonymous module so, through path mapping, it can be @@ -6257,12 +6308,12 @@ }); } // check for `exports` after `define` in case a build optimizer adds an `exports` object - else if (freeExports && !freeExports.nodeType) { - // in Node.js or RingoJS v0.8.0+ - if (freeModule) { + else if (freeExports && freeModule) { + // in Node.js or RingoJS + if (moduleExports) { (freeModule.exports = _)._ = _; } - // in Narwhal or RingoJS v0.7.0- + // in Narwhal or Rhino -require else { freeExports._ = _; } diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 2a26444b23..48fc3e3285 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -1,52 +1,52 @@ /** * @license - * Lo-Dash 2.0.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE + * Lo-Dash 2.1.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE * Build: `lodash modern -o ./dist/lodash.js` */ -;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++er||typeof e=="undefined")return 1;if(ee?0:e);++r=_&&f===n,h=u||v?i():s;if(v){var g=o(h);g?(f=t,h=g):(v=!1,h=u?h:(l(h),s))}for(;++af(h,y))&&((u||v)&&h.push(y),s.push(g))}return v?(l(h.b),c(h)):u&&l(h),s}function ot(n){return function(t,e,r){var u={};e=X.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++re?Ee(0,o+e):e)||0,Te(n)?a=-1o&&(o=i)}}else t=!t&&_t(n)?r:X.createCallback(t,e,3),xt(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function Et(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Ht(r);++earguments.length;t=nt(t,r,4);var o=-1,a=n.length;if(typeof a=="number")for(u&&(e=n[++o]);++oarguments.length;return t=nt(t,r,4),Ct(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function At(n){var t=-1,e=n?n.length:0,r=Ht(typeof e=="number"?e:0);return xt(n,function(n){var e=Vt(++t);r[t]=r[e],r[e]=n}),r}function Rt(n,t,e){var r;t=X.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e=_&&u===n; -if(l){var p=o(i);p?(u=t,i=p):l=!1}for(;++ru(i,p)&&f.push(p);return l&&c(i),f}function $t(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=X.createCallback(t,e,3);++or?Ee(0,u+r):r||0}else if(r)return r=Tt(t,e),t[r]===e?r:-1;return n(t,e,r)}function Ft(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0; -for(t=X.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:X}};var Te=xe||function(n){return n&&typeof n=="object"?be.call(n)==$:!1},ze=Ne?function(n){return yt(n)?Ne(n):[]}:H,qe={"&":"&","<":"<",">":">",'"':""","'":"'"},We=ht(qe),Pe=te("("+ze(We).join("|")+")","g"),Ke=te("["+ze(qe).join("")+"]","g"),Le=ot(function(n,t,e){ve.call(n,e)?n[e]++:n[e]=1}),Me=ot(function(n,t,e){(ve.call(n,e)?n[e]:n[e]=[]).push(t) -}),Ue=ot(function(n,t,e){n[e]=t});$e&&G&&typeof ye=="function"&&(Lt=function(n){if(!gt(n))throw new re;return ye.apply(e,arguments)});var Ve=8==Se(d+"08")?Se:function(n,t){return Se(_t(n)?n.replace(E,""):n,t||0)};return X.after=function(n,t){if(!gt(t))throw new re;return function(){return 1>--n?t.apply(this,arguments):void 0}},X.assign=V,X.at=function(n){for(var t=arguments,e=-1,r=tt(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Ht(t);++e=_&&o(a?r[a]:g)}n:for(;++p(m?t(m,y):s(g,y))){for(a=u,(m||g).push(y);--a;)if(m=f[a],0>(m?t(m,y):s(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=f[u])&&c(m);return l(f),l(g),h},X.invert=ht,X.invoke=function(n,t){var e=Re.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Ht(typeof o=="number"?o:0); -return xt(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},X.keys=ze,X.map=Ot,X.max=Nt,X.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):m+arguments[0];return ve.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!gt(n))throw new re;return e.cache={},e},X.merge=function(n){var t=arguments,e=2;if(!yt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},X.once=function(n){var t,e;if(!gt(n))throw new re;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e) -}},X.pairs=function(n){for(var t=-1,e=ze(n),r=e.length,u=Ht(r);++te?Ee(0,r+e):Ie(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},X.mixin=Ut,X.noConflict=function(){return e._=ae,this},X.parseInt=Ve,X.random=Vt,X.reduce=It,X.reduceRight=St,X.result=function(n,t){if(n){var e=n[t];return gt(e)?n[t]():e}},X.runInContext=s,X.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ze(n).length},X.some=Rt,X.sortedIndex=Tt,X.template=function(n,t,e){var r=X.templateSettings; -n||(n=""),e=M({},e,r);var u,o=M({},e.imports,r.imports),r=ze(o),o=bt(o),i=0,f=e.interpolate||I,l="__p+='",f=te((e.escape||I).source+"|"+f.source+"|"+(f===N?x:I).source+"|"+(e.evaluate||I).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(i,c).replace(A,a),e&&(l+="'+__e("+e+")+'"),f&&(u=!0,l+="';"+f+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),l+="';\n",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(w,""):l).replace(j,"$1").replace(k,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}"; -try{var c=Xt(r,"return "+l).apply(v,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},X.unescape=function(n){return null==n?"":ee(n).replace(Pe,ct)},X.uniqueId=function(n){var t=++y;return ee(null==n?"":n)+t},X.all=wt,X.any=Rt,X.detect=kt,X.findWhere=kt,X.foldl=It,X.foldr=St,X.include=dt,X.inject=It,g(X,function(n,t){X.prototype[t]||(X.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return ge.apply(t,arguments),t=n.apply(X,t),e?new Y(t,e):t})}),X.first=$t,X.last=function(n,t,e){var r=0,u=n?n.length:0; -if(typeof t!="number"&&null!=t){var o=u;for(t=X.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:v;return p(n,Ee(0,u-r))},X.sample=function(n,t,e){var r=n?n.length:0;return typeof r!="number"&&(n=bt(n)),null==t||e?n?n[Vt(r-1)]:v:(n=At(n),n.length=Ie(Ee(0,t),n.length),n)},X.take=$t,X.head=$t,g(X,function(n,t){var e="sample"!==t;X.prototype[t]||(X.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new Y(o,u):o -})}),X.VERSION="2.0.0",X.prototype.chain=function(){return this.__chain__=!0,this},X.prototype.toString=function(){return ee(this.__wrapped__)},X.prototype.value=Gt,X.prototype.valueOf=Gt,xt(["join","pop","shift"],function(n){var t=ue[n];X.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new Y(e,n):e}}),xt(["push","reverse","sort","unshift"],function(n){var t=ue[n];X.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),xt(["concat","slice","splice"],function(n){var t=ue[n]; -X.prototype[n]=function(){return new Y(t.apply(this.__wrapped__,arguments),this.__chain__)}}),X}var v,h=[],g=[],y=0,m=+new Date+"",_=75,b=40,d=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",w=/\b__p\+='';/g,j=/\b(__p\+=)''\+/g,k=/(__e\(.*?\)|\b__t\))\+'';/g,x=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,C=/\w*$/,O=/^function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,E=RegExp("^["+d+"]*0+(?=.$)"),I=/($^)/,S=(S=/\bthis\b/)&&S.test(s)&&S,A=/['\n\r\t\u2028\u2029\\]/g,R="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),B="[object Arguments]",$="[object Array]",D="[object Boolean]",F="[object Date]",T="[object Function]",z="[object Number]",q="[object Object]",W="[object RegExp]",P="[object String]",K={}; -K[T]=!1,K[B]=K[$]=K[D]=K[F]=K[z]=K[q]=K[W]=K[P]=!0;var L={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},M={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},U=L[typeof window]&&window||this,V=L[typeof exports]&&exports,G=L[typeof module]&&module&&module.exports==V&&module,H=L[typeof global]&&global;!H||H.global!==H&&H.window!==H||(U=H);var J=s();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(U._=J, define(function(){return J -})):V&&!V.nodeType?G?(G.exports=J)._=J:V._=J:U._=J}).call(this); \ No newline at end of file +;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++er||typeof e=="undefined")return 1;if(ee?0:e);++r=_&&f===n,h=u||v?i():s;if(v){var g=o(h);g?(f=t,h=g):(v=!1,h=u?h:(c(h),s))}for(;++af(h,y))&&((u||v)&&h.push(y),s.push(g))}return v?(c(h.b),p(h)):u&&c(h),s}function ot(n){return function(t,e,r){var u={};e=Q.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++re?Ee(0,o+e):e)||0,ze(n)?a=-1o&&(o=i)}}else t=!t&&bt(n)?r:Q.createCallback(t,e,3),xt(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function Et(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Ht(r);++earguments.length;t=nt(t,r,4);var o=-1,a=n.length;if(typeof a=="number")for(u&&(e=n[++o]);++oarguments.length;return t=nt(t,r,4),Ct(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function Rt(n){var t=-1,e=n?n.length:0,r=Ht(typeof e=="number"?e:0);return xt(n,function(n){var e=Vt(++t);r[t]=r[e],r[e]=n}),r}function At(n,t,e){var r;t=Q.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e=_&&u===n; +if(l){var c=o(i);c?(u=t,i=c):l=!1}for(;++ru(i,c)&&f.push(c);return l&&p(i),f}function Bt(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=Q.createCallback(t,e,3);++or?Ee(0,u+r):r||0}else if(r)return r=Tt(t,e),t[r]===e?r:-1;return n(t,e,r)}function Ft(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0; +for(t=Q.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:E,variable:"",imports:{_:Q}};var Te=we?function(n,t){var e=f();e.value=t,we(n,"__bindData__",e),p(e)}:l,ze=xe||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&_e.call(n)==$||!1},We=Ne?function(n){return yt(n)?Ne(n):[]}:H,qe={"&":"&","<":"<",">":">",'"':""","'":"'"},Pe=ht(qe),Ke=te("("+We(Pe).join("|")+")","g"),Le=te("["+We(qe).join("")+"]","g"),Me=ot(function(n,t,e){ve.call(n,e)?n[e]++:n[e]=1 +}),Ue=ot(function(n,t,e){(ve.call(n,e)?n[e]:n[e]=[]).push(t)}),Ve=ot(function(n,t,e){n[e]=t});Be&&J&&typeof ye=="function"&&(Lt=function(n){if(!gt(n))throw new re;return ye.apply(e,arguments)});var Ge=8==Se(w+"08")?Se:function(n,t){return Se(bt(n)?n.replace(I,""):n,t||0)};return Q.after=function(n,t){if(!gt(t))throw new re;return function(){return 1>--n?t.apply(this,arguments):void 0}},Q.assign=G,Q.at=function(n){for(var t=arguments,e=-1,r=tt(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Ht(t);++e=_&&o(a?r[a]:g)}n:for(;++l(m?t(m,y):s(g,y))){for(a=u,(m||g).push(y);--a;)if(m=f[a],0>(m?t(m,y):s(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=f[u])&&p(m);return c(f),c(g),h},Q.invert=ht,Q.invoke=function(n,t){var e=Ae.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Ht(typeof o=="number"?o:0); +return xt(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},Q.keys=We,Q.map=Ot,Q.max=Nt,Q.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):b+arguments[0];return ve.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!gt(n))throw new re;return e.cache={},e},Q.merge=function(n){var t=arguments,e=2;if(!yt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},Q.once=function(n){var t,e;if(!gt(n))throw new re;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e) +}},Q.pairs=function(n){for(var t=-1,e=We(n),r=e.length,u=Ht(r);++te?Ee(0,r+e):Ie(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Q.mixin=Ut,Q.noConflict=function(){return e._=ae,this},Q.parseInt=Ge,Q.random=Vt,Q.reduce=It,Q.reduceRight=St,Q.result=function(n,t){if(n){var e=n[t];return gt(e)?n[t]():e}},Q.runInContext=v,Q.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:We(n).length},Q.some=At,Q.sortedIndex=Tt,Q.template=function(n,t,e){var r=Q.templateSettings; +n||(n=""),e=U({},e,r);var u,o=U({},e.imports,r.imports),r=We(o),o=_t(o),i=0,f=e.interpolate||S,l="__p+='",f=te((e.escape||S).source+"|"+f.source+"|"+(f===E?C:S).source+"|"+(e.evaluate||S).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(i,c).replace(A,a),e&&(l+="'+__e("+e+")+'"),f&&(u=!0,l+="';"+f+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),l+="';\n",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(j,""):l).replace(k,"$1").replace(x,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}"; +try{var c=Xt(r,"return "+l).apply(h,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},Q.unescape=function(n){return null==n?"":ee(n).replace(Ke,ct)},Q.uniqueId=function(n){var t=++m;return ee(null==n?"":n)+t},Q.all=wt,Q.any=At,Q.detect=kt,Q.findWhere=kt,Q.foldl=It,Q.foldr=St,Q.include=dt,Q.inject=It,y(Q,function(n,t){Q.prototype[t]||(Q.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return ge.apply(t,arguments),t=n.apply(Q,t),e?new Y(t,e):t})}),Q.first=Bt,Q.last=function(n,t,e){var r=0,u=n?n.length:0; +if(typeof t!="number"&&null!=t){var o=u;for(t=Q.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:h;return s(n,Ee(0,u-r))},Q.sample=function(n,t,e){var r=n?n.length:0;return typeof r!="number"&&(n=_t(n)),null==t||e?n?n[Vt(r-1)]:h:(n=Rt(n),n.length=Ie(Ee(0,t),n.length),n)},Q.take=Bt,Q.head=Bt,y(Q,function(n,t){var e="sample"!==t;Q.prototype[t]||(Q.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new Y(o,u):o +})}),Q.VERSION="2.1.0",Q.prototype.chain=function(){return this.__chain__=!0,this},Q.prototype.toString=function(){return ee(this.__wrapped__)},Q.prototype.value=Gt,Q.prototype.valueOf=Gt,xt(["join","pop","shift"],function(n){var t=ue[n];Q.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new Y(e,n):e}}),xt(["push","reverse","sort","unshift"],function(n){var t=ue[n];Q.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),xt(["concat","slice","splice"],function(n){var t=ue[n]; +Q.prototype[n]=function(){return new Y(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Q}var h,g=[],y=[],m=0,b=+new Date+"",_=75,d=40,w=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",j=/\b__p\+='';/g,k=/\b(__p\+=)''\+/g,x=/(__e\(.*?\)|\b__t\))\+'';/g,C=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,O=/\w*$/,N=/^function[ \n\r\t]+\w/,E=/<%=([\s\S]+?)%>/g,I=RegExp("^["+w+"]*0+(?=.$)"),S=/($^)/,R=/\bthis\b/,A=/['\n\r\t\u2028\u2029\\]/g,D="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),B="[object Arguments]",$="[object Array]",F="[object Boolean]",T="[object Date]",z="[object Function]",W="[object Number]",q="[object Object]",P="[object RegExp]",K="[object String]",L={}; +L[z]=!1,L[B]=L[$]=L[F]=L[T]=L[W]=L[q]=L[P]=L[K]=!0;var M={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},U={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},V=M[typeof window]&&window||this,G=M[typeof exports]&&exports&&!exports.nodeType&&exports,H=M[typeof module]&&module&&!module.nodeType&&module,J=H&&H.exports===G&&G,Q=M[typeof global]&&global;!Q||Q.global!==Q&&Q.window!==Q||(V=Q);var X=v();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(V._=X, define(function(){return X +})):G&&H?J?(H.exports=X)._=X:G._=X:V._=X}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index fb649427bf..2bc17ca12e 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.0.0 (Custom Build) + * Lo-Dash 2.1.0 (Custom Build) * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.5.2 @@ -27,6 +27,9 @@ /** Used to ensure capturing order of template delimiters */ var reNoMatch = /($^)/; + /** Used to detect functions containing a `this` reference */ + var reThis = /\bthis\b/; + /** Used to match unescaped characters in compiled string literals */ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; @@ -66,10 +69,13 @@ var root = (objectTypes[typeof window] && window) || this; /** Detect free variable `exports` */ - var freeExports = objectTypes[typeof exports] && exports; + var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; /** Detect free variable `module` */ - var freeModule = objectTypes[typeof module] && module && module.exports == freeExports && module; + var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; + + /** Detect the popular CommonJS extension `module.exports` */ + var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ var freeGlobal = objectTypes[typeof global] && global; @@ -304,6 +310,15 @@ */ support.fastBind = nativeBind && !isV8; + /** + * Detect if functions can be decompiled by `Function#toString` + * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps). + * + * @memberOf _.support + * @type boolean + */ + support.funcDecomp = !reNative.test(root.WinRTError) && reThis.test(function() { return this; }); + /** * Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. * @@ -418,9 +433,21 @@ while (++index < length) { var value = array[index]; - // recursively flatten arrays (susceptible to call stack limits) - if (value && typeof value == 'object' && (isArray(value) || isArguments(value))) { - push.apply(result, isShallow ? value : baseFlatten(value, isShallow, isArgArrays)); + + if (value && typeof value == 'object' && typeof value.length == 'number' + && (isArray(value) || isArguments(value))) { + // recursively flatten arrays (susceptible to call stack limits) + if (!isShallow) { + value = baseFlatten(value, isShallow, isArgArrays); + } + var valIndex = -1, + valLength = value.length, + resIndex = result.length; + + result.length += valLength; + while (++valIndex < valLength) { + result[resIndex++] = value[valIndex]; + } } else if (!isArgArrays) { result.push(value); } @@ -773,12 +800,14 @@ * // => false */ function isArguments(value) { - return (value && typeof value == 'object') ? toString.call(value) == argsClass : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == argsClass || false; } // fallback for browsers that can't detect `arguments` objects by [[Class]] if (!isArguments(arguments)) { isArguments = function(value) { - return (value && typeof value == 'object') ? hasOwnProperty.call(value, 'callee') : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + hasOwnProperty.call(value, 'callee') || false; }; } @@ -800,7 +829,8 @@ * // => true */ var isArray = nativeIsArray || function(value) { - return (value && typeof value == 'object') ? toString.call(value) == arrayClass : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == arrayClass || false; }; /** @@ -925,7 +955,7 @@ * @memberOf _ * @category Objects * @param {*} value The value to clone. - * @param {boolean} [deep=false] A flag to indicate a deep clone. + * @param {boolean} [deep=false] Specify a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the cloned `value`. @@ -1882,7 +1912,7 @@ /** * Examines each element in a `collection`, returning the first that - * has the given `properties`. When checking `properties`, this method + * has the given properties. When checking `properties`, this method * performs a deep comparison between values to determine if they are * equivalent to each other. * @@ -2156,10 +2186,11 @@ } /** - * Retrieves the maximum value of an array. If a callback is provided it - * will be executed for each value in the array to generate the criterion by - * which the value is ranked. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the maximum value of a collection. If the collection is empty or + * falsey `-Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style * callback will return the property value of the given element. @@ -2223,10 +2254,11 @@ } /** - * Retrieves the minimum value of an array. If a callback is provided it - * will be executed for each value in the array to generate the criterion by - * which the value is ranked. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the minimum value of a collection. If the collection is empty or + * falsey `Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style * callback will return the property value of the given element. @@ -2690,16 +2722,16 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Object} properties The object of property values to filter by. - * @returns {Array} Returns a new array of elements that have the given `properties`. + * @returns {Array} Returns a new array of elements that have the given properties. * @example * * var stooges = [ * { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - * { 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] } + * { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } * ]; * * _.where(stooges, { 'age': 40 }); - * // => [{ 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] }] + * // => [{ 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] }] * * _.where(stooges, { 'quotes': ['Poifect!'] }); * // => [{ 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }] @@ -3621,7 +3653,7 @@ */ function compose() { var funcs = arguments, - length = funcs.length || 1; + length = funcs.length; while (length--) { if (!isFunction(funcs[length])) { @@ -4154,21 +4186,29 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one * argument is provided a number between `0` and the given number will be - * returned. + * returned. If `floating` is truey or either `min` or `max` are floats a + * floating-point number will be returned instead of an integer. * * @static * @memberOf _ * @category Utilities * @param {number} [min=0] The minimum possible value. * @param {number} [max=1] The maximum possible value. + * @param {boolean} [floating=false] Specify returning a floating-point number. * @returns {number} Returns a random number. * @example * * _.random(0, 5); - * // => a number between 0 and 5 + * // => an integer between 0 and 5 * * _.random(5); - * // => also a number between 0 and 5 + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 */ function random(min, max) { if (min == null && max == null) { @@ -4181,10 +4221,7 @@ } else { max = +max || 0; } - var rand = nativeRandom(); - return (min % 1 || max % 1) - ? min + nativeMin(rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1))), max) - : min + floor(rand * (max - min + 1)); + return min + floor(nativeRandom() * (max - min + 1)); } /** @@ -4281,8 +4318,8 @@ * // => 'hello mustache!' * * // using the `imports` option to import jQuery - * var list = '<% $.each(people, function(name) { %>
  • <%= name %>
  • <% }); %>'; - * _.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery }); + * var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; + * _.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery } }); * // => '
  • moe
  • larry
  • ' * * // using the `sourceURL` option to specify a custom sourceURL for the template @@ -4441,7 +4478,7 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps the given `value`. + * Creates a `lodash` object that wraps the given value. * * @static * @memberOf _ @@ -4670,7 +4707,7 @@ * @memberOf _ * @type string */ - lodash.VERSION = '2.0.0'; + lodash.VERSION = '2.1.0'; // add "Chaining" functions to the wrapper lodash.prototype.chain = wrapperChain; @@ -4714,7 +4751,7 @@ // Expose Lo-Dash to the global object even when an AMD loader is present in // case Lo-Dash was injected by a third-party script and not intended to be // loaded as a module. The global assignment can be reverted in the Lo-Dash - // module via its `noConflict()` method. + // module by its `noConflict()` method. root._ = lodash; // define as an anonymous module so, through path mapping, it can be @@ -4724,12 +4761,12 @@ }); } // check for `exports` after `define` in case a build optimizer adds an `exports` object - else if (freeExports && !freeExports.nodeType) { - // in Node.js or RingoJS v0.8.0+ - if (freeModule) { + else if (freeExports && freeModule) { + // in Node.js or RingoJS + if (moduleExports) { (freeModule.exports = lodash)._ = lodash; } - // in Narwhal or RingoJS v0.7.0- + // in Narwhal or Rhino -require else { freeExports._ = lodash; } diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index baf18d1067..3a75350752 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -1,37 +1,38 @@ /** * @license - * Lo-Dash 2.0.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE + * Lo-Dash 2.1.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` */ -;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined")return 1;if(tu(f,l))&&(t&&f.push(l),i.push(a))}return i}function c(n){return function(r,t,e){var u={};t=K(t,e,3),e=-1;var o=r?r.length:0;if(typeof o=="number")for(;++ee&&(e=t,u=n)});else for(;++ou&&(u=t);return u}function q(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++targuments.length;r=i(r,e,4); -var o=-1,f=n.length;if(typeof f=="number")for(u&&(t=n[++o]);++oarguments.length;return r=i(r,e,4),D(n,function(n,e,o){t=u?(u=!1,n):r(t,n,e,o)}),t}function I(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return R(n,function(n){var t=Y(++r);e[r]=e[t],e[t]=n}),e}function W(n,r,t){var e;r=K(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++tt(u,i)&&o.push(i)}return o}function P(n,r,t){var e=0,u=n?n.length:0;if(typeof r!="number"&&null!=r){var o=-1;for(r=K(r,t,3);++oe?qr(0,u+e):e||0}else if(e)return e=G(r,t),r[e]===t?e:-1;return n(r,t,e) -}function V(n,r,t){if(typeof r!="number"&&null!=r){var e=0,u=-1,o=n?n.length:0;for(r=K(r,t,3);++u>>1,t(n[e])/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Nr||(s=function(n){if(x(n)){e.prototype=n;var r=new e;e.prototype=null}return r||{}}),y(arguments)||(y=function(n){return n&&typeof n=="object"?Ar.call(n,"callee"):!1});var Pr=Rr||function(n){return n&&typeof n=="object"?Or.call(n)==ir:!1},Ur=function(n){var r,t=[]; -if(!n||!vr[typeof n])return t;for(r in n)Ar.call(n,r)&&t.push(r);return t},Vr=kr?function(n){return x(n)?kr(n):[]}:Ur,Gr={"&":"&","<":"<",">":">",'"':""","'":"'"},Hr=b(Gr),Jr=RegExp("("+Vr(Hr).join("|")+")","g"),Kr=RegExp("["+Vr(Gr).join("")+"]","g"),Lr=function(n,r){var t;if(!n||!vr[typeof n])return n;for(t in n)if(r(n[t],t,n)===rr)break;return n},Qr=function(n,r){var t;if(!n||!vr[typeof n])return n;for(t in n)if(Ar.call(n,t)&&r(n[t],t,n)===rr)break;return n};j(/x/)&&(j=function(n){return typeof n=="function"&&"[object Function]"==Or.call(n) -});var Xr=c(function(n,r,t){Ar.call(n,t)?n[t]++:n[t]=1}),Yr=c(function(n,r,t){(Ar.call(n,t)?n[t]:n[t]=[]).push(r)}),Zr=c(function(n,r,t){n[t]=r});u.after=function(n,r){if(!j(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=J,u.bindAll=function(n){for(var r=1u(i,f)){for(var a=t;--a;)if(0>u(r[a],f))continue n;i.push(f)}}return i},u.invert=b,u.invoke=function(n,r){var t=Ir.call(arguments,2),e=-1,u=typeof r=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); -return R(n,function(n){i[++e]=(u?r:n[r]).apply(n,t)}),i},u.keys=Vr,u.map=F,u.max=k,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):tr+arguments[0];return Ar.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var e=1/0,u=e,o=-1,i=n?n.length:0;if(r||typeof i!="number")r=K(r,t,3),R(n,function(n,t,o){t=r(n,t,o),tr(t,u)&&(e[u]=n) -}),e},u.once=function(n){var r,t;if(!j(n))throw new TypeError;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},u.pairs=function(n){for(var r=-1,t=Vr(n),e=t.length,u=Array(e);++rr?0:r);++nt?qr(0,e+t):Mr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=X,u.noConflict=function(){return gr._=wr,this},u.random=Y,u.reduce=M,u.reduceRight=$,u.result=function(n,r){if(n){var t=n[r];return j(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Vr(n).length},u.some=W,u.sortedIndex=G,u.template=function(n,r,e){var o=u,i=o.templateSettings;n||(n=""),e=_({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||er).source+"|"+(e.interpolate||er).source+"|"+(e.evaluate||er).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(ur,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r -}),a+="';\n",i||(i="obj",a="with("+i+"||{}){"+a+"}"),a="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";try{var l=Function("_","return "+a)(o)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Jr,g)},u.uniqueId=function(n){var r=++nr+"";return n?n+r:r},u.all=S,u.any=W,u.detect=N,u.findWhere=function(n,r){return z(n,r,!0)},u.foldl=M,u.foldr=$,u.include=O,u.inject=M,u.first=P,u.last=function(n,r,t){var e=0,u=n?n.length:0; -if(typeof r!="number"&&null!=r){var o=u;for(r=K(r,t,3);o--&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n?n[u-1]:Z;return Ir.call(n,qr(0,u-e))},u.sample=function(n,r,t){var e=n?n.length:0;return typeof e!="number"&&(n=T(n)),null==r||t?n?n[Y(e-1)]:Z:(n=I(n),n.length=Mr(qr(0,r),n.length),n)},u.take=P,u.head=P,X(u),u.VERSION="2.0.0",u.prototype.chain=function(){return this.__chain__=!0,this},u.prototype.value=function(){return this.__wrapped__},R("pop push reverse shift sort splice unshift".split(" "),function(n){var r=dr[n]; -u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Cr.spliceObjects||0!==n.length||delete n[0],this}}),R(["concat","join","slice"],function(n){var r=dr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(gr._=u, define(function(){return u})):yr&&!yr.nodeType?mr?(mr.exports=u)._=u:yr._=u:gr._=u}).call(this); \ No newline at end of file +;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined")return 1;if(tu(f,l))&&(t&&f.push(l),i.push(a))}return i}function c(n){return function(r,t,e){var u={};t=K(t,e,3),e=-1;var o=r?r.length:0; +if(typeof o=="number")for(;++ee&&(e=t,u=n)});else for(;++ou&&(u=t);return u}function q(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++targuments.length;r=i(r,e,4);var o=-1,f=n.length;if(typeof f=="number")for(u&&(t=n[++o]);++oarguments.length;return r=i(r,e,4),N(n,function(n,e,o){t=u?(u=!1,n):r(t,n,e,o)}),t}function $(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return D(n,function(n){var t=Y(++r);e[r]=e[t],e[t]=n}),e}function I(n,r,t){var e;r=K(r,t,3),t=-1; +var u=n?n.length:0;if(typeof u=="number")for(;++tt(u,i)&&o.push(i)}return o}function P(n,r,t){var e=0,u=n?n.length:0;if(typeof r!="number"&&null!=r){var o=-1;for(r=K(r,t,3);++oe?Wr(0,u+e):e||0}else if(e)return e=G(r,t),r[e]===t?e:-1;return n(r,t,e)}function V(n,r,t){if(typeof r!="number"&&null!=r){var e=0,u=-1,o=n?n.length:0;for(r=K(r,t,3);++u>>1,t(n[e])/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Nr||(s=function(n){if(x(n)){e.prototype=n;var r=new e;e.prototype=null}return r||{}}),y(arguments)||(y=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Or.call(n,"callee")||!1 +});var Vr=kr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Sr.call(n)==fr||!1},Gr=function(n){var r,t=[];if(!n||!vr[typeof n])return t;for(r in n)Or.call(n,r)&&t.push(r);return t},Hr=Mr?function(n){return x(n)?Mr(n):[]}:Gr,Jr={"&":"&","<":"<",">":">",'"':""","'":"'"},Kr=b(Jr),Lr=RegExp("("+Hr(Kr).join("|")+")","g"),Qr=RegExp("["+Hr(Jr).join("")+"]","g"),Xr=function(n,r){var t;if(!n||!vr[typeof n])return n;for(t in n)if(r(n[t],t,n)===rr)break;return n},Yr=function(n,r){var t; +if(!n||!vr[typeof n])return n;for(t in n)if(Or.call(n,t)&&r(n[t],t,n)===rr)break;return n};j(/x/)&&(j=function(n){return typeof n=="function"&&"[object Function]"==Sr.call(n)});var Zr=c(function(n,r,t){Or.call(n,t)?n[t]++:n[t]=1}),nt=c(function(n,r,t){(Or.call(n,t)?n[t]:n[t]=[]).push(r)}),rt=c(function(n,r,t){n[t]=r});u.after=function(n,r){if(!j(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=J,u.bindAll=function(n){for(var r=1u(i,f)){for(var a=t;--a;)if(0>u(r[a],f))continue n;i.push(f)}}return i},u.invert=b,u.invoke=function(n,r){var t=zr.call(arguments,2),e=-1,u=typeof r=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return D(n,function(n){i[++e]=(u?r:n[r]).apply(n,t)}),i},u.keys=Hr,u.map=k,u.max=F,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):tr+arguments[0];return Or.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var e=1/0,u=e,o=-1,i=n?n.length:0; +if(r||typeof i!="number")r=K(r,t,3),D(n,function(n,t,o){t=r(n,t,o),tr(t,u)&&(e[u]=n)}),e},u.once=function(n){var r,t;if(!j(n))throw new TypeError;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},u.pairs=function(n){for(var r=-1,t=Hr(n),e=t.length,u=Array(e);++rr?0:r);++nt?Wr(0,e+t):$r(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=X,u.noConflict=function(){return yr._=xr,this},u.random=Y,u.reduce=M,u.reduceRight=W,u.result=function(n,r){if(n){var t=n[r];return j(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0; +return typeof r=="number"?r:Hr(n).length},u.some=I,u.sortedIndex=G,u.template=function(n,r,e){var o=u,i=o.templateSettings;n||(n=""),e=_({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||er).source+"|"+(e.interpolate||er).source+"|"+(e.evaluate||er).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(or,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r}),a+="';\n",i||(i="obj",a="with("+i+"||{}){"+a+"}"),a="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}"; +try{var l=Function("_","return "+a)(o)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Lr,g)},u.uniqueId=function(n){var r=++nr+"";return n?n+r:r},u.all=R,u.any=I,u.detect=B,u.findWhere=function(n,r){return z(n,r,!0)},u.foldl=M,u.foldr=W,u.include=O,u.inject=M,u.first=P,u.last=function(n,r,t){var e=0,u=n?n.length:0;if(typeof r!="number"&&null!=r){var o=u;for(r=K(r,t,3);o--&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n?n[u-1]:Z; +return zr.call(n,Wr(0,u-e))},u.sample=function(n,r,t){var e=n?n.length:0;return typeof e!="number"&&(n=A(n)),null==r||t?n?n[Y(e-1)]:Z:(n=$(n),n.length=$r(Wr(0,r),n.length),n)},u.take=P,u.head=P,X(u),u.VERSION="2.1.0",u.prototype.chain=function(){return this.__chain__=!0,this},u.prototype.value=function(){return this.__wrapped__},D("pop push reverse shift sort splice unshift".split(" "),function(n){var r=wr[n];u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Ur.spliceObjects||0!==n.length||delete n[0],this +}}),D(["concat","join","slice"],function(n){var r=wr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(yr._=u, define(function(){return u})):mr&&_r?dr?(_r.exports=u)._=u:mr._=u:yr._=u}).call(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 50bfcd1265..80cf5e1ba7 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# Lo-Dash v2.0.0 +# Lo-Dash v2.1.0 @@ -107,14 +107,14 @@ * [`_.compose`](#_composefunc) * [`_.createCallback`](#_createcallbackfuncidentity--thisarg--argcount) * [`_.curry`](#_curryfunc--arityfunclength) -* [`_.debounce`](#_debouncefunc-wait--options--optionsleadingfalse--optionsmaxwait--optionstrailingtrue) +* [`_.debounce`](#_debouncefunc-wait--options--optionsmaxwait) * [`_.defer`](#_deferfunc--arg) * [`_.delay`](#_delayfunc-wait--arg) * [`_.memoize`](#_memoizefunc--resolver) * [`_.once`](#_oncefunc) * [`_.partial`](#_partialfunc--arg) * [`_.partialRight`](#_partialrightfunc--arg) -* [`_.throttle`](#_throttlefunc-wait--options--optionsleadingtrue--optionstrailingtrue) +* [`_.throttle`](#_throttlefunc-wait--options) * [`_.wrap`](#_wrapvalue-wrapper) @@ -174,7 +174,7 @@ * [`_.mixin`](#_mixinobject-object) * [`_.noConflict`](#_noconflict) * [`_.parseInt`](#_parseintvalue--radix) -* [`_.random`](#_randommin0--max1) +* [`_.random`](#_randommin0--max1--floatingfalse) * [`_.result`](#_resultobject-property) * [`_.runInContext`](#_runincontextcontextroot) * [`_.template`](#_templatetext-data--options--optionsescape--optionsevaluate--optionsimports--optionsinterpolate--sourceurl--variable) @@ -203,6 +203,7 @@ * [`_.support.enumErrorProps`](#_supportenumerrorprops) * [`_.support.enumPrototypes`](#_supportenumprototypes) * [`_.support.fastBind`](#_supportfastbind) +* [`_.support.funcDecomp`](#_supportfuncdecomp) * [`_.support.funcNames`](#_supportfuncnames) * [`_.support.nonEnumArgs`](#_supportnonenumargs) * [`_.support.nonEnumShadows`](#_supportnonenumshadows) @@ -232,7 +233,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4146 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4176 "View in source") [Ⓣ][1] Creates an array with all falsey values removed. The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are all falsey. @@ -256,7 +257,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array, [array])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4175 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4205 "View in source") [Ⓣ][1] Creates an array excluding all values of the provided arrays using strict equality for comparisons, i.e. `===`. @@ -281,7 +282,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.findIndex(array, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4225 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4255 "View in source") [Ⓣ][1] This method is like `_.find` except that it returns the index of the first element that passes the callback check, instead of the element itself. @@ -309,7 +310,7 @@ _.findIndex(['apple', 'banana', 'beet'], function(food) { ### `_.findLastIndex(array, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4288 "View in source") [Ⓣ][1] This method is like `_.findIndex` except that it iterates over elements of a `collection` from right to left. @@ -337,7 +338,7 @@ _.findLastIndex(['apple', 'banana', 'beet'], function(food) { ### `_.first(array, [callback], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4325 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4355 "View in source") [Ⓣ][1] Gets the first element or first `n` elements of an array. If a callback is provided elements at the beginning of the array are returned as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -397,7 +398,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array, [isShallow=false], [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4385 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4415 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truey, the array will only be flattened a single level. If a callback is provided each element of the array is passed through the callback before flattening. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -440,7 +441,7 @@ _.flatten(stooges, 'quotes'); ### `_.indexOf(array, value, [fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4422 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4452 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the array is already sorted providing `true` for `fromIndex` will run a faster binary search. @@ -472,7 +473,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array, [callback=1], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4488 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4518 "View in source") [Ⓣ][1] Gets all but the last element or last `n` elements of an array. If a callback is provided elements at the end of the array are excluded from the result as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -529,7 +530,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4518 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4548 "View in source") [Ⓣ][1] Creates an array of unique values present in all provided arrays using strict equality for comparisons, i.e. `===`. @@ -553,7 +554,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array, [callback], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4618 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4648 "View in source") [Ⓣ][1] Gets the last element or last `n` elements of an array. If a callback is provided elements at the end of the array are returned as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -610,7 +611,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value, [fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4657 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4687 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -639,7 +640,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.pull(array, [value])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4687 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4717 "View in source") [Ⓣ][1] Removes all provided values from the given array using strict equality for comparisons, i.e. `===`. @@ -666,7 +667,7 @@ console.log(array); ### `_.range([start=0], end, [step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4768 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. If `start` is less than `stop` a zero-length range is created unless a negative `step` is specified. @@ -707,7 +708,7 @@ _.range(0); ### `_.remove(array, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4791 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4821 "View in source") [Ⓣ][1] Removes all elements from an array that the callback returns truey for and returns an array of removed elements. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -743,7 +744,7 @@ console.log(evens); ### `_.rest(array, [callback=1], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4865 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4895 "View in source") [Ⓣ][1] The opposite of `_.initial` this method gets all but the first element or first `n` elements of an array. If a callback function is provided elements at the beginning of the array are excluded from the result as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -803,7 +804,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4929 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4959 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which a value should be inserted into a given sorted array in order to maintain the sort order of the array. If a callback is provided it will be executed for `value` and each element of `array` to compute their sort ranking. The callback is bound to `thisArg` and invoked with one argument; *(value)*. @@ -852,7 +853,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4960 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4990 "View in source") [Ⓣ][1] Creates an array of unique values, in order, of the provided arrays using strict equality for comparisons, i.e. `===`. @@ -876,7 +877,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array, [isSorted=false], [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5008 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5038 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of an array using strict equality for comparisons, i.e. `===`. If the array is sorted, providing `true` for `isSorted` will use a faster algorithm. If a callback is provided each element of `array` is passed through the callback before uniqueness is computed. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -923,7 +924,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.without(array, [value])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5036 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5066 "View in source") [Ⓣ][1] Creates an array excluding all provided values using strict equality for comparisons, i.e. `===`. @@ -948,7 +949,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5056 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5086 "View in source") [Ⓣ][1] Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. @@ -975,7 +976,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_.zipObject(keys, [values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5086 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5116 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Provide either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` or two arrays, one of `keys` and one of corresponding `values`. @@ -1010,7 +1011,7 @@ _.zipObject(['moe', 'larry'], [30, 40]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L631 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L636 "View in source") [Ⓣ][1] Creates a `lodash` object which wraps the given value to enable method chaining. @@ -1063,9 +1064,9 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6285 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6336 "View in source") [Ⓣ][1] -Creates a `lodash` object that wraps the given `value`. +Creates a `lodash` object that wraps the given value. #### Arguments 1. `value` *(\*)*: The value to wrap. @@ -1096,7 +1097,7 @@ var youngest = _.chain(stooges) ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6313 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6364 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument and then returns `value`. The purpose of this method is to "tap into" a method chain in order to perform operations on intermediate results within the chain. @@ -1126,7 +1127,7 @@ _([1, 2, 3, 4]) ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6333 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6384 "View in source") [Ⓣ][1] Enables method chaining on the wrapper object. @@ -1150,7 +1151,7 @@ var sum = _([1, 2, 3]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6350 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6401 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1171,7 +1172,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6367 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6418 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1202,7 +1203,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection, [index])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3002 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3030 "View in source") [Ⓣ][1] Creates an array of elements from the specified indexes, or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -1230,7 +1231,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target, [fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3045 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3073 "View in source") [Ⓣ][1] Checks if a given value is present in a collection using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -1268,7 +1269,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3100 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3128 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of `collection` through the callback. The corresponding value of each key is the number of times the key was returned by the callback. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1304,7 +1305,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3173 "View in source") [Ⓣ][1] Checks if the given callback returns truey value for **all** elements of a collection. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1350,7 +1351,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3206 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3234 "View in source") [Ⓣ][1] Iterates over elements of a collection, returning an array of all elements the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1396,7 +1397,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3273 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3301 "View in source") [Ⓣ][1] Iterates over elements of a collection, returning the first element that the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1445,7 +1446,7 @@ _.find(food, 'organic'); ### `_.findLast(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3318 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3346 "View in source") [Ⓣ][1] This method is like `_.find` except that it iterates over elements of a `collection` from right to left. @@ -1473,7 +1474,7 @@ _.findLast([1, 2, 3, 4], function(num) { ### `_.forEach(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3352 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3380 "View in source") [Ⓣ][1] Iterates over elements of a collection, executing the callback for each element. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1505,7 +1506,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); ### `_.forEachRight(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3385 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3413 "View in source") [Ⓣ][1] This method is like `_.forEach` except that it iterates over elements of a `collection` from right to left. @@ -1534,7 +1535,7 @@ _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); ### `_.groupBy(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3446 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3474 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of a collection through the callback. The corresponding value of each key is an array of the elements responsible for generating the key. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1571,7 +1572,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.indexBy(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3489 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3517 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of the collection through the given callback. The corresponding value of each key is the last element responsible for generating the key. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1612,7 +1613,7 @@ _.indexBy(stooges, function(key) { this.fromCharCode(key.code); }, String); ### `_.invoke(collection, methodName, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3515 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3543 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection` returning an array of the results of each invoked method. Additional arguments will be provided to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1641,7 +1642,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3567 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3595 "View in source") [Ⓣ][1] Creates an array of values by running each element in the collection through the callback. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1686,9 +1687,9 @@ _.map(stooges, 'name'); ### `_.max(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3653 "View in source") [Ⓣ][1] -Retrieves the maximum value of an array. If a callback is provided it will be executed for each value in the array to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. +Retrieves the maximum value of a collection. If the collection is empty or falsey `-Infinity` is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element. @@ -1728,9 +1729,9 @@ _.max(stooges, 'age'); ### `_.min(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3693 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3723 "View in source") [Ⓣ][1] -Retrieves the minimum value of an array. If a callback is provided it will be executed for each value in the array to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. +Retrieves the minimum value of a collection. If the collection is empty or falsey `Infinity` is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. If a property name is provided for `callback` the created "_.pluck" style callback will return the property value of the given element. @@ -1770,7 +1771,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3743 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3773 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1800,7 +1801,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection, [callback=identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3775 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3805 "View in source") [Ⓣ][1] Reduces a collection to a value which is the accumulated result of running each element in the collection through the callback, where each successive callback execution consumes the return value of the previous execution. If `accumulator` is not provided the first element of the collection will be used as the initial `accumulator` value. The callback is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. @@ -1838,7 +1839,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { ### `_.reduceRight(collection, [callback=identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3818 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3848 "View in source") [Ⓣ][1] This method is like `_.reduce` except that it iterates over elements of a `collection` from right to left. @@ -1869,7 +1870,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3867 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3897 "View in source") [Ⓣ][1] The opposite of `_.filter` this method returns the elements of a collection that the callback does **not** return truey for. @@ -1912,7 +1913,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.sample(collection, [n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3923 "View in source") [Ⓣ][1] Retrieves a random element or `n` random elements from a collection. @@ -1940,7 +1941,7 @@ _.sample([1, 2, 3, 4], 2); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3922 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3952 "View in source") [Ⓣ][1] Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1964,7 +1965,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3955 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L3985 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1994,7 +1995,7 @@ _.size('curly'); ### `_.some(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4002 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4032 "View in source") [Ⓣ][1] Checks if the callback returns a truey value for **any** element of a collection. The function returns as soon as it finds a passing value and does not iterate over the entire collection. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -2040,7 +2041,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4058 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4088 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in a collection through the callback. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -2077,7 +2078,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4094 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4124 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -2101,7 +2102,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4128 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L4158 "View in source") [Ⓣ][1] Performs a deep comparison of each element in a `collection` to the given `properties` object, returning an array of all elements that have equivalent property values. @@ -2110,17 +2111,17 @@ Performs a deep comparison of each element in a `collection` to the given `prope 2. `properties` *(Object)*: The object of property values to filter by. #### Returns -*(Array)*: Returns a new array of elements that have the given `properties`. +*(Array)*: Returns a new array of elements that have the given properties. #### Example ```js var stooges = [ { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - { 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] } + { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } ]; _.where(stooges, { 'age': 40 }); -// => [{ 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] }] +// => [{ 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] }] _.where(stooges, { 'quotes': ['Poifect!'] }); // => [{ 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }] @@ -2141,7 +2142,7 @@ _.where(stooges, { 'quotes': ['Poifect!'] }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5128 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5158 "View in source") [Ⓣ][1] Creates a function that executes `func`, with the `this` binding and arguments of the created function, only after being called `n` times. @@ -2174,7 +2175,7 @@ _.forEach(saves, function(type) { ### `_.bind(func, [thisArg], [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5161 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5191 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those provided to the bound function. @@ -2205,7 +2206,7 @@ func(); ### `_.bindAll(object, [methodName])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5221 "View in source") [Ⓣ][1] Binds methods of an object to the object itself, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided all the function properties of `object` will be bound. @@ -2236,7 +2237,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5237 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5267 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those provided to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -2277,7 +2278,7 @@ func(); ### `_.compose([func])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5273 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5303 "View in source") [Ⓣ][1] Creates a function that is the composition of the provided functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -2315,7 +2316,7 @@ welcome('curly'); ### `_.createCallback([func=identity], [thisArg], [argCount])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5324 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5354 "View in source") [Ⓣ][1] Produces a callback bound to an optional `thisArg`. If `func` is a property name the created callback will return the property value for a given element. If `func` is an object the created callback will return `true` for elements that contain the equivalent object properties, otherwise it will return `false`. @@ -2354,7 +2355,7 @@ _.filter(stooges, 'age__gt45'); ### `_.curry(func, [arity=func.length])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5389 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5419 "View in source") [Ⓣ][1] Creates a function which accepts one or more arguments of `func` that when invoked either executes `func` returning its result, if all `func` arguments have been provided, or returns a function that accepts one or more of the remaining `func` arguments, and so on. The arity of `func` can be specified if `func.length` is not sufficient. @@ -2388,8 +2389,8 @@ curried(1, 2, 3); -### `_.debounce(func, wait, [options], [options.leading=false], [options.maxWait], [options.trailing=true])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5433 "View in source") [Ⓣ][1] +### `_.debounce(func, wait, [options], [options.maxWait])` +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5463 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Provide an options object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -2433,7 +2434,7 @@ source.addEventListener('message', _.debounce(batchLog, 250, { ### `_.defer(func, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5534 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5564 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be provided to `func` when it is invoked. @@ -2458,7 +2459,7 @@ _.defer(function() { console.log('deferred'); }); ### `_.delay(func, wait, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5568 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5598 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be provided to `func` when it is invoked. @@ -2485,7 +2486,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func, [resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5610 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5640 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is provided it will be used to determine the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. The result cache is exposed as the `cache` property on the memoized function. @@ -2525,7 +2526,7 @@ stooge('curly'); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5643 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5673 "View in source") [Ⓣ][1] Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. @@ -2551,7 +2552,7 @@ initialize(); ### `_.partial(func, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5681 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5711 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those provided to the new function. This method is similar to `_.bind` except it does **not** alter the `this` binding. @@ -2578,7 +2579,7 @@ hi('moe'); ### `_.partialRight(func, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5712 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5742 "View in source") [Ⓣ][1] This method is like `_.partial` except that `partial` arguments are appended to those provided to the new function. @@ -2614,8 +2615,8 @@ options.imports -### `_.throttle(func, wait, [options], [options.leading=true], [options.trailing=true])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5747 "View in source") [Ⓣ][1] +### `_.throttle(func, wait, [options])` +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5777 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Provide an options object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2651,7 +2652,7 @@ jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5791 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5821 "View in source") [Ⓣ][1] Creates a function that provides `value` to the wrapper function as its first argument. Additional arguments provided to the function are appended to those provided to the wrapper function. The wrapper is executed with the `this` binding of the created function. @@ -2687,7 +2688,7 @@ hello(); ### `_.assign(object, [source], [callback], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1928 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L1956 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite property assignments of previous sources. If a callback is provided it will be executed to produce the assigned values. The callback is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -2725,13 +2726,13 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value, [deep=false], [callback], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1981 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2009 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true` nested objects will also be cloned, otherwise they will be assigned by reference. If a callback is provided it will be executed to produce the cloned values. If the callback returns `undefined` cloning will be handled by the method instead. The callback is bound to `thisArg` and invoked with one argument; *(value)*. #### Arguments 1. `value` *(\*)*: The value to clone. -2. `[deep=false]` *(boolean)*: A flag to indicate a deep clone. +2. `[deep=false]` *(boolean)*: Specify a deep clone. 3. `[callback]` *(Function)*: The function to customize cloning values. 4. `[thisArg]` *(\*)*: The `this` binding of `callback`. @@ -2772,7 +2773,7 @@ clone.childNodes.length; ### `_.cloneDeep(value, [callback], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2033 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2061 "View in source") [Ⓣ][1] Creates a deep clone of `value`. If a callback is provided it will be executed to produce the cloned values. If the callback returns `undefined` cloning will be handled by the method instead. The callback is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2818,7 +2819,7 @@ clone.node == view.node; ### `_.defaults(object, [source])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2057 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2085 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -2844,7 +2845,7 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.findKey(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2079 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2107 "View in source") [Ⓣ][1] This method is like `_.findIndex` except that it returns the key of the first element that passes the callback check, instead of the element itself. @@ -2872,7 +2873,7 @@ _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.findLastKey(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2111 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2139 "View in source") [Ⓣ][1] This method is like `_.findKey` except that it iterates over elements of a `collection` in the opposite order. @@ -2900,7 +2901,7 @@ _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.forIn(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2152 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2180 "View in source") [Ⓣ][1] Iterates over own and inherited enumerable properties of an object, executing the callback for each property. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2936,7 +2937,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forInRight(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2182 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2210 "View in source") [Ⓣ][1] This method is like `_.forIn` except that it iterates over elements of a `collection` in the opposite order. @@ -2972,7 +2973,7 @@ _.forInRight(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2248 "View in source") [Ⓣ][1] Iterates over own enumerable properties of an object, executing the callback for each property. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -3000,7 +3001,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.forOwnRight(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2240 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2268 "View in source") [Ⓣ][1] This method is like `_.forOwn` except that it iterates over elements of a `collection` in the opposite order. @@ -3028,7 +3029,7 @@ _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2269 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2297 "View in source") [Ⓣ][1] Creates a sorted array of property names of all enumerable properties, own and inherited, of `object` that have function values. @@ -3055,7 +3056,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2294 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2322 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -3080,7 +3081,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2311 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2339 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given object. @@ -3104,7 +3105,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1756 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L1781 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -3131,7 +3132,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1783 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L1810 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -3158,7 +3159,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2337 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2365 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -3182,7 +3183,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2354 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2382 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -3206,7 +3207,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2371 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2399 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -3230,7 +3231,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2396 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2424 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -3260,7 +3261,7 @@ _.isEmpty(''); ### `_.isEqual(a, b, [callback], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2453 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2481 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If a callback is provided it will be executed to compare values. If the callback returns `undefined` comparisons will be handled by the method instead. The callback is bound to `thisArg` and invoked with two arguments; *(a, b)*. @@ -3305,7 +3306,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2485 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2513 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -3343,7 +3344,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2502 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2530 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -3367,7 +3368,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2565 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2593 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -3402,7 +3403,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2587 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2615 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -3429,7 +3430,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2606 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2634 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -3455,7 +3456,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2532 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2560 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -3485,7 +3486,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2634 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2662 "View in source") [Ⓣ][1] Checks if `value` is an object created by the `Object` constructor. @@ -3520,7 +3521,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2659 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2687 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -3544,7 +3545,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2676 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2704 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -3568,7 +3569,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2693 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2721 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -3592,7 +3593,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1816 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L1844 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of an object. @@ -3616,7 +3617,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object, [source], [callback], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2748 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2776 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined` into the destination object. Subsequent sources will overwrite property assignments of previous sources. If a callback is provided it will be executed to produce the merged values of the destination and source properties. If the callback returns `undefined` merging will be handled by the method instead. The callback is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -3672,7 +3673,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, [callback], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2804 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2832 "View in source") [Ⓣ][1] Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a callback is provided it will be executed for each property of `object` omitting the properties the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3703,7 +3704,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2867 "View in source") [Ⓣ][1] Creates a two dimensional array of an object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3727,7 +3728,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, [callback], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2907 "View in source") [Ⓣ][1] Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a callback is provided it will be executed for each property of `object` picking the properties the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3758,7 +3759,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.transform(collection, [callback=identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2934 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2962 "View in source") [Ⓣ][1] An alternative to `_.reduce` this method transforms `object` to a new `accumulator` object which is the result of running each of its elements through a callback, with each callback execution potentially mutating the `accumulator` object. The callback is bound to `thisArg` and invoked with four arguments; *(accumulator, value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -3795,7 +3796,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2967 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L2995 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3826,7 +3827,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5818 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5848 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3850,7 +3851,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5836 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5866 "View in source") [Ⓣ][1] This method returns the first argument provided to it. @@ -3875,7 +3876,7 @@ moe === _.identity(moe); ### `_.mixin(object, object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5863 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5893 "View in source") [Ⓣ][1] Adds function properties of a source object to the `lodash` function and chainable wrapper. @@ -3906,7 +3907,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5901 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5931 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3926,9 +3927,9 @@ var lodash = _.noConflict(); ### `_.parseInt(value, [radix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5925 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5955 "View in source") [Ⓣ][1] -Converts the given `value` into an integer of the specified `radix`. If `radix` is `undefined` or `0` a `radix` of `10` is used unless the `value` is a hexadecimal, in which case a `radix` of `16` is used. +Converts the given value into an integer of the specified radix. If `radix` is `undefined` or `0` a `radix` of `10` is used unless the `value` is a hexadecimal, in which case a `radix` of `16` is used. Note: This method avoids differences in native ES3 and ES5 `parseInt` implementations. See http://es5.github.io/#E. @@ -3952,14 +3953,15 @@ _.parseInt('08'); -### `_.random([min=0], [max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5949 "View in source") [Ⓣ][1] +### `_.random([min=0], [max=1], [floating=false])` +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L5987 "View in source") [Ⓣ][1] -Produces a random number between `min` and `max` *(inclusive)*. If only one argument is provided a number between `0` and the given number will be returned. +Produces a random number between `min` and `max` *(inclusive)*. If only one argument is provided a number between `0` and the given number will be returned. If `floating` is truey or either `min` or `max` are floats a floating-point number will be returned instead of an integer. #### Arguments 1. `[min=0]` *(number)*: The minimum possible value. 2. `[max=1]` *(number)*: The maximum possible value. +3. `[floating=false]` *(boolean)*: Specify returning a floating-point number. #### Returns *(number)*: Returns a random number. @@ -3967,10 +3969,16 @@ Produces a random number between `min` and `max` *(inclusive)*. If only one argu #### Example ```js _.random(0, 5); -// => a number between 0 and 5 +// => an integer between 0 and 5 _.random(5); -// => also a number between 0 and 5 +// => also an integer between 0 and 5 + +_.random(5, true); +// => a floating-point number between 0 and 5 + +_.random(1.2, 5.2); +// => a floating-point number between 1.2 and 5.2 ``` * * * @@ -3981,7 +3989,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5993 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6044 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey then `undefined` is returned. @@ -4016,9 +4024,9 @@ _.result(object, 'stuff'); ### `_.runInContext([context=root])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L452 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L457 "View in source") [Ⓣ][1] -Create a new `lodash` function using the given `context` object. +Create a new `lodash` function using the given context object. #### Arguments 1. `[context=root]` *(Object)*: The context object. @@ -4034,7 +4042,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, [options], [options.escape], [options.evaluate], [options.imports], [options.interpolate], [sourceURL], [variable])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6086 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6137 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -4093,8 +4101,8 @@ _.template('hello {{ name }}!', { 'name': 'mustache' }); // => 'hello mustache!' // using the `imports` option to import jQuery -var list = '<% $.each(people, function(name) { %>
  • <%= name %>
  • <% }); %>'; -_.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery }); +var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; +_.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery } }); // => '
  • moe
  • larry
  • ' // using the `sourceURL` option to specify a custom sourceURL for the template @@ -4128,7 +4136,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback, [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6209 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6260 "View in source") [Ⓣ][1] Executes the callback `n` times, returning an array of the results of each callback execution. The callback is bound to `thisArg` and invoked with one argument; *(index)*. @@ -4160,7 +4168,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6236 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6287 "View in source") [Ⓣ][1] The inverse of `_.escape` this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -4184,7 +4192,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6256 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6307 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is provided the ID will be appended to it. @@ -4218,7 +4226,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L851 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L864 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -4237,7 +4245,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6565 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L6616 "View in source") [Ⓣ][1] *(string)*: The semantic version number. @@ -4249,7 +4257,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L660 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L665 "View in source") [Ⓣ][1] *(Object)*: An object used to flag environments features. @@ -4261,7 +4269,7 @@ A reference to the `lodash` function. ### `_.support.argsClass` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L685 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L682 "View in source") [Ⓣ][1] *(boolean)*: Detect if an `arguments` object's [[Class]] is resolvable *(all but Firefox < `4`, IE < `9`)*. @@ -4273,7 +4281,7 @@ A reference to the `lodash` function. ### `_.support.argsObject` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L677 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L690 "View in source") [Ⓣ][1] *(boolean)*: Detect if `arguments` objects are `Object` objects *(all but Narwhal and Opera < `10.5`)*. @@ -4285,7 +4293,7 @@ A reference to the `lodash` function. ### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L694 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L699 "View in source") [Ⓣ][1] *(boolean)*: Detect if `name` or `message` properties of `Error.prototype` are enumerable by default. *(IE < `9`, Safari < `5.1`)* @@ -4297,7 +4305,7 @@ A reference to the `lodash` function. ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L707 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L712 "View in source") [Ⓣ][1] *(boolean)*: Detect if `prototype` properties are enumerable by default. @@ -4311,7 +4319,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.fastBind` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L715 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L720 "View in source") [Ⓣ][1] *(boolean)*: Detect if `Function#bind` exists and is inferred to be fast *(all but V8)*. @@ -4320,10 +4328,22 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p + + +### `_.support.funcDecomp` +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L729 "View in source") [Ⓣ][1] + +*(boolean)*: Detect if functions can be decompiled by `Function#toString` *(all but PS3 and older Opera mobile browsers & avoided in Windows `8` apps)*. + +* * * + + + + ### `_.support.funcNames` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L737 "View in source") [Ⓣ][1] *(boolean)*: Detect if `Function#name` is supported *(all but IE)*. @@ -4335,7 +4355,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumArgs` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L741 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L746 "View in source") [Ⓣ][1] *(boolean)*: Detect if `arguments` object indexes are non-enumerable *(Firefox < `4`, IE < `9`, PhantomJS, Safari < `5.1`)*. @@ -4347,7 +4367,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L752 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L757 "View in source") [Ⓣ][1] *(boolean)*: Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -4361,7 +4381,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.ownLast` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L732 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L765 "View in source") [Ⓣ][1] *(boolean)*: Detect if own properties are iterated after inherited properties *(all but IE < `9`)*. @@ -4373,7 +4393,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.spliceObjects` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L766 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L779 "View in source") [Ⓣ][1] *(boolean)*: Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -4387,7 +4407,7 @@ Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` a ### `_.support.unindexedChars` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L777 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L790 "View in source") [Ⓣ][1] *(boolean)*: Detect lack of support for accessing string characters by index. @@ -4401,7 +4421,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L803 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L816 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -4413,7 +4433,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L811 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L824 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -4425,7 +4445,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L819 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L832 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -4437,7 +4457,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L827 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L840 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -4449,7 +4469,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L835 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L848 "View in source") [Ⓣ][1] *(string)*: Used to reference the data object in the template text. @@ -4461,7 +4481,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L843 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.1.0/lodash.js#L856 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. @@ -4476,4 +4496,4 @@ IE < `8` can't access characters by index and IE `8` can only access characters - [1]: #Arrays "Jump back to the TOC." \ No newline at end of file + [1]: #Arrays "Jump back to the TOC." diff --git a/doc/parse.php b/doc/parse.php index 7fc7f0bd9f..6e94dd42d3 100644 --- a/doc/parse.php +++ b/doc/parse.php @@ -21,9 +21,9 @@ // generate Markdown $markdown = docdown(array( 'path' => '../' . $file, - 'title' => 'Lo-Dash v2.0.0', + 'title' => 'Lo-Dash v2.1.0', 'toc' => 'categories', - 'url' => 'https://github.com/bestiejs/lodash/blob/master/lodash.js' + 'url' => 'https://github.com/lodash/lodash/blob/2.1.0/lodash.js' )); // save to a .md file @@ -33,4 +33,4 @@ header('Content-Type: text/plain;charset=utf-8'); echo $markdown . PHP_EOL; -?> \ No newline at end of file +?> diff --git a/lodash.js b/lodash.js index f10cc3d50d..4839b62fa8 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.0.0 + * Lo-Dash 2.1.0 * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.5.2 * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors @@ -69,7 +69,7 @@ var reNoMatch = /($^)/; /** Used to detect functions containing a `this` reference */ - var reThis = (reThis = /\bthis\b/) && reThis.test(runInContext) && reThis; + var reThis = /\bthis\b/; /** Used to match unescaped characters in compiled string literals */ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g; @@ -135,10 +135,13 @@ var root = (objectTypes[typeof window] && window) || this; /** Detect free variable `exports` */ - var freeExports = objectTypes[typeof exports] && exports; + var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; /** Detect free variable `module` */ - var freeModule = objectTypes[typeof module] && module && module.exports == freeExports && module; + var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; + + /** Detect the popular CommonJS extension `module.exports` */ + var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; /** Detect free variable `global` from Node.js or Browserified code and use it as `root` */ var freeGlobal = objectTypes[typeof global] && global; @@ -198,7 +201,7 @@ } /** - * Adds a given `value` to the corresponding cache object. + * Adds a given value to the corresponding cache object. * * @private * @param {*} value The value to add to the cache. @@ -277,9 +280,11 @@ var index = -1, length = array.length, first = array[0], + mid = array[(length / 2) | 0], last = array[length - 1]; - if (first && typeof first == 'object' && last && typeof last == 'object') { + if (first && typeof first == 'object' && + mid && typeof mid == 'object' && last && typeof last == 'object') { return false; } var cache = getObject(); @@ -441,7 +446,7 @@ /*--------------------------------------------------------------------------*/ /** - * Create a new `lodash` function using the given `context` object. + * Create a new `lodash` function using the given context object. * * @static * @memberOf _ @@ -669,20 +674,20 @@ for (prop in arguments) { } /** - * Detect if `arguments` objects are `Object` objects (all but Narwhal and Opera < 10.5). + * Detect if an `arguments` object's [[Class]] is resolvable (all but Firefox < 4, IE < 9). * * @memberOf _.support * @type boolean */ - support.argsObject = arguments.constructor == Object && !(arguments instanceof Array); + support.argsClass = toString.call(arguments) == argsClass; /** - * Detect if an `arguments` object's [[Class]] is resolvable (all but Firefox < 4, IE < 9). + * Detect if `arguments` objects are `Object` objects (all but Narwhal and Opera < 10.5). * * @memberOf _.support * @type boolean */ - support.argsClass = toString.call(arguments) == argsClass; + support.argsObject = arguments.constructor == Object && !(arguments instanceof Array); /** * Detect if `name` or `message` properties of `Error.prototype` are @@ -714,22 +719,22 @@ */ support.fastBind = nativeBind && !isV8; - /** - * Detect if `Function#name` is supported (all but IE). + * Detect if functions can be decompiled by `Function#toString` + * (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps). * * @memberOf _.support * @type boolean */ - support.funcNames = typeof Function.name == 'string'; + support.funcDecomp = !reNative.test(context.WinRTError) && reThis.test(runInContext); /** - * Detect if own properties are iterated after inherited properties (all but IE < 9). + * Detect if `Function#name` is supported (all but IE). * * @memberOf _.support * @type boolean */ - support.ownLast = props[0] != 'x'; + support.funcNames = typeof Function.name == 'string'; /** * Detect if `arguments` object indexes are non-enumerable @@ -751,6 +756,14 @@ */ support.nonEnumShadows = !/valueOf/.test(props); + /** + * Detect if own properties are iterated after inherited properties (all but IE < 9). + * + * @memberOf _.support + * @type boolean + */ + support.ownLast = props[0] != 'x'; + /** * Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. * @@ -977,7 +990,7 @@ * * @private * @param {*} value The value to clone. - * @param {boolean} [deep=false] A flag to indicate a deep clone. + * @param {boolean} [deep=false] Specify a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {Array} [stackA=[]] Tracks traversed source objects. * @param {Array} [stackB=[]] Associates clones with source counterparts. @@ -1087,7 +1100,7 @@ } if (support.funcNames || !bindData) { // checks if `func` references the `this` keyword and stores the result - bindData = !reThis || reThis.test(source); + bindData = !support.funcDecomp || reThis.test(source); setBindData(func, bindData); } } @@ -1130,9 +1143,21 @@ while (++index < length) { var value = array[index]; - // recursively flatten arrays (susceptible to call stack limits) - if (value && typeof value == 'object' && (isArray(value) || isArguments(value))) { - push.apply(result, isShallow ? value : baseFlatten(value, isShallow, isArgArrays)); + + if (value && typeof value == 'object' && typeof value.length == 'number' + && (isArray(value) || isArguments(value))) { + // recursively flatten arrays (susceptible to call stack limits) + if (!isShallow) { + value = baseFlatten(value, isShallow, isArgArrays); + } + var valIndex = -1, + valLength = value.length, + resIndex = result.length; + + result.length += valLength; + while (++valIndex < valLength) { + result[resIndex++] = value[valIndex]; + } } else if (!isArgArrays) { result.push(value); } @@ -1754,12 +1779,14 @@ * // => false */ function isArguments(value) { - return (value && typeof value == 'object') ? toString.call(value) == argsClass : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == argsClass || false; } // fallback for browsers that can't detect `arguments` objects by [[Class]] if (!support.argsClass) { isArguments = function(value) { - return (value && typeof value == 'object') ? hasOwnProperty.call(value, 'callee') : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + hasOwnProperty.call(value, 'callee') || false; }; } @@ -1781,7 +1808,8 @@ * // => true */ var isArray = nativeIsArray || function(value) { - return (value && typeof value == 'object') ? toString.call(value) == arrayClass : false; + return value && typeof value == 'object' && typeof value.length == 'number' && + toString.call(value) == arrayClass || false; }; /** @@ -1949,7 +1977,7 @@ * @memberOf _ * @category Objects * @param {*} value The value to clone. - * @param {boolean} [deep=false] A flag to indicate a deep clone. + * @param {boolean} [deep=false] Specify a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {*} [thisArg] The `this` binding of `callback`. * @returns {*} Returns the cloned `value`. @@ -3583,10 +3611,11 @@ } /** - * Retrieves the maximum value of an array. If a callback is provided it - * will be executed for each value in the array to generate the criterion by - * which the value is ranked. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the maximum value of a collection. If the collection is empty or + * falsey `-Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style * callback will return the property value of the given element. @@ -3652,10 +3681,11 @@ } /** - * Retrieves the minimum value of an array. If a callback is provided it - * will be executed for each value in the array to generate the criterion by - * which the value is ranked. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index, collection). + * Retrieves the minimum value of a collection. If the collection is empty or + * falsey `Infinity` is returned. If a callback is provided it will be executed + * for each value in the collection to generate the criterion by which the value + * is ranked. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). * * If a property name is provided for `callback` the created "_.pluck" style * callback will return the property value of the given element. @@ -4111,16 +4141,16 @@ * @category Collections * @param {Array|Object|string} collection The collection to iterate over. * @param {Object} properties The object of property values to filter by. - * @returns {Array} Returns a new array of elements that have the given `properties`. + * @returns {Array} Returns a new array of elements that have the given properties. * @example * * var stooges = [ * { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - * { 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] } + * { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } * ]; * * _.where(stooges, { 'age': 40 }); - * // => [{ 'name': 'moe', 'age': '40', 'quotes': ['Spread out!', 'You knucklehead!'] }] + * // => [{ 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] }] * * _.where(stooges, { 'quotes': ['Poifect!'] }); * // => [{ 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }] @@ -5272,7 +5302,7 @@ */ function compose() { var funcs = arguments, - length = funcs.length || 1; + length = funcs.length; while (length--) { if (!isFunction(funcs[length])) { @@ -5539,7 +5569,7 @@ return setTimeout(function() { func.apply(undefined, args); }, 1); } // use `setImmediate` if available in Node.js - if (isV8 && freeModule && typeof setImmediate == 'function') { + if (isV8 && moduleExports && typeof setImmediate == 'function') { defer = function(func) { if (!isFunction(func)) { throw new TypeError; @@ -5904,7 +5934,7 @@ } /** - * Converts the given `value` into an integer of the specified `radix`. + * Converts the given value into an integer of the specified radix. * If `radix` is `undefined` or `0` a `radix` of `10` is used unless the * `value` is a hexadecimal, in which case a `radix` of `16` is used. * @@ -5930,35 +5960,56 @@ /** * Produces a random number between `min` and `max` (inclusive). If only one * argument is provided a number between `0` and the given number will be - * returned. + * returned. If `floating` is truey or either `min` or `max` are floats a + * floating-point number will be returned instead of an integer. * * @static * @memberOf _ * @category Utilities * @param {number} [min=0] The minimum possible value. * @param {number} [max=1] The maximum possible value. + * @param {boolean} [floating=false] Specify returning a floating-point number. * @returns {number} Returns a random number. * @example * * _.random(0, 5); - * // => a number between 0 and 5 + * // => an integer between 0 and 5 * * _.random(5); - * // => also a number between 0 and 5 + * // => also an integer between 0 and 5 + * + * _.random(5, true); + * // => a floating-point number between 0 and 5 + * + * _.random(1.2, 5.2); + * // => a floating-point number between 1.2 and 5.2 */ - function random(min, max) { - if (min == null && max == null) { + function random(min, max, floating) { + var noMin = min == null, + noMax = max == null; + + if (floating == null) { + if (typeof min == 'boolean' && noMax) { + floating = min; + min = 1; + } + else if (!noMax && typeof max == 'boolean') { + floating = max; + noMax = true; + } + } + if (noMin && noMax) { max = 1; } min = +min || 0; - if (max == null) { + if (noMax) { max = min; min = 0; } else { max = +max || 0; } var rand = nativeRandom(); - return (min % 1 || max % 1) + return (floating || min % 1 || max % 1) ? min + nativeMin(rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1))), max) : min + floor(rand * (max - min + 1)); } @@ -6057,8 +6108,8 @@ * // => 'hello mustache!' * * // using the `imports` option to import jQuery - * var list = '<% $.each(people, function(name) { %>
  • <%= name %>
  • <% }); %>'; - * _.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery }); + * var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; + * _.template(list, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery } }); * // => '
  • moe
  • larry
  • ' * * // using the `sourceURL` option to specify a custom sourceURL for the template @@ -6176,7 +6227,7 @@ if (data) { return result(data); } - // provide the compiled function's source via its `toString` method, in + // provide the compiled function's source by its `toString` method, in // supported environments, or the `source` property as a convenience for // inlining compiled templates during the build process result.source = source; @@ -6261,7 +6312,7 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps the given `value`. + * Creates a `lodash` object that wraps the given value. * * @static * @memberOf _ @@ -6562,7 +6613,7 @@ * @memberOf _ * @type string */ - lodash.VERSION = '2.0.0'; + lodash.VERSION = '2.1.0'; // add "Chaining" functions to the wrapper lodash.prototype.chain = wrapperChain; @@ -6640,7 +6691,7 @@ // Expose Lo-Dash to the global object even when an AMD loader is present in // case Lo-Dash was injected by a third-party script and not intended to be // loaded as a module. The global assignment can be reverted in the Lo-Dash - // module via its `noConflict()` method. + // module by its `noConflict()` method. root._ = _; // define as an anonymous module so, through path mapping, it can be @@ -6650,12 +6701,12 @@ }); } // check for `exports` after `define` in case a build optimizer adds an `exports` object - else if (freeExports && !freeExports.nodeType) { - // in Node.js or RingoJS v0.8.0+ - if (freeModule) { + else if (freeExports && freeModule) { + // in Node.js or RingoJS + if (moduleExports) { (freeModule.exports = _)._ = _; } - // in Narwhal or RingoJS v0.7.0- + // in Narwhal or Rhino -require else { freeExports._ = _; } diff --git a/package.json b/package.json index 9a46158d4a..dfd46da812 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lodash", - "version": "2.0.0", - "description": "A utility library delivering consistency, customization, performance, and extras.", + "version": "2.1.0", + "description": "A utility library delivering consistency, customization, performance, & extras.", "homepage": "http://lodash.com/", "license": "MIT", "main": "dist/lodash.js", @@ -27,7 +27,16 @@ "dist/lodash.underscore.min.js" ], "jam": { - "main": "dist/lodash.compat.js" + "main": "dist/lodash.compat.js", + "include": [ + "LICENSE.txt", + "dist/lodash.js", + "dist/lodash.min.js", + "dist/lodash.compat.js", + "dist/lodash.compat.min.js", + "dist/lodash.underscore.js", + "dist/lodash.underscore.min.js" + ] }, "volo": { "type": "directory", diff --git a/perf/perf-ui.js b/perf/perf-ui.js index 6a1d6f0ea7..0b448fcba8 100644 --- a/perf/perf-ui.js +++ b/perf/perf-ui.js @@ -5,10 +5,10 @@ var basePath = '../'; /** The Lo-Dash build to load */ - var build = (/build=([^&]+)/.exec(location.search) || [])[1]; + var build = (build = /build=([^&]+)/.exec(location.search)) && decodeURIComponent(build[1]); /** The other library to load */ - var other = (/other=([^&]+)/.exec(location.search) || [])[1]; + var other = (other = /other=([^&]+)/.exec(location.search)) && decodeURIComponent(other[1]); /** The `ui` object */ var ui = {}; @@ -51,7 +51,7 @@ case 'lodash-custom-dev': result = 'lodash.custom.js'; break; case 'lodash-custom': result = 'lodash.custom.min.js'; break; case 'lodash-modern': - case undefined: result = 'dist/lodash.min.js'; break; + case null: result = 'dist/lodash.min.js'; break; default: return build; } return basePath + result; @@ -70,7 +70,7 @@ case 'lodash-custom': result = 'lodash.custom.min.js'; break; case 'underscore-dev': result = 'vendor/underscore/underscore.js'; break; case 'underscore': - case undefined: result = 'vendor/underscore/underscore-min.js'; break; + case null: result = 'vendor/underscore/underscore-min.js'; break; default: return other; } return basePath + result; @@ -141,7 +141,7 @@ case 'lodash-custom-dev': return 5; case 'lodash-custom': return 6; case 'lodash-modern': - case undefined: return 3; + case null: return 3; } return -1; }()); @@ -157,7 +157,7 @@ case 'lodash-custom-dev': return 7; case 'lodash-custom': return 8; case 'underscore': - case undefined: return 1; + case null: return 1; } return -1; }()); diff --git a/perf/perf.js b/perf/perf.js index 4d7d31d3bf..1479af3cce 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -270,6 +270,7 @@ numbers = Array(limit),\ fourNumbers = [5, 25, 10, 30],\ nestedNumbers = [1, [2], [3, [[4]]]],\ + nestedObjects = [{}, [{}], [{}, [[{}]]]],\ twoNumbers = [12, 23];\ \ for (index = 0; index < limit; index++) {\ @@ -1025,6 +1026,16 @@ ) ); + suites.push( + Benchmark.Suite('`_.flatten` with objects') + .add(buildName, '\ + lodash.flatten(nestedObjects)' + ) + .add(otherName, '\ + _.flatten(nestedObjects)' + ) + ); + suites.push( Benchmark.Suite('`_.flatten` with `shallow`') .add(buildName, '\ diff --git a/test/index.html b/test/index.html index 1059917c26..a2453ecb6c 100644 --- a/test/index.html +++ b/test/index.html @@ -17,7 +17,16 @@