From 090fb09955b63cfb186c7a78ce80dc49fff5396c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 6 Dec 2012 23:09:41 -0800 Subject: [PATCH 01/45] Optimize `_.union`. Former-commit-id: 0cba8cac81a621b1fdbe8868ab406a30eb1d743f --- lodash.js | 6 ++++-- perf/perf.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/lodash.js b/lodash.js index 1664a12964..66a2f605c1 100644 --- a/lodash.js +++ b/lodash.js @@ -3140,11 +3140,13 @@ if (isLarge) { // manually coerce `computed` to a string because `hasOwnProperty`, in // some older versions of Firefox, coerces objects incorrectly - seen = hasOwnProperty.call(cache, computed + '') ? cache[computed] : (cache[computed] = []); + var inited = hasOwnProperty.call(cache, computed + '') + ? !(seen = cache[computed]) + : (seen = []); } if (isSorted ? !index || seen[seen.length - 1] !== computed - : indexOf(seen, computed) < 0 + : inited || indexOf(seen, computed) < 0 ) { if (callback || isLarge) { seen.push(computed); diff --git a/perf/perf.js b/perf/perf.js index a8d80a1084..a53ea27a99 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -1631,6 +1631,42 @@ ) ); + suites.push( + Benchmark.Suite('`_.union` iterating an array of 50 elements') + .add(buildName, { + 'fn': 'lodash.union(twentyFiveValues, twentyFiveValues2);', + 'teardown': 'function multiArrays(){}' + }) + .add(otherName, { + 'fn': '_.union(twentyFiveValues, twentyFiveValues2);', + 'teardown': 'function multiArrays(){}' + }) + ); + + suites.push( + Benchmark.Suite('`_.union` iterating an array of 75 elements') + .add(buildName, { + 'fn': 'lodash.union(fiftyValues, twentyFiveValues2);', + 'teardown': 'function multiArrays(){}' + }) + .add(otherName, { + 'fn': '_.union(fiftyValues, twentyFiveValues2);', + 'teardown': 'function multiArrays(){}' + }) + ); + + suites.push( + Benchmark.Suite('`_.union` iterating an array of 100 elements') + .add(buildName, { + 'fn': 'lodash.union(seventyFiveValues, twentyFiveValues2);', + 'teardown': 'function multiArrays(){}' + }) + .add(otherName, { + 'fn': '_.union(seventyFiveValues, twentyFiveValues2);', + 'teardown': 'function multiArrays(){}' + }) + ); + /*--------------------------------------------------------------------------*/ suites.push( From cdeb50132d1e31fbb87aba3ebd8574726e2a9939 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 6 Dec 2012 23:28:12 -0800 Subject: [PATCH 02/45] Optimize `_.reduce` and `_.reduceRight`. Former-commit-id: 6f281aae7f285458feafb02957fcd90fb09c10bd --- build.js | 2 +- lodash.js | 45 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/build.js b/build.js index e3c447ab44..6d3aa33670 100755 --- a/build.js +++ b/build.js @@ -135,7 +135,7 @@ 'pluck': ['map'], 'random': [], 'range': [], - 'reduce': ['forEach'], + 'reduce': ['forEach', 'isArray'], 'reduceRight': ['forEach', 'isString', 'keys'], 'reject': ['filter'], 'rest': [], diff --git a/lodash.js b/lodash.js index 66a2f605c1..10fcb392fa 100644 --- a/lodash.js +++ b/lodash.js @@ -611,9 +611,11 @@ * @param {Function|String} [func=identity|property] The function called per * iteration or property name to query. * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @param {Boolean} [accumulating] A flag to indicate creating a callback + * that accepts an `accumulator` argument. * @returns {Function} Returns a callback function. */ - function createCallback(func, thisArg) { + function createCallback(func, thisArg, accumulating) { if (!func) { return identity; } @@ -623,6 +625,11 @@ }; } if (typeof thisArg != 'undefined') { + if (accumulating) { + return function(accumulator, value, index, object) { + return func.call(thisArg, accumulator, value, index, object); + }; + } return function(value, index, object) { return func.call(thisArg, value, index, object); }; @@ -1951,6 +1958,7 @@ function countBy(collection, callback, thisArg) { var result = {}; callback = createCallback(callback, thisArg); + forEach(collection, function(value, key, collection) { key = callback(value, key, collection); (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); @@ -2063,6 +2071,7 @@ function find(collection, callback, thisArg) { var result; callback = createCallback(callback, thisArg); + forEach(collection, function(value, index, collection) { if (callback(value, index, collection)) { result = value; @@ -2125,6 +2134,7 @@ function groupBy(collection, callback, thisArg) { var result = {}; callback = createCallback(callback, thisArg); + forEach(collection, function(value, key, collection) { key = callback(value, key, collection); (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); @@ -2349,12 +2359,25 @@ */ function reduce(collection, callback, accumulator, thisArg) { var noaccum = arguments.length < 3; - callback || (callback = identity); - forEach(collection, function(value, index, collection) { - accumulator = noaccum - ? (noaccum = false, value) - : callback.call(thisArg, accumulator, value, index, collection) - }); + callback = createCallback(callback, thisArg, true); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + if (noaccum) { + accumulator = collection[++index]; + } + while (++index < length) { + accumulator = callback(accumulator, collection[index], index, collection); + } + } else { + forEach(collection, function(value, index, collection) { + accumulator = noaccum + ? (noaccum = false, value) + : callback(accumulator, value, index, collection) + }); + } return accumulator; } @@ -2387,12 +2410,12 @@ } else if (noCharByIndex && isString(collection)) { iteratee = collection.split(''); } - callback || (callback = identity); + callback = createCallback(callback, thisArg, true); forEach(collection, function(value, index, collection) { index = props ? props[--length] : --length; accumulator = noaccum ? (noaccum = false, iteratee[index]) - : callback.call(thisArg, accumulator, iteratee[index], index, collection); + : callback(accumulator, iteratee[index], index, collection); }); return accumulator; } @@ -2541,6 +2564,7 @@ function sortBy(collection, callback, thisArg) { var result = []; callback = createCallback(callback, thisArg); + forEach(collection, function(value, index, collection) { result.push({ 'criteria': callback(value, index, collection), @@ -3051,9 +3075,10 @@ var low = 0, high = array ? array.length : low; - // explicitly reference `identity` for better engine inlining + // explicitly reference `identity` for better inlining in Firefox callback = callback ? createCallback(callback, thisArg) : identity; value = callback(value); + while (low < high) { var mid = (low + high) >>> 1; callback(array[mid]) < value From c79bed22f87aab5f551f74d7f0bb0475e0648706 Mon Sep 17 00:00:00 2001 From: Kit Cambridge Date: Fri, 7 Dec 2012 19:41:11 -0800 Subject: [PATCH 03/45] Ensure that passing `settings=...` does not clobber the default `moduleId`. Precompiling a template with `settings` previously generated a snippet resembling `define(["undefined"], function(lodash) { ... })` if the `settings` object did not contain a `moduleId` property. You can now pass `settings` and `moduleId` options simultaneously; the builder will always use the `moduleId` property in `settings` if it is provided, and default to `moduleId` otherwise. Former-commit-id: 711b4f167dc08ce3d42029e9001ebdb2d8d60a56 --- build.js | 2 +- test/test-build.js | 39 +++++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/build.js b/build.js index 6d3aa33670..9403790298 100755 --- a/build.js +++ b/build.js @@ -1050,7 +1050,7 @@ var templateSettings = options.reduce(function(result, value) { var match = value.match(/settings=(.+)$/); return match - ? Function('return {' + match[1].replace(/^{|}$/g, '') + '}')() + ? Function('assign, result', 'return assign(result, {' + match[1].replace(/^{|}$/g, '') + '})')(_.assign, result) : result; }, _.assign(_.clone(_.templateSettings), { 'moduleId': moduleId diff --git a/test/test-build.js b/test/test-build.js index 18a475a38a..3421536a24 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -525,25 +525,36 @@ start(); }); }); - }); - asyncTest('`lodash settings=...`', function() { - var start = _.after(2, _.once(QUnit.start)); + asyncTest('`lodash settings=...`' + (command ? ' ' + command : ''), function() { + var start = _.after(2, _.once(QUnit.start)); - build(['-s', 'template=' + templatePath + '/*.tpl', 'settings={interpolate:/\\{\\{([\\s\\S]+?)\\}\\}/}'], function(source, filePath) { - var basename = path.basename(filePath, '.js'), - context = createContext(); + build(['-s', 'template=' + templatePath + '/*.tpl', 'settings={interpolate:/\\{\\{([\\s\\S]+?)\\}\\}/}'].concat(command || []), function(source, filePath) { + var moduleId, templates, + basename = path.basename(filePath, '.js'), + context = createContext(); - var data = { - 'd': { 'name': 'Mustache' } - }; + var data = { + 'd': { 'name': 'Mustache' } + }; - context._ = _; - vm.runInContext(source, context); - var templates = context._.templates; + (context.define = function(requires, factory) { + factory(_); + templates = _.templates; + moduleId = requires + ''; + }) + .amd = {}; - equal(templates.d(data.d), 'Hello Mustache!', basename); - start(); + context._ = _; + vm.runInContext(source, context); + + var templates = context._.templates; + + equal(moduleId, command ? 'underscore' : 'lodash'); + equal(templates.d(data.d), 'Hello Mustache!', basename); + delete _.templates; + start(); + }); }); }); }()); From 32b9de05f2c0362675539cab9992354a1f655019 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 8 Dec 2012 01:24:25 -0800 Subject: [PATCH 04/45] Cleanup test/test-build.js. Former-commit-id: 4edb24bf22b8e8f9aa45b08a97289c1b83461e16 --- test/test-build.js | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/test/test-build.js b/test/test-build.js index 3421536a24..6dfed942da 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -489,11 +489,10 @@ context._ = _; vm.runInContext(source, context); - var templates = context._.templates; - equal(templates.a(data.a).replace(/[\r\n]+/g, ''), '
  • moe
  • larry
  • curly
', basename); - equal(templates.b(data.b), 'Hello stooge.', basename); - equal(templates.c(data.c), 'Hello ES6!', basename); + equal(_.templates.a(data.a).replace(/[\r\n]+/g, ''), '
  • moe
  • larry
  • curly
', basename); + equal(_.templates.b(data.b), 'Hello stooge.', basename); + equal(_.templates.c(data.c), 'Hello ES6!', basename); delete _.templates; start(); }); @@ -506,21 +505,18 @@ build(['-s', 'template=' + templatePath + '/*.jst', 'exports=amd'].concat(command || []), function(source, filePath) { var moduleId, basename = path.basename(filePath, '.js'), - context = createContext(), - pass = false; + context = createContext(); - (context.define = function(requires, factory) { + context.define = function(requires, factory) { factory(_); - var templates = _.templates; - moduleId = requires + ''; - pass = 'a' in templates && 'b' in templates; - }) - .amd = {}; + moduleId = requires[0]; + }; + context.define.amd = {}; vm.runInContext(source, context); - equal(moduleId, command ? 'underscore' : 'lodash'); - ok(pass, basename); + equal(moduleId, (command ? 'underscore' : 'lodash'), basename); + ok('a' in _.templates && 'b' in _.templates, basename); delete _.templates; start(); }); @@ -530,7 +526,7 @@ var start = _.after(2, _.once(QUnit.start)); build(['-s', 'template=' + templatePath + '/*.tpl', 'settings={interpolate:/\\{\\{([\\s\\S]+?)\\}\\}/}'].concat(command || []), function(source, filePath) { - var moduleId, templates, + var moduleId, basename = path.basename(filePath, '.js'), context = createContext(); @@ -538,20 +534,16 @@ 'd': { 'name': 'Mustache' } }; - (context.define = function(requires, factory) { + context.define = function(requires, factory) { factory(_); - templates = _.templates; - moduleId = requires + ''; - }) - .amd = {}; + moduleId = requires[0]; + }; - context._ = _; + context.define.amd = {}; vm.runInContext(source, context); - var templates = context._.templates; - - equal(moduleId, command ? 'underscore' : 'lodash'); - equal(templates.d(data.d), 'Hello Mustache!', basename); + equal(moduleId, (command ? 'underscore' : 'lodash'), basename); + equal(_.templates.d(data.d), 'Hello Mustache!', basename); delete _.templates; start(); }); From 7313dd74a6613bcfb24e3063bbb050b6586727f7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 8 Dec 2012 01:26:08 -0800 Subject: [PATCH 05/45] Allow compiled templates loaded via AMD to set and use the private `_` variable. Former-commit-id: 746e6d8275f08dbb628e92c146fffba84df0f8c0 --- build.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.js b/build.js index 9403790298..c47c5cae13 100755 --- a/build.js +++ b/build.js @@ -336,6 +336,7 @@ source.push( " if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {", " define(['" + options.moduleId + "'], function(lodash) {", + ' _ = lodash;', ' lodash.templates = lodash.extend(lodash.templates || {}, templates);', ' });', " } else if (freeExports) {", @@ -1050,7 +1051,7 @@ var templateSettings = options.reduce(function(result, value) { var match = value.match(/settings=(.+)$/); return match - ? Function('assign, result', 'return assign(result, {' + match[1].replace(/^{|}$/g, '') + '})')(_.assign, result) + ? _.assign(result, Function('return {' + match[1].replace(/^{|}$/g, '') + '}')()) : result; }, _.assign(_.clone(_.templateSettings), { 'moduleId': moduleId From a451861bf1a47eb77d8680e8dfb3999f44ea0d40 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 8 Dec 2012 18:42:48 -0800 Subject: [PATCH 06/45] Make "Functions" methods return wrapped values when chaining and remove `_.chain` and `_#chain` methods. Former-commit-id: a507f9a1b76b933a7d558d2cc20177e6995dcf0d --- lodash.js | 102 ++++++++++++++++++++---------------------------------- 1 file changed, 37 insertions(+), 65 deletions(-) diff --git a/lodash.js b/lodash.js index 10fcb392fa..9de8797781 100644 --- a/lodash.js +++ b/lodash.js @@ -243,9 +243,30 @@ /*--------------------------------------------------------------------------*/ /** - * The `lodash` function. - * - * @name _ + * Creates a `lodash` object, that wraps the given `value`, to enable + * method chaining. + * + * The wrapper functions capable of chaining are: + * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, + * `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, + * `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, + * `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, + * `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, + * `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, + * `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` + * + * The wrapper functions that do not chain are: + * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, + * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, + * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, + * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, + * `mixin`, `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, + * `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` + * + * The wrapper functions `first` and `last` return wrapped values when `n` is + * passed, otherwise unwrapped values are returned. + * + * @name _, * @constructor * @category Chaining * @param {Mixed} value The value to wrap in a `lodash` instance. @@ -4076,32 +4097,6 @@ /*--------------------------------------------------------------------------*/ - /** - * Wraps the value in a `lodash` wrapper object. - * - * @static - * @memberOf _ - * @category Chaining - * @param {Mixed} value The value to wrap. - * @returns {Object} Returns the wrapper object. - * @example - * - * var stooges = [ - * { 'name': 'moe', 'age': 40 }, - * { 'name': 'larry', 'age': 50 }, - * { 'name': 'curly', 'age': 60 } - * ]; - * - * var youngest = _.chain(stooges) - * .sortBy(function(stooge) { return stooge.age; }) - * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) - * .first(); - * // => 'moe is 40' - */ - function chain(value) { - return new lodash(value); - } - /** * 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, @@ -4128,28 +4123,6 @@ return value; } - /** - * This function returns the wrapper object. - * - * Note: This function is defined to ensure the existing wrapper object is - * returned, instead of creating a new wrapper object like the `_.chain` - * method does. - * - * @name chain - * @deprecated - * @memberOf _ - * @category Chaining - * @returns {Mixed} Returns the wrapper object. - * @example - * - * var wrapped = _([1, 2, 3]); - * wrapped === wrapped.chain(); - * // => true - */ - function wrapperChain() { - return this; - } - /** * Produces the `toString` result of the wrapped value. * @@ -4186,12 +4159,19 @@ /*--------------------------------------------------------------------------*/ // add functions that return wrapped values when chaining + + lodash.after = after; lodash.assign = assign; + lodash.bind = bind; lodash.bindAll = bindAll; - lodash.chain = chain; + lodash.bindKey = bindKey; lodash.compact = compact; + lodash.compose = compose; lodash.countBy = countBy; + lodash.debounce = debounce; lodash.defaults = defaults; + lodash.defer = defer; + lodash.delay = delay; lodash.difference = difference; lodash.filter = filter; lodash.flatten = flatten; @@ -4207,11 +4187,14 @@ lodash.keys = keys; lodash.map = map; lodash.max = max; + lodash.memoize = memoize; lodash.merge = merge; lodash.min = min; lodash.object = object; lodash.omit = omit; + lodash.once = once; lodash.pairs = pairs; + lodash.partial = partial; lodash.pick = pick; lodash.pluck = pluck; lodash.range = range; @@ -4220,6 +4203,7 @@ lodash.shuffle = shuffle; lodash.sortBy = sortBy; lodash.tap = tap; + lodash.throttle = throttle; lodash.times = times; lodash.toArray = toArray; lodash.union = union; @@ -4227,6 +4211,7 @@ lodash.values = values; lodash.where = where; lodash.without = without; + lodash.wrap = wrap; lodash.zip = zip; // add aliases @@ -4245,15 +4230,8 @@ /*--------------------------------------------------------------------------*/ // add functions that return unwrapped values when chaining - lodash.after = after; - lodash.bind = bind; - lodash.bindKey = bindKey; lodash.clone = clone; - lodash.compose = compose; lodash.contains = contains; - lodash.debounce = debounce; - lodash.defer = defer; - lodash.delay = delay; lodash.escape = escape; lodash.every = every; lodash.find = find; @@ -4278,11 +4256,8 @@ lodash.isString = isString; lodash.isUndefined = isUndefined; lodash.lastIndexOf = lastIndexOf; - lodash.memoize = memoize; lodash.mixin = mixin; lodash.noConflict = noConflict; - lodash.once = once; - lodash.partial = partial; lodash.random = random; lodash.reduce = reduce; lodash.reduceRight = reduceRight; @@ -4291,10 +4266,8 @@ lodash.some = some; lodash.sortedIndex = sortedIndex; lodash.template = template; - lodash.throttle = throttle; lodash.unescape = unescape; lodash.uniqueId = uniqueId; - lodash.wrap = wrap; // add aliases lodash.all = every; @@ -4346,7 +4319,6 @@ lodash.VERSION = '1.0.0-rc.2'; // add "Chaining" functions to the wrapper - lodash.prototype.chain = wrapperChain; lodash.prototype.toString = wrapperToString; lodash.prototype.value = wrapperValueOf; lodash.prototype.valueOf = wrapperValueOf; From cf5e5dbe554616aa4fa1c18cbedca789c8c0b8f0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 8 Dec 2012 18:46:09 -0800 Subject: [PATCH 07/45] Update build to add `_.chain` and `_#chain` for `backbone` and `underscore` builds. Former-commit-id: 2c910de419904a1285d246a3b08d87cb4daafa18 --- build.js | 171 +++++++++++++++++++++++++++++-------------- build/pre-compile.js | 4 +- test/test-build.js | 74 +++++++++++++++---- 3 files changed, 176 insertions(+), 73 deletions(-) diff --git a/build.js b/build.js index c47c5cae13..e8476b684b 100755 --- a/build.js +++ b/build.js @@ -70,7 +70,6 @@ 'bind': ['isFunction', 'isObject'], 'bindAll': ['bind', 'functions'], 'bindKey': ['isFunction', 'isObject'], - 'chain': ['mixin'], 'clone': ['assign', 'forEach', 'forOwn', 'isArray', 'isObject'], 'compact': [], 'compose': [], @@ -159,7 +158,10 @@ 'where': ['filter', 'keys'], 'without': ['indexOf'], 'wrap': [], - 'zip': ['max', 'pluck'] + 'zip': ['max', 'pluck'], + + // method used by the `backbone` and `underscore` builds + 'chain': ['mixin'] }; /** Used to inline `iteratorTemplate` */ @@ -1175,7 +1177,117 @@ source = replaceVar(source, 'noArgsClass', 'true'); source = removeKeysOptimization(source); } - else if (isUnderscore) { + // add Underscore's chaining API + if (isBackbone || isUnderscore) { + // add `_.chain` + source = source.replace(matchFunction(source, 'tap'), function(match) { + return [ + '', + ' /**', + ' * Creates a `lodash` object that wraps the given `value`.', + ' *', + ' * @static', + ' * @memberOf _', + ' * @category Chaining', + ' * @param {Mixed} value The value to wrap.', + ' * @returns {Object} Returns the wrapper object.', + ' * @example', + ' *', + ' * var stooges = [', + " * { 'name': 'moe', 'age': 40 },", + " * { 'name': 'larry', 'age': 50 },", + " * { 'name': 'curly', 'age': 60 }", + ' * ];', + ' *', + ' * var youngest = _.chain(stooges)', + ' * .sortBy(function(stooge) { return stooge.age; })', + " * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; })", + ' * .first();', + " * // => 'moe is 40'", + ' */', + ' function chain(value) {', + ' value = new lodash(value);', + ' value.__chain__ = true;', + ' return value;', + ' }', + '', + match + ].join('\n'); + }); + + // add `wrapperChain` + source = source.replace(matchFunction(source, 'wrapperToString'), function(match) { + return [ + '', + ' /**', + ' * Enables method chaining on the wrapper object.', + ' *', + ' * @name chain', + ' * @memberOf _', + ' * @category Chaining', + ' * @returns {Mixed} Returns the wrapper object.', + ' * @example', + ' *', + ' * var sum = _([1, 2, 3])', + ' * .chain()', + ' * .reduce(function(sum, num) { return sum + num; })', + ' * .value()', + ' * // => 6`', + ' */', + ' function wrapperChain() {', + ' this.__chain__ = true;', + ' return this;', + ' }', + '', + match + ].join('\n'); + }); + + // add `__chain__` checks to `_.mixin` and `Array` function wrappers + _.each([ + matchFunction(source, 'mixin'), + /(?:\s*\/\/.*)*\n( *)forEach\(\['[\s\S]+?\n\1}.+/g + ], function(pattern) { + source = source.replace(pattern, function(match) { + return match.replace(/( *)return new lodash\(([^)]+)\).+/, function(submatch, indent, varName) { + return indent + [ + 'if (this.__chain__) {', + ' varName = new lodash(varName);', + ' varName.__chain__ = true;', + '}', + 'return varName;' + ].join('\n' + indent) + .replace(/varName/g, varName); + }); + }); + }); + + // add `lodash.chain` assignment + source = source.replace(getMethodAssignments(source), function(match) { + return match.replace(/^(?: *\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\n)?( *)lodash\.VERSION *=/m, '$1lodash.chain = chain;\n\n$&'); + }); + + // add `lodash.prototype.chain` assignment + source = source.replace(/^( *)lodash\.prototype\.value *=.+\n/m, '$1lodash.prototype.chain = wrapperChain;\n$&'); + + // remove `lodash.prototype.toString` and `lodash.prototype.valueOf` assignments + source = source.replace(/^ *lodash\.prototype\.(?:toString|valueOf) *=.+\n/gm, ''); + + // remove `lodash.prototype` batch method assignments + source = source.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, ''); + + // move `mixin(lodash)` to after the method assignments + source = source.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+/, ''); + source = source.replace(getMethodAssignments(source), function(match) { + return match + [ + '', + '', + ' // add functions to `lodash.prototype`', + ' mixin(lodash);' + ].join('\n'); + }); + } + if (isUnderscore) { // remove unneeded variables source = removeVar(source, 'cloneableClasses'); source = removeVar(source, 'ctorByClass'); @@ -1202,15 +1314,6 @@ ' }' ].join('\n')); - // replace `_.chain` - source = replaceFunction(source, 'chain', [ - ' function chain(value) {', - ' value = new lodash(value);', - ' value.__chain__ = true;', - ' return value;', - ' }' - ].join('\n')); - // replace `_.clone` if (useUnderscoreClone) { source = replaceFunction(source, 'clone', [ @@ -1460,33 +1563,6 @@ ' }' ].join('\n')); - // replace `wrapperChain` - source = replaceFunction(source, 'wrapperChain', [ - ' function wrapperChain() {', - ' this.__chain__ = true;', - ' return this;', - ' }' - ].join('\n')); - - // add `__chain__` checks to `_.mixin` and `Array` function wrappers - _.each([ - matchFunction(source, 'mixin'), - /(?:\s*\/\/.*)*\n( *)forEach\(\['[\s\S]+?\n\1}.+/g - ], function(pattern) { - source = source.replace(pattern, function(match) { - return match.replace(/( *)return new lodash\(([^)]+)\).+/, function(submatch, indent, varName) { - return indent + [ - 'if (this.__chain__) {', - ' varName = new lodash(varName);', - ' varName.__chain__ = true;', - '}', - 'return varName;' - ].join('\n' + indent) - .replace(/varName/g, varName); - }); - }); - }); - // remove `arguments` object check from `_.isEqual` source = source.replace(matchFunction(source, 'isEqual'), function(match) { return match.replace(/^ *if *\(.+== argsClass[^}]+}\n/gm, '') @@ -1499,23 +1575,6 @@ }); }); - // remove `lodash.prototype.toString` and `lodash.prototype.valueOf` assignments - source = source.replace(/^ *lodash\.prototype\.(?:toString|valueOf) *=.+\n/gm, ''); - - // remove `lodash.prototype` batch method assignments - source = source.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, ''); - - // move `mixin(lodash)` to after the method assignments - source = source.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+/, ''); - source = source.replace(getMethodAssignments(source), function(match) { - return match + [ - '', - '', - ' // add functions to `lodash.prototype`', - ' mixin(lodash);' - ].join('\n'); - }); - // remove unused features from `createBound` if (buildMethods.indexOf('partial') == -1) { source = source.replace(matchFunction(source, 'createBound'), function(match) { diff --git a/build/pre-compile.js b/build/pre-compile.js index c877082cb7..e02f303e2c 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -68,7 +68,6 @@ 'bind', 'bindAll', 'bindKey', - 'chain', 'clone', 'collect', 'compact', @@ -188,8 +187,9 @@ 'wrap', 'zip', - // property used by the `lodash underscore` build + // properties used by the `backbone` and `underscore` builds '__chain__', + 'chain', // properties used by underscore.js '_chain', diff --git a/test/test-build.js b/test/test-build.js index 6dfed942da..e2d7d8e9c9 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -54,9 +54,9 @@ }; /** List of all Lo-Dash methods */ - var allMethods = _.functions(_).filter(function(methodName) { - return !/^_/.test(methodName); - }); + var allMethods = _.functions(_) + .filter(function(methodName) { return !/^_/.test(methodName); }) + .concat('chain'); /** List of "Arrays" category methods */ var arraysMethods = [ @@ -86,7 +86,6 @@ /** List of "Chaining" category methods */ var chainingMethods = [ - 'chain', 'mixin', 'tap', 'value' @@ -498,7 +497,12 @@ }); }); - ['', 'moduleId=underscore'].forEach(function(command) { + var commands = [ + '', + 'moduleId=underscore' + ]; + + commands.forEach(function(command) { asyncTest('`lodash template=*.jst` exports=amd' + (command ? ' ' + command : ''), function() { var start = _.after(2, _.once(QUnit.start)); @@ -637,6 +641,44 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('underscore chaining methods'); + + (function() { + var commands = [ + 'backbone', + 'underscore' + ]; + + commands.forEach(function(command) { + asyncTest('`lodash ' + command +'`', function() { + var start = _.after(2, _.once(QUnit.start)); + + build(['-s', command], function(source, filePath) { + var basename = path.basename(filePath, '.js'), + context = createContext(); + + vm.runInContext(source, context); + var lodash = context._; + + ok(lodash.chain(1) instanceof lodash, '_.chain: ' + basename); + ok(lodash(1).chain() instanceof lodash, '_#chain: ' + basename); + + var wrapped = lodash(1); + equal(wrapped.clone() instanceof lodash, false, '_(...) wrapped values are not chainable by default: ' + basename); + equal(String(wrapped) === '1', false, '_#toString should not be implemented: ' + basename); + equal(Number(wrapped) === 1 , false, '_#valueOf should not be implemented: ' + basename); + + wrapped.chain(); + equal(wrapped.has('x') instanceof lodash, true, '_#has returns wrapped values when chaining: ' + basename); + + start(); + }); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('underscore modifier'); (function() { @@ -701,14 +743,6 @@ equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename); equal(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename); - var wrapped = lodash(1); - equal(wrapped.clone() instanceof lodash, false, '_(...) wrapped values are not chainable by default: ' + basename); - equal(String(wrapped) === '1', false, '_#toString should not be implemented: ' + basename); - equal(Number(wrapped) === 1 , false, '_#valueOf should not be implemented: ' + basename); - - wrapped.chain(); - equal(wrapped.has('x') instanceof lodash, true, '_#has returns wrapped values when chaining: ' + basename); - start(); }); }); @@ -877,7 +911,12 @@ QUnit.module('output options'); (function() { - ['-o a.js', '--output a.js'].forEach(function(command, index) { + var commands = [ + '-o a.js', + '--output a.js' + ]; + + commands.forEach(function(command, index) { asyncTest('`lodash ' + command +'`', function() { var start = _.once(QUnit.start); @@ -894,7 +933,12 @@ QUnit.module('stdout options'); (function() { - ['-c', '--stdout'].forEach(function(command, index) { + var commands = [ + '-c', + '--stdout' + ]; + + commands.forEach(function(command, index) { asyncTest('`lodash ' + command +'`', function() { var written, start = _.once(QUnit.start), From 6fcd80b979fab248b3617dcaefa59e6ba2e393cd Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 8 Dec 2012 18:52:59 -0800 Subject: [PATCH 08/45] Update builds and docs. Former-commit-id: 647fe24574fc9bab2d32abb6e95f74d1cdd593f4 --- doc/README.md | 259 +++++++++++++++------------------------ lodash.js | 2 +- lodash.min.js | 58 ++++----- lodash.underscore.js | 110 ++++++++++++----- lodash.underscore.min.js | 54 ++++---- 5 files changed, 236 insertions(+), 247 deletions(-) diff --git a/doc/README.md b/doc/README.md index b85a94e74d..455cafffcd 100644 --- a/doc/README.md +++ b/doc/README.md @@ -36,9 +36,7 @@ ## `Chaining` * [`_`](#_value) -* [`_.chain`](#_chainvalue) * [`_.tap`](#_tapvalue-interceptor) -* [`_.prototype.chain`](#_prototypechain) * [`_.prototype.toString`](#_prototypetostring) * [`_.prototype.value`](#_prototypevalueof) * [`_.prototype.valueOf`](#_prototypevalueof) @@ -187,7 +185,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2634 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2679 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -211,7 +209,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2664 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2709 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -236,7 +234,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2699 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -264,7 +262,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2726 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2771 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -292,7 +290,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2768 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2813 "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, passing `true` for `fromIndex` will run a faster binary search. @@ -324,7 +322,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2803 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -349,7 +347,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2827 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2872 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -373,7 +371,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2865 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2910 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -398,7 +396,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2892 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2937 "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. @@ -427,7 +425,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2922 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2967 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -452,7 +450,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2967 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3012 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -490,7 +488,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3006 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3051 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -518,7 +516,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3050 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3095 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -562,7 +560,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3081 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3127 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -586,7 +584,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#L3115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3161 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -625,7 +623,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3173 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3221 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -650,7 +648,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3204 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3252 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -681,9 +679,9 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L254 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L275 "View in source") [Ⓣ][1] -The `lodash` function. +Creates a `lodash` object, that wraps the given `value`, to enable method chaining. The wrapper functions capable of chaining are: `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` The wrapper functions that do not chain are: `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, `mixin`, `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise unwrapped values are returned. #### Arguments 1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. @@ -696,43 +694,10 @@ The `lodash` function. - - -### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4074 "View in source") [Ⓣ][1] - -Wraps the value in a `lodash` wrapper object. - -#### Arguments -1. `value` *(Mixed)*: The value to wrap. - -#### Returns -*(Object)*: Returns the wrapper object. - -#### Example -```js -var stooges = [ - { 'name': 'moe', 'age': 40 }, - { 'name': 'larry', 'age': 50 }, - { 'name': 'curly', 'age': 60 } -]; - -var youngest = _.chain(stooges) - .sortBy(function(stooge) { return stooge.age; }) - .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) - .first(); -// => 'moe is 40' -``` - -* * * - - - - ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4099 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4121 "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. @@ -759,28 +724,6 @@ _.chain([1, 2, 3, 200]) - - -### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4122 "View in source") [Ⓣ][1] - -This function returns the wrapper object. Note: This function is defined to ensure the existing wrapper object is returned, instead of creating a new wrapper object like the `_.chain` method does. - -#### Returns -*(Mixed)*: Returns the wrapper object. - -#### Example -```js -var wrapped = _([1, 2, 3]); -wrapped === wrapped.chain(); -// => true -``` - -* * * - - - - ### `_.prototype.toString()` @@ -836,7 +779,7 @@ _([1, 2, 3]).valueOf(); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1904 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1932 "View in source") [Ⓣ][1] Checks if a given `target` element 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. @@ -874,7 +817,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1951 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1979 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -906,7 +849,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1980 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2009 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -935,7 +878,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2019 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2048 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -964,7 +907,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2063 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2092 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -993,7 +936,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2097 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2127 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1025,7 +968,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2125 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2155 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1057,7 +1000,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2157 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2188 "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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1086,7 +1029,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2189 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2220 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1118,7 +1061,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2231 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2262 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, 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)*. @@ -1150,7 +1093,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2277 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2308 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, 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)*. @@ -1176,7 +1119,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2326 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2357 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1207,7 +1150,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2350 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2381 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1237,7 +1180,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2379 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2423 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1268,7 +1211,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#L2417 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2461 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -1294,7 +1237,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2438 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2482 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1318,7 +1261,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2470 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2514 "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. @@ -1348,7 +1291,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2495 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2539 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds 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)*. @@ -1377,7 +1320,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2541 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2585 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1409,7 +1352,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2573 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2618 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1433,7 +1376,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2604 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2649 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1471,7 +1414,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3237 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3285 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1499,7 +1442,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3270 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3318 "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 passed to the bound function. @@ -1530,7 +1473,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3300 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3348 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1561,7 +1504,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3346 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3394 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. @@ -1602,7 +1545,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3369 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3417 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1629,7 +1572,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3402 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3450 "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. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1655,7 +1598,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3514 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1680,7 +1623,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3446 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3494 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1707,7 +1650,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3490 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3538 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1733,7 +1676,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3517 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3565 "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. @@ -1759,7 +1702,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3552 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3600 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1786,7 +1729,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3574 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3622 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1811,7 +1754,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3627 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3675 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1847,7 +1790,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L786 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L814 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1875,7 +1818,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L985 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1013 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, all nested objects will also be cloned, otherwise they will be assigned by reference. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm. See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. @@ -1914,7 +1857,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1073 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1101 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1940,7 +1883,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L842 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L870 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, 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`. @@ -1976,7 +1919,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L866 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L894 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, 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`. @@ -2004,7 +1947,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1092 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1120 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2031,7 +1974,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1117 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1145 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2056,7 +1999,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1162 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2080,7 +2023,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L804 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L832 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2107,7 +2050,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1158 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1186 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2134,7 +2077,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1175 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1203 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2158,7 +2101,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1192 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1220 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2182,7 +2125,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1209 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1237 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2206,7 +2149,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1234 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1262 "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". @@ -2236,7 +2179,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1276 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1304 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2267,7 +2210,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1428 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1456 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. @@ -2303,7 +2246,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1445 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1473 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2327,7 +2270,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1508 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1536 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. @@ -2360,7 +2303,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1530 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1558 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2387,7 +2330,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1547 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1575 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2411,7 +2354,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1475 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1503 "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('')`)* @@ -2441,7 +2384,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1575 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1603 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2476,7 +2419,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1600 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1628 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2500,7 +2443,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1617 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1645 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2524,7 +2467,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1634 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1662 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2548,7 +2491,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1651 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1679 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2572,7 +2515,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1689 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1717 "View in source") [Ⓣ][1] Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2607,7 +2550,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1763 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1791 "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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2638,7 +2581,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1797 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1825 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2662,7 +2605,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1830 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1858 "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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2693,7 +2636,7 @@ _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1867 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1895 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2724,7 +2667,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3651 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3699 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2748,7 +2691,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3719 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: This function is used throughout Lo-Dash as a default callback. @@ -2773,7 +2716,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3745 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2803,7 +2746,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3723 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3771 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2823,7 +2766,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3746 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3794 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2851,7 +2794,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3784 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3832 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2886,7 +2829,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3869 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3917 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html @@ -2960,7 +2903,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4000 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4048 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -2992,7 +2935,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4026 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4074 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3016,7 +2959,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4046 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4094 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3050,7 +2993,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4318 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4319 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3062,7 +3005,7 @@ _.uniqueId(); ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L275 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L296 "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. @@ -3074,7 +3017,7 @@ _.uniqueId(); ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L284 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L305 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3086,7 +3029,7 @@ _.uniqueId(); ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L293 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L314 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3098,7 +3041,7 @@ _.uniqueId(); ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L302 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L323 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3110,7 +3053,7 @@ _.uniqueId(); ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L311 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L332 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. diff --git a/lodash.js b/lodash.js index 9de8797781..04d13ce22b 100644 --- a/lodash.js +++ b/lodash.js @@ -266,7 +266,7 @@ * The wrapper functions `first` and `last` return wrapped values when `n` is * passed, otherwise unwrapped values are returned. * - * @name _, + * @name _ * @constructor * @category Chaining * @param {Mixed} value The value to wrap in a `lodash` instance. diff --git a/lodash.min.js b/lodash.min.js index acde0a7488..7f68b32d84 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -3,9 +3,9 @@ Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(e,t){function s(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof s))return new s(e);this.__wrapped__=e}function o(t,n){return e.eval("(function("+t+"){"+n+"})")}function u(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||it);if(i)for(var s={},n=t-1;++nt||"undefined"==typeof e)return 1;if(ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" +t=t.a;if(e!==t){if(e>t||"undefined"==typeof e)return 1;if(ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" ,o("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(c,Tt,b,A,on,_t,Ct)}function p(e){return"\\"+un[e]}function d(e){return dn[e]}function v(e){return"function"!=typeof e.toString&&"string"==typeof (e+"")}function m(){}function g(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Dt(0,s+n):n)||0;return"number"==typeof s?o=-1<(A(e)?e.indexOf(t,n):W(e,t,n)):wn(e,function(e){if(++r>=n)return!(o=e===t)}),o}function D(e,t,r){var i=n,t=c (t,r);if(gn(e))for(var r=-1,s=e.length;++rr&&(r=n,o=e)});else for(;++io&&(o=e[i]);return o}function F(e,t){return B(e,t+"")}function I(e,t,n,r){var s=3>arguments.length;return t||(t=K),wn(e,function(e,o,u){n=s?(s=i,e):t.call(r,n,e,o,u)}),n}function q(e,t,n,r){var s=e,o=e?e.length:0,u=3>arguments.length;if("number"!=typeof o)var a=bn(e),o=a.length;else en&&A(e)&& -(s=e.split(""));return t||(t=K),wn(e,function(e,f,l){f=a?a[--o]:--o,n=u?(u=i,s[f]):t.call(r,n,s[f],f,l)}),n}function R(e,t,n){var r,t=c(t,n);if(gn(e))for(var n=-1,i=e.length;++nn?Dt(0,i+n):n||0)-1;else if(n)return r=V(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])W(a,h))(n||f)&&a.push(h),u.push(r)}return u}function J(e,t){return $t||Lt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ut=/&(?:amp|lt|gt|quot|#x27);/g,at=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,lt=/(__e\(.*?\)|\b__t\))\+'';/g,ct=/\w*$/,ht=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,pt=RegExp("^"+(tt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),dt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,vt=/<%=([\s\S]+?)%>/g,mt=/($^)/,gt=/[&<>"']/g,yt=/['\n\r\t\u2028\u2029\\]/g,bt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf" -.split(" "),wt=Math.ceil,Et=et.concat,St=Math.floor,xt=pt.test(xt=Object.getPrototypeOf)&&xt,Tt=tt.hasOwnProperty,Nt=et.push,Ct=tt.propertyIsEnumerable,kt=tt.toString,Lt=pt.test(Lt=g.bind)&&Lt,At=pt.test(At=Array.isArray)&&At,Ot=e.isFinite,Mt=e.isNaN,_t=pt.test(_t=Object.keys)&&_t,Dt=Math.max,Pt=Math.min,Ht=Math.random,Bt="[object Arguments]",jt="[object Array]",Ft="[object Boolean]",It="[object Date]",qt="[object Number]",Rt="[object Object]",Ut="[object RegExp]",zt="[object String]",Wt=!/1/.test -(Function("1")),Xt=!!e.attachEvent,Vt=Lt&&!/\n|true/.test(Lt+Xt),$t=Lt&&!Vt,Jt=_t&&(Xt||Vt),Kt,Qt,Gt=(Gt={0:1,length:1},et.splice.call(Gt,0,1),Gt[0]),Yt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Yt=!n;Kt=!/valueOf/.test(t),Qt="x"!=t[0]})(1);var Zt=!b(arguments),en="xx"!="x"[0]+Object("x")[0];try{var tn=("[object Object]",kt.call(document)==Rt)}catch(nn){}var rn={"[object Function]":i};rn[Bt]=rn[jt]=rn[Ft]=rn[It]=rn[qt]= -rn[Rt]=rn[Ut]=rn[zt]=n;var sn={};sn[jt]=Array,sn[Ft]=Boolean,sn[It]=Date,sn[Rt]=Object,sn[qt]=Number,sn[Ut]=RegExp,sn[zt]=String;var on={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},un={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:vt,variable:""};if(Xt||Vt||!Wt)o=Function;var an={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},vn=T(dn),mn=h(an,{g:"if(t[i]==null)"+an.g}),gn=At||function(e){return kt.call(e)==jt};C(/x/)&&(C=function(e){return"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof -e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!b(e):w(e)}:w,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?E(e):k(e)?_t(e):[]}:E,wn=h(fn);s.assign=cn,s.bindAll=function(e){for(var t=arguments,n=1W(i,e)){for(var s=n;--s;)if(!(r[s]||(r[s]=u(t[s])))(e))return;i.push(e)}}),i},s.invert=T,s.invoke=function(e,t){var n=g(arguments,2),r="function"==typeof t,i=[];return wn(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.merge=O,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&A(e)?a:c(t,n),wn(e,function(e,n,i) -{n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([n,e])}),t},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply -(et,arguments),o=s.length;++ie?t():function(){if(1>--e)return t.apply(this,arguments)}},s.bind=J,s.bindKey=function(e,t){return l(e,t,g -(arguments,2))},s.clone=S,s.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length;n--;)t=[e[n].apply(this,t)];return t[0]}},s.contains=_,s.debounce=function(e,t,n){function i(){a=r,n||(o=e.apply(u,s))}var s,o,u,a;return function(){var r=n&&!a;return s=arguments,u=this,clearTimeout(a),a=setTimeout(i,t),r&&(o=e.apply(u,s)),o}},s.defer=function(e){var n=g(arguments,1);return setTimeout(function(){e.apply(t,n)},1)},s.delay=function(e,n){var r=g(arguments,2);return setTimeout -(function(){e.apply(t,r)},n)},s.escape=function(e){return e==r?"":(e+"").replace(gt,d)},s.every=D,s.find=H,s.has=function(e,t){return e?Tt.call(e,t):i},s.identity=K,s.indexOf=W,s.isArguments=b,s.isArray=gn,s.isBoolean=function(e){return e===n||e===i||kt.call(e)==Ft},s.isDate=function(e){return kt.call(e)==It},s.isElement=function(e){return e?1===e.nodeType:i},s.isEmpty=function(e){var t=n;if(!e)return t;var r=kt.call(e),s=e.length;return r==jt||r==zt||r==Bt||Zt&&b(e)||r==Rt&&"number"==typeof s&&C -(e.splice)?!s:(pn(e,function(){return t=i}),t)},s.isEqual=N,s.isFinite=function(e){return Ot(e)&&!Mt(parseFloat(e))},s.isFunction=C,s.isNaN=function(e){return L(e)&&e!=+e},s.isNull=function(e){return e===r},s.isNumber=L,s.isObject=k,s.isPlainObject=yn,s.isRegExp=function(e){return kt.call(e)==Ut},s.isString=A,s.isUndefined=function(e){return"undefined"==typeof e},s.lastIndexOf=function(e,t,n){var r=e?e.length:0;for("number"==typeof n&&(r=(0>n?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1 -},s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.partial=function(e){return l(e,g(arguments,1))},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e, -t){var n=e?e[t]:r;return C(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,u=s.templateSettings,a=0,f=n.interpolate||u.interpolate||mt,l="__p+='",c=n.variable||u.variable,h=c;e.replace(RegExp((n.escape||u.escape||mt).source+"|"+f.source+"|"+(f===vt?dt:mt).source+"|"+(n.evaluate||u.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,u){return i||(i=s),l+=e.slice(a,u).replace(yt -,p),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),i&&(l+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),a=u+t.length,t}),l+="';\n",h||(c="obj",r?l="with("+c+"){"+l+"}":(n=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ht,"$&"+c+".").replace(n,"$1__d"))),l=(r?l.replace(at,""):l).replace(ft,"$1").replace(lt,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+ -c+"."+c+"||"+c)+";")+l+"return __p}";try{i=o("_","return "+l)(s)}catch(d){throw d.source=l,d}return t?i(t):(i.source=l,i)},s.throttle=function(e,t){function n(){a=new Date,u=r,s=e.apply(o,i)}var i,s,o,u,a=0;return function(){var f=new Date,l=t-(f-a);return i=arguments,o=this,0>=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.unescape=function(e){return e==r?"":(e+"").replace(ut,y)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.wrap=function(e,t){return function(){var n= -[e];return Nt.apply(n,arguments),t.apply(this,n)}},s.all=D,s.any=R,s.detect=H,s.foldl=I,s.foldr=q,s.include=_,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:g(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2" -,s.prototype.chain=function(){return this},s.prototype.toString=function(){return""+this.__wrapped__},s.prototype.value=G,s.prototype.valueOf=G,wn("pop push reverse shift sort splice unshift".split(" "),function(e){var t=et[e];s.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Gt&&e.length===0&&delete e[0],this}}),wn(["concat","join","slice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),typeof define=="function"&&typeof -define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file +(e,function(e,n,i){s[++r]=t(e,n,i)});return s}function j(e,t,n){var r=-Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&A(e)?a:c(t,n),wn(e,function(e,n,i){n=t(e,n,i),n>r&&(r=n,o=e)});else for(;++io&&(o=e[i]);return o}function F(e,t){return B(e,t+"")}function I(e,t,r,s){var o=3>arguments.length,t=c(t,s,n);if(gn(e)){var u=-1,a=e.length;for(o&&(r=e[++u]);++uarguments +.length;if("number"!=typeof u)var f=bn(e),u=f.length;else en&&A(e)&&(o=e.split(""));return t=c(t,s,n),wn(e,function(e,n,s){n=f?f[--u]:--u,r=a?(a=i,o[n]):t(r,o[n],n,s)}),r}function R(e,t,n){var r,t=c(t,n);if(gn(e))for(var n=-1,i=e.length;++nn?Dt(0,i+n):n||0)-1;else if(n)return r=V(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])W(a,h))(n||f)&&a.push(h),u.push(r)}return u}function J(e,t){return $t||Lt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ut=/&(?:amp|lt|gt|quot|#x27);/g,at=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,lt=/(__e\(.*?\)|\b__t\))\+'';/g,ct=/\w*$/,ht=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,pt=RegExp("^"+(tt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),dt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,vt=/<%=([\s\S]+?)%>/g +,mt=/($^)/,gt=/[&<>"']/g,yt=/['\n\r\t\u2028\u2029\\]/g,bt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),wt=Math.ceil,Et=et.concat,St=Math.floor,xt=pt.test(xt=Object.getPrototypeOf)&&xt,Tt=tt.hasOwnProperty,Nt=et.push,Ct=tt.propertyIsEnumerable,kt=tt.toString,Lt=pt.test(Lt=g.bind)&&Lt,At=pt.test(At=Array.isArray)&&At,Ot=e.isFinite,Mt=e.isNaN,_t=pt.test(_t=Object.keys)&&_t,Dt=Math.max,Pt=Math.min,Ht=Math.random,Bt="[object Arguments]",jt="[object Array]" +,Ft="[object Boolean]",It="[object Date]",qt="[object Number]",Rt="[object Object]",Ut="[object RegExp]",zt="[object String]",Wt=!/1/.test(Function("1")),Xt=!!e.attachEvent,Vt=Lt&&!/\n|true/.test(Lt+Xt),$t=Lt&&!Vt,Jt=_t&&(Xt||Vt),Kt,Qt,Gt=(Gt={0:1,length:1},et.splice.call(Gt,0,1),Gt[0]),Yt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Yt=!n;Kt=!/valueOf/.test(t),Qt="x"!=t[0]})(1);var Zt=!b(arguments),en="xx"!="x"[0]+Object +("x")[0];try{var tn=("[object Object]",kt.call(document)==Rt)}catch(nn){}var rn={"[object Function]":i};rn[Bt]=rn[jt]=rn[Ft]=rn[It]=rn[qt]=rn[Rt]=rn[Ut]=rn[zt]=n;var sn={};sn[jt]=Array,sn[Ft]=Boolean,sn[It]=Date,sn[Rt]=Object,sn[qt]=Number,sn[Ut]=RegExp,sn[zt]=String;var on={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},un={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate +:vt,variable:""};if(Xt||Vt||!Wt)o=Function;var an={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},vn=T(dn),mn=h(an,{g:"if(t[i]==null)"+ +an.g}),gn=At||function(e){return kt.call(e)==jt};C(/x/)&&(C=function(e){return"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!b(e):w(e)}:w,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?E(e):k(e)?_t(e):[]}:E,wn=h(fn);s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},s.assign=cn,s.bind=J,s.bindAll=function(e){for( +var t=arguments,n=1W(i,e)){for(var s=n;--s;)if(!(r[s]||(r[s]=u(t[s])))(e))return;i.push(e)}}),i},s.invert=T,s.invoke=function( +e,t){var n=g(arguments,2),r="function"==typeof t,i=[];return wn(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=O,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&A(e)?a:c(t,n),wn(e,function(e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([n,e])}),t},s.partial=function(e){return l(e,g(arguments,1))},s.pick=function(e, +t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e +);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return C(n)?e[t]():n},s.size=function(e) +{var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,u=s.templateSettings,a=0,f=n.interpolate||u.interpolate||mt,l="__p+='",c=n.variable||u.variable,h=c;e.replace(RegExp((n.escape||u.escape||mt).source+"|"+f.source+"|"+(f===vt?dt:mt).source+"|"+(n.evaluate||u.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,u){return i||(i=s),l+=e.slice(a,u).replace(yt,p),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),i&&( +l+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),a=u+t.length,t}),l+="';\n",h||(c="obj",r?l="with("+c+"){"+l+"}":(n=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ht,"$&"+c+".").replace(n,"$1__d"))),l=(r?l.replace(at,""):l).replace(ft,"$1").replace(lt,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{i=o("_","return "+ +l)(s)}catch(d){throw d.source=l,d}return t?i(t):(i.source=l,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,y)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=D,s.any=R,s.detect=H,s.foldl=I,s.foldr=q,s.include=_,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:g(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function( +e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return""+this.__wrapped__},s.prototype.value=G,s.prototype.valueOf=G,wn("pop push reverse shift sort splice unshift".split(" "),function(e){var t=et[e];s.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Gt&&e.length===0&&delete e[0],this}}),wn(["concat","join","slice"],function(e){var t=et[e];s.prototype[e]= +function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 7760563d10..c3e7970230 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -182,7 +182,28 @@ /*--------------------------------------------------------------------------*/ /** - * The `lodash` function. + * Creates a `lodash` object, that wraps the given `value`, to enable + * method chaining. + * + * The wrapper functions capable of chaining are: + * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, + * `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, + * `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, + * `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, + * `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, + * `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, + * `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` + * + * The wrapper functions that do not chain are: + * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, + * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, + * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, + * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, + * `mixin`, `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, + * `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` + * + * The wrapper functions `first` and `last` return wrapped values when `n` is + * passed, otherwise unwrapped values are returned. * * @name _ * @constructor @@ -366,9 +387,11 @@ * @param {Function|String} [func=identity|property] The function called per * iteration or property name to query. * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @param {Boolean} [accumulating] A flag to indicate creating a callback + * that accepts an `accumulator` argument. * @returns {Function} Returns a callback function. */ - function createCallback(func, thisArg) { + function createCallback(func, thisArg, accumulating) { if (!func) { return identity; } @@ -378,6 +401,11 @@ }; } if (typeof thisArg != 'undefined') { + if (accumulating) { + return function(accumulator, value, index, object) { + return func.call(thisArg, accumulator, value, index, object); + }; + } return function(value, index, object) { return func.call(thisArg, value, index, object); }; @@ -1521,6 +1549,7 @@ function countBy(collection, callback, thisArg) { var result = {}; callback = createCallback(callback, thisArg); + forEach(collection, function(value, key, collection) { key = callback(value, key, collection); (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); @@ -1633,6 +1662,7 @@ function find(collection, callback, thisArg) { var result; callback = createCallback(callback, thisArg); + forEach(collection, function(value, index, collection) { if (callback(value, index, collection)) { result = value; @@ -1713,6 +1743,7 @@ function groupBy(collection, callback, thisArg) { var result = {}; callback = createCallback(callback, thisArg); + forEach(collection, function(value, key, collection) { key = callback(value, key, collection); (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); @@ -1933,12 +1964,25 @@ */ function reduce(collection, callback, accumulator, thisArg) { var noaccum = arguments.length < 3; - callback || (callback = identity); - forEach(collection, function(value, index, collection) { - accumulator = noaccum - ? (noaccum = false, value) - : callback.call(thisArg, accumulator, value, index, collection) - }); + callback = createCallback(callback, thisArg, true); + + if (isArray(collection)) { + var index = -1, + length = collection.length; + + if (noaccum) { + accumulator = collection[++index]; + } + while (++index < length) { + accumulator = callback(accumulator, collection[index], index, collection); + } + } else { + forEach(collection, function(value, index, collection) { + accumulator = noaccum + ? (noaccum = false, value) + : callback(accumulator, value, index, collection) + }); + } return accumulator; } @@ -1969,12 +2013,12 @@ var props = keys(collection); length = props.length; } - callback || (callback = identity); + callback = createCallback(callback, thisArg, true); forEach(collection, function(value, index, collection) { index = props ? props[--length] : --length; accumulator = noaccum ? (noaccum = false, iteratee[index]) - : callback.call(thisArg, accumulator, iteratee[index], index, collection); + : callback(accumulator, iteratee[index], index, collection); }); return accumulator; } @@ -2123,6 +2167,7 @@ function sortBy(collection, callback, thisArg) { var result = []; callback = createCallback(callback, thisArg); + forEach(collection, function(value, index, collection) { result.push({ 'criteria': callback(value, index, collection), @@ -2629,9 +2674,10 @@ var low = 0, high = array ? array.length : low; - // explicitly reference `identity` for better engine inlining + // explicitly reference `identity` for better inlining in Firefox callback = callback ? createCallback(callback, thisArg) : identity; value = callback(value); + while (low < high) { var mid = (low + high) >>> 1; callback(array[mid]) < value @@ -3501,7 +3547,7 @@ /*--------------------------------------------------------------------------*/ /** - * Wraps the value in a `lodash` wrapper object. + * Creates a `lodash` object that wraps the given `value`. * * @static * @memberOf _ @@ -3555,22 +3601,19 @@ } /** - * This function returns the wrapper object. - * - * Note: This function is defined to ensure the existing wrapper object is - * returned, instead of creating a new wrapper object like the `_.chain` - * method does. + * Enables method chaining on the wrapper object. * * @name chain - * @deprecated * @memberOf _ * @category Chaining * @returns {Mixed} Returns the wrapper object. * @example * - * var wrapped = _([1, 2, 3]); - * wrapped === wrapped.chain(); - * // => true + * var sum = _([1, 2, 3]) + * .chain() + * .reduce(function(sum, num) { return sum + num; }) + * .value() + * // => 6` */ function wrapperChain() { this.__chain__ = true; @@ -3612,11 +3655,18 @@ /*--------------------------------------------------------------------------*/ + // add functions that return wrapped values when chaining + + lodash.after = after; + lodash.bind = bind; lodash.bindAll = bindAll; - lodash.chain = chain; lodash.compact = compact; + lodash.compose = compose; lodash.countBy = countBy; + lodash.debounce = debounce; lodash.defaults = defaults; + lodash.defer = defer; + lodash.delay = delay; lodash.difference = difference; lodash.filter = filter; lodash.flatten = flatten; @@ -3630,9 +3680,11 @@ lodash.keys = keys; lodash.map = map; lodash.max = max; + lodash.memoize = memoize; lodash.min = min; lodash.object = object; lodash.omit = omit; + lodash.once = once; lodash.pairs = pairs; lodash.pick = pick; lodash.pluck = pluck; @@ -3642,6 +3694,7 @@ lodash.shuffle = shuffle; lodash.sortBy = sortBy; lodash.tap = tap; + lodash.throttle = throttle; lodash.times = times; lodash.toArray = toArray; lodash.union = union; @@ -3649,6 +3702,7 @@ lodash.values = values; lodash.where = where; lodash.without = without; + lodash.wrap = wrap; lodash.zip = zip; // add aliases @@ -3664,14 +3718,8 @@ /*--------------------------------------------------------------------------*/ // add functions that return unwrapped values when chaining - lodash.after = after; - lodash.bind = bind; lodash.clone = clone; - lodash.compose = compose; lodash.contains = contains; - lodash.debounce = debounce; - lodash.defer = defer; - lodash.delay = delay; lodash.escape = escape; lodash.every = every; lodash.find = find; @@ -3694,10 +3742,8 @@ lodash.isString = isString; lodash.isUndefined = isUndefined; lodash.lastIndexOf = lastIndexOf; - lodash.memoize = memoize; lodash.mixin = mixin; lodash.noConflict = noConflict; - lodash.once = once; lodash.random = random; lodash.reduce = reduce; lodash.reduceRight = reduceRight; @@ -3706,10 +3752,8 @@ lodash.some = some; lodash.sortedIndex = sortedIndex; lodash.template = template; - lodash.throttle = throttle; lodash.unescape = unescape; lodash.uniqueId = uniqueId; - lodash.wrap = wrap; // add aliases lodash.all = every; @@ -3732,6 +3776,8 @@ /*--------------------------------------------------------------------------*/ + lodash.chain = chain; + /** * The semantic version number. * diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index afeffa6a05..b32d1a92ee 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -4,30 +4,30 @@ Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(e,t){function n(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||"undefined"==typeof e)return 1;if(en?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function L(e,t){return C(e,t+"")}function A(e,t,n,r){var i=3>arguments.length;return t||(t=I),At(e,function(e,s,o){n=i?(i=!1,e):t.call(r,n,e,s,o)}),n}function O(e,t,n,r){var i=e?e.length:0,s=3>arguments.length;if("number"!=typeof i)var o=Lt(e),i=o.length;return t||(t=I -),At(e,function(u,a,f){a=o?o[--i]:--i,n=s?(s=!1,e[a]):t.call(r,n,e[a],a,f)}),n}function M(e,t,n){var r,t=s(t,n);if(kt(e))for(var n=-1,i=e.length;++nn?ft -(0,i+n):n||0)-1;else if(n)return r=B(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])P(a,f))n&&a.push(f),u.push(r)}return u}function F(e,t){return bt|| -it&&2"']/g,G=/['\n\r\t\u2028\u2029\\]/g,Y=Math.ceil,Z=z.concat,et=Math.floor,tt=U.hasOwnProperty,nt=z.push,rt=U.toString,it=J.test(it=f.bind)&&it,st=J.test(st=Array.isArray)&&st,ot=e.isFinite,ut=e.isNaN,at=J.test(at=Object.keys)&&at,ft=Math.max,lt=Math.min,ct=Math.random,ht="[object Array]",pt="[object Boolean]",dt="[object Date]",vt="[object Number]",mt="[object Object]",gt="[object RegExp]",yt="[object String]",U=!!e.attachEvent,U=it&&!/\n|true/ -.test(it+U),bt=it&&!U,wt=(wt={0:1,length:1},z.splice.call(wt,0,1),wt[0]),Et={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},St={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},n.isArguments=function(e){return"[object Arguments]"==rt.call(e)},n.isArguments(arguments)||(n.isArguments=function(e){return e?tt.call(e,"callee"):!1} -);var xt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(t(e[n],n,e)===X)break;return e},Tt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(tt.call(e,n)&&t(e[n],n,e)===X)break;return e},Nt={"&":"&","<":"<",">":">",'"':""","'":"'"},Ct=v(Nt),kt=st||function(e){return rt.call(e)==ht};g(/x/)&&(g=function(e){return"[object Function]"==rt.call(e)});var Lt=at?function(e){return y(e)?at(e):[]}:h,At=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t -,n),r=e.length,n=-1;if("number"==typeof r){for(;++nP(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=D,n.forEach=At,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return At(e,function(e,n,i){n=t(e,n,i),(tt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,lt(ft(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length -,r=[];return At(e,function(e){if(0>P(r,e)){for(var i=n;--i;)if(0>P(t[i],e))return;r.push(e)}}),r},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return At(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Lt,n.map=C,n.max=k,n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!kt(e))t=s(t,n),At(e,function(e,n,i){n=t(e,n,i),nP(t,r,1)&&(n[r]=e)}),n},n.pairs=function(e){var t=[];return Tt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=Z.apply(z,arguments),r=n.length,i={};++tP(arguments,i,1)&&r.push(i)}return r},n.zip=function(e){for(var t=-1,n=e?k(L(arguments,"length")):0,r=Array(n);++te?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=F,n.clone=function(e){return e&&Et[typeof e]?kt(e)?f(e):c({},e):e},n.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length;n--;)t=[e[n].apply(this,t)];return t[0]}},n.contains=S,n.debounce=function(e,t,n){function r(){u=null,n||(s=e.apply(o,i))}var i,s,o,u;return function(){var a=n&&!u;return i=arguments,o=this,clearTimeout(u),u=setTimeout( -r,t),a&&(s=e.apply(o,i)),s}},n.defer=function(e){var n=f(arguments,1);return setTimeout(function(){e.apply(t,n)},1)},n.delay=function(e,n){var r=f(arguments,2);return setTimeout(function(){e.apply(t,r)},n)},n.escape=function(e){return null==e?"":(e+"").replace(Q,u)},n.every=x,n.find=N,n.has=function(e,t){return e?tt.call(e,t):!1},n.identity=I,n.indexOf=P,n.isArray=kt,n.isBoolean=function(e){return!0===e||!1===e||rt.call(e)==pt},n.isDate=function(e){return rt.call(e)==dt},n.isElement=function(e){return e?1=== -e.nodeType:!1},n.isEmpty=function(e){if(!e)return!0;if(kt(e)||w(e))return!e.length;for(var t in e)if(tt.call(e,t))return!1;return!0},n.isEqual=m,n.isFinite=function(e){return ot(e)&&!ut(parseFloat(e))},n.isFunction=g,n.isNaN=function(e){return b(e)&&e!=+e},n.isNull=function(e){return null===e},n.isNumber=b,n.isObject=y,n.isRegExp=function(e){return rt.call(e)==gt},n.isString=w,n.isUndefined=function(e){return"undefined"==typeof e},n.lastIndexOf=function(e,t,n){var r=e?e.length:0;for("number"==typeof -n&&(r=(0>n?ft(0,r+n):lt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.mixin=q,n.noConflict=function(){return e._=V,this},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+et(ct()*((+t||0)-e+1))},n.reduce=A,n.reduceRight= -O,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Lt(e).length},n.some=M,n.sortedIndex=B,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||K).source+"|"+(r.interpolate||K).source+"|"+(r.evaluate||K).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(G,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'" -:"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.throttle=function(e,t){function n(){u=new Date,o=null,i=e.apply(s,r)}var r,i,s,o,u=0;return function(){var a=new Date,f=t-(a-u);return r=arguments,s=this,0>=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout -(n,f)),i}},n.unescape=function(e){return null==e?"":(e+"").replace($,l)},n.uniqueId=function(e){var t=++W+"";return e?e+t:t},n.wrap=function(e,t){return function(){var n=[e];return nt.apply(n,arguments),t.apply(this,n)}},n.all=x,n.any=M,n.detect=N,n.foldl=A,n.foldr=O,n.include=S,n.inject=A,n.first=_,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,ft(0,r-t))}},n.take=_,n.head=_,n.VERSION="1.0.0-rc.2",q(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype -.value=function(){return this.__wrapped__},At("pop push reverse shift sort splice unshift".split(" "),function(e){var t=z[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),wt&&e.length===0&&delete e[0],this}}),At(["concat","join","slice"],function(e){var t=z[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),R?"object"==typeof module&&module&&module.exports==R?(module.exports=n)._=n:R._=n:e._= -n})(this); \ No newline at end of file +(e,t,n){return e?"function"!=typeof e?function(t){return t[e]}:"undefined"!=typeof t?n?function(n,r,i,s){return e.call(t,n,r,i,s)}:function(n,r,i){return e.call(t,n,r,i)}:e:I}function o(e){return"\\"+St[e]}function u(e){return Nt[e]}function a(){}function f(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function L(e,t){return C(e,t+"")}function A(e,t,n,r){var i=3>arguments.length,t=s(t,r,!0);if(kt(e)){var o=-1,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if("number"!=typeof i)var u=Lt(e),i=u.length;return t=s(t,r,!0),At(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function M(e,t,n){var r,t=s(t,n);if(kt(e))for(var n=-1,i=e.length;++nn?ft(0,i+n):n||0)-1;else if(n)return r=B(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])P(a,f))n&&a.push(f),u.push(r)}return u}function F(e,t){return bt||it&&2"']/g,G=/['\n\r\t\u2028\u2029\\]/g,Y=Math.ceil,Z=z.concat,et=Math.floor,tt=U.hasOwnProperty,nt=z.push,rt=U.toString,it=J.test(it=f.bind)&&it,st=J.test(st=Array.isArray)&&st,ot=e.isFinite,ut=e.isNaN,at=J.test(at=Object.keys)&&at,ft=Math.max,lt=Math.min,ct=Math.random,ht="[object Array]",pt="[object Boolean]" +,dt="[object Date]",vt="[object Number]",mt="[object Object]",gt="[object RegExp]",yt="[object String]",U=!!e.attachEvent,U=it&&!/\n|true/.test(it+U),bt=it&&!U,wt=(wt={0:1,length:1},z.splice.call(wt,0,1),wt[0]),Et={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},St={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},n.isArguments= +function(e){return"[object Arguments]"==rt.call(e)},n.isArguments(arguments)||(n.isArguments=function(e){return e?tt.call(e,"callee"):!1});var xt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(t(e[n],n,e)===X)break;return e},Tt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(tt.call(e,n)&&t(e[n],n,e)===X)break;return e},Nt={"&":"&","<":"<",">":">",'"':""","'":"'"},Ct=v(Nt),kt=st||function(e){return rt.call(e)==ht};g(/x/)&&(g=function(e){return"[object Function]"== +rt.call(e)});var Lt=at?function(e){return y(e)?at(e):[]}:h,At=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++ne?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=F,n.bindAll=function(e){for(var t=arguments,n=1P(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=D,n.forEach=At,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return At(e,function(e,n,i){n=t(e,n,i),(tt.call(r,n)?r[n]:r[n]=[]). +push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,lt(ft(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=[];return At(e,function(e){if(0>P(r,e)){for(var i=n;--i;)if(0>P(t[i],e))return;r.push(e)}}),r},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return At(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Lt,n.map=C,n.max=k,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply +(this,arguments):arguments[0];return tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!kt(e))t=s(t,n),At(e,function(e,n,i){n=t(e,n,i),nP(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1 +;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Tt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=Z.apply(z,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o|| +(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rP(arguments,i,1)&&r.push(i)}return r},n.wrap= +function(e,t){return function(){var n=[e];return nt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?k(L(arguments,"length")):0,r=Array(n);++tn?ft(0,r+n):lt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=q,n.noConflict=function(){return e._=V,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+et(ct()*((+t||0)-e+1))},n.reduce=A,n.reduceRight=O,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function( +e){var t=e?e.length:0;return"number"==typeof t?t:Lt(e).length},n.some=M,n.sortedIndex=B,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||K).source+"|"+(r.interpolate||K).source+"|"+(r.evaluate||K).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(G,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+ +u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace($,l)},n.uniqueId=function(e){var t=++W+"";return e?e+t:t},n.all=x,n.any=M,n.detect=N,n.foldl=A,n.foldr=O,n.include=S,n.inject=A,n.first=_,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,ft(0,r-t))}},n.take=_,n.head= +_,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.2",q(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},At("pop push reverse shift sort splice unshift".split(" "),function(e){var t=z[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),wt&&e.length===0&&delete e[0],this}}),At(["concat","join","slice"],function(e){var t=z[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__ +,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),R?"object"==typeof module&&module&&module.exports==R?(module.exports=n)._=n:R._=n:e._=n})(this); \ No newline at end of file From 38edbadca568c68e686aacae2356a7f02152784e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 8 Dec 2012 18:53:45 -0800 Subject: [PATCH 09/45] Update Lo-Dash description. Former-commit-id: 75703b13b95399107b11f109dcc6d3b3dfd9eabe --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 06e15d91be..a56b34a6b9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Lo-Dash v1.0.0-rc.2 [![build status](https://secure.travis-ci.org/bestiejs/lodash.png)](http://travis-ci.org/bestiejs/lodash) -A utility library, usable as a drop-in replacement for Underscore, delivering [performance](http://lodash.com/benchmarks), [bug fixes](https://github.com/bestiejs/lodash#resolved-underscorejs-issues), and [additional features](http://lodash.com/#features). +An alternative to Underscore.js, delivering [consistency](https://github.com/bestiejs/lodash#resolved-underscorejs-issues), [customization](https://github.com/bestiejs/lodash#custom-builds), [performance](http://lodash.com/benchmarks), and [extra features](https://github.com/bestiejs/lodash#features). ## Download diff --git a/package.json b/package.json index b2a0a20832..c529f38585 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lodash", "version": "1.0.0-rc.2", - "description": "A utility library, usable as a drop-in replacement for Underscore, delivering performance, bug fixes, and additional features.", + "description": "An alternative to Underscore.js, delivering consistency, customization, performance, and extra features.", "homepage": "http://lodash.com", "main": "./lodash", "keywords": [ From 1831efbe9d8f8d92178d8600779c9ca8bc0bedc0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 8 Dec 2012 21:24:40 -0800 Subject: [PATCH 10/45] Cleanup build and doc comments. Former-commit-id: 861145621113c0b6719b24d00ce0e359360ee1eb --- build.js | 231 ++++++++++++++++++++++++++------------------------ doc/README.md | 2 +- lodash.js | 18 ++-- 3 files changed, 132 insertions(+), 119 deletions(-) diff --git a/build.js b/build.js index e8476b684b..59c515b652 100755 --- a/build.js +++ b/build.js @@ -257,7 +257,126 @@ /*--------------------------------------------------------------------------*/ /** - * Adds the given build `commands` to the copyright/license header of `source`. + * Adds support for Underscore style chaining to the `source`. + * + * @private + * @param {String} source The source to process. + * @returns {String} Returns the modified source. + */ + function addChainMethods(source) { + // add `_.chain` + source = source.replace(matchFunction(source, 'tap'), function(match) { + return [ + '', + ' /**', + ' * Creates a `lodash` object that wraps the given `value`.', + ' *', + ' * @static', + ' * @memberOf _', + ' * @category Chaining', + ' * @param {Mixed} value The value to wrap.', + ' * @returns {Object} Returns the wrapper object.', + ' * @example', + ' *', + ' * var stooges = [', + " * { 'name': 'moe', 'age': 40 },", + " * { 'name': 'larry', 'age': 50 },", + " * { 'name': 'curly', 'age': 60 }", + ' * ];', + ' *', + ' * var youngest = _.chain(stooges)', + ' * .sortBy(function(stooge) { return stooge.age; })', + " * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; })", + ' * .first();', + " * // => 'moe is 40'", + ' */', + ' function chain(value) {', + ' value = new lodash(value);', + ' value.__chain__ = true;', + ' return value;', + ' }', + '', + match + ].join('\n'); + }); + + // add `wrapperChain` + source = source.replace(matchFunction(source, 'wrapperToString'), function(match) { + return [ + '', + ' /**', + ' * Enables method chaining on the wrapper object.', + ' *', + ' * @name chain', + ' * @memberOf _', + ' * @category Chaining', + ' * @returns {Mixed} Returns the wrapper object.', + ' * @example', + ' *', + ' * var sum = _([1, 2, 3])', + ' * .chain()', + ' * .reduce(function(sum, num) { return sum + num; })', + ' * .value()', + ' * // => 6`', + ' */', + ' function wrapperChain() {', + ' this.__chain__ = true;', + ' return this;', + ' }', + '', + match + ].join('\n'); + }); + + // add `__chain__` checks to `_.mixin` and `Array` function wrappers + _.each([ + matchFunction(source, 'mixin'), + /(?:\s*\/\/.*)*\n( *)forEach\(\['[\s\S]+?\n\1}.+/g + ], function(pattern) { + source = source.replace(pattern, function(match) { + return match.replace(/( *)return new lodash\(([^)]+)\).+/, function(submatch, indent, varName) { + return indent + [ + 'if (this.__chain__) {', + ' varName = new lodash(varName);', + ' varName.__chain__ = true;', + '}', + 'return varName;' + ].join('\n' + indent) + .replace(/varName/g, varName); + }); + }); + }); + + // add `lodash.chain` assignment + source = source.replace(getMethodAssignments(source), function(match) { + return match.replace(/^(?: *\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\n)?( *)lodash\.VERSION *=/m, '$1lodash.chain = chain;\n\n$&'); + }); + + // add `lodash.prototype.chain` assignment + source = source.replace(/^( *)lodash\.prototype\.value *=.+\n/m, '$1lodash.prototype.chain = wrapperChain;\n$&'); + + // remove `lodash.prototype.toString` and `lodash.prototype.valueOf` assignments + source = source.replace(/^ *lodash\.prototype\.(?:toString|valueOf) *=.+\n/gm, ''); + + // remove `lodash.prototype` batch method assignments + source = source.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, ''); + + // move `mixin(lodash)` to after the method assignments + source = source.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+/, ''); + source = source.replace(getMethodAssignments(source), function(match) { + return match + [ + '', + '', + ' // add functions to `lodash.prototype`', + ' mixin(lodash);' + ].join('\n'); + }); + + return source; + } + + /** + * Adds build `commands` to the copyright/license header of the `source`. * * @private * @param {String} source The source to process. @@ -1177,115 +1296,9 @@ source = replaceVar(source, 'noArgsClass', 'true'); source = removeKeysOptimization(source); } - // add Underscore's chaining API if (isBackbone || isUnderscore) { - // add `_.chain` - source = source.replace(matchFunction(source, 'tap'), function(match) { - return [ - '', - ' /**', - ' * Creates a `lodash` object that wraps the given `value`.', - ' *', - ' * @static', - ' * @memberOf _', - ' * @category Chaining', - ' * @param {Mixed} value The value to wrap.', - ' * @returns {Object} Returns the wrapper object.', - ' * @example', - ' *', - ' * var stooges = [', - " * { 'name': 'moe', 'age': 40 },", - " * { 'name': 'larry', 'age': 50 },", - " * { 'name': 'curly', 'age': 60 }", - ' * ];', - ' *', - ' * var youngest = _.chain(stooges)', - ' * .sortBy(function(stooge) { return stooge.age; })', - " * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; })", - ' * .first();', - " * // => 'moe is 40'", - ' */', - ' function chain(value) {', - ' value = new lodash(value);', - ' value.__chain__ = true;', - ' return value;', - ' }', - '', - match - ].join('\n'); - }); - - // add `wrapperChain` - source = source.replace(matchFunction(source, 'wrapperToString'), function(match) { - return [ - '', - ' /**', - ' * Enables method chaining on the wrapper object.', - ' *', - ' * @name chain', - ' * @memberOf _', - ' * @category Chaining', - ' * @returns {Mixed} Returns the wrapper object.', - ' * @example', - ' *', - ' * var sum = _([1, 2, 3])', - ' * .chain()', - ' * .reduce(function(sum, num) { return sum + num; })', - ' * .value()', - ' * // => 6`', - ' */', - ' function wrapperChain() {', - ' this.__chain__ = true;', - ' return this;', - ' }', - '', - match - ].join('\n'); - }); - - // add `__chain__` checks to `_.mixin` and `Array` function wrappers - _.each([ - matchFunction(source, 'mixin'), - /(?:\s*\/\/.*)*\n( *)forEach\(\['[\s\S]+?\n\1}.+/g - ], function(pattern) { - source = source.replace(pattern, function(match) { - return match.replace(/( *)return new lodash\(([^)]+)\).+/, function(submatch, indent, varName) { - return indent + [ - 'if (this.__chain__) {', - ' varName = new lodash(varName);', - ' varName.__chain__ = true;', - '}', - 'return varName;' - ].join('\n' + indent) - .replace(/varName/g, varName); - }); - }); - }); - - // add `lodash.chain` assignment - source = source.replace(getMethodAssignments(source), function(match) { - return match.replace(/^(?: *\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\n)?( *)lodash\.VERSION *=/m, '$1lodash.chain = chain;\n\n$&'); - }); - - // add `lodash.prototype.chain` assignment - source = source.replace(/^( *)lodash\.prototype\.value *=.+\n/m, '$1lodash.prototype.chain = wrapperChain;\n$&'); - - // remove `lodash.prototype.toString` and `lodash.prototype.valueOf` assignments - source = source.replace(/^ *lodash\.prototype\.(?:toString|valueOf) *=.+\n/gm, ''); - - // remove `lodash.prototype` batch method assignments - source = source.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, ''); - - // move `mixin(lodash)` to after the method assignments - source = source.replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+/, ''); - source = source.replace(getMethodAssignments(source), function(match) { - return match + [ - '', - '', - ' // add functions to `lodash.prototype`', - ' mixin(lodash);' - ].join('\n'); - }); + // add Underscore style chaining + source = addChainMethods(source); } if (isUnderscore) { // remove unneeded variables diff --git a/doc/README.md b/doc/README.md index 455cafffcd..8a7b65cd3e 100644 --- a/doc/README.md +++ b/doc/README.md @@ -681,7 +681,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L275 "View in source") [Ⓣ][1] -Creates a `lodash` object, that wraps the given `value`, to enable method chaining. The wrapper functions capable of chaining are: `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` The wrapper functions that do not chain are: `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, `mixin`, `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise unwrapped values are returned. +Creates a `lodash` object, that wraps the given `value`, to enable method chaining. The chainable wrapper functions are: `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` The non-chainable wrapper functions are: `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, `mixin`, `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise return unwrapped values. #### Arguments 1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. diff --git a/lodash.js b/lodash.js index 04d13ce22b..0143819aef 100644 --- a/lodash.js +++ b/lodash.js @@ -246,7 +246,7 @@ * Creates a `lodash` object, that wraps the given `value`, to enable * method chaining. * - * The wrapper functions capable of chaining are: + * The chainable wrapper functions are: * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, * `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, * `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, @@ -255,16 +255,16 @@ * `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, * `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` * - * The wrapper functions that do not chain are: - * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, - * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, - * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, - * `mixin`, `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, - * `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` + * The non-chainable wrapper functions are: + * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, + * `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, + * `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, + * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, `mixin`, + * `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, `some`, + * `sortedIndex`, `template`, `unescape`, and `uniqueId` * * The wrapper functions `first` and `last` return wrapped values when `n` is - * passed, otherwise unwrapped values are returned. + * passed, otherwise return unwrapped values. * * @name _ * @constructor From 5eb3106706f2f2787fa42826f756fdd14bc646eb Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 9 Dec 2012 00:23:02 -0800 Subject: [PATCH 11/45] Updating Backbone/Underscore unit tests to avoid failing tests due to different chaining implementations. Former-commit-id: d797a3547368faae04806d61818327e7d2319309 --- test/backbone.html | 11 ++++++++++- test/underscore.html | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/test/backbone.html b/test/backbone.html index 001e5a973d..6af89c5bcb 100644 --- a/test/backbone.html +++ b/test/backbone.html @@ -12,7 +12,7 @@
-

Backbone Speed Suite

+

Test

@@ -32,6 +32,15 @@

Test

+ diff --git a/test/underscore.html b/test/underscore.html index 9f2d1974a9..610522bccd 100644 --- a/test/underscore.html +++ b/test/underscore.html @@ -5,7 +5,7 @@ Underscore Test Suite @@ -32,6 +32,48 @@ + From e2fd0cfc4edb211a4a5c48b368b1c3dea35fbb66 Mon Sep 17 00:00:00 2001 From: Kit Cambridge Date: Sun, 9 Dec 2012 14:16:15 -0800 Subject: [PATCH 12/45] Add contributing guidelines. Former-commit-id: 0e613d3b5136a980284b3ba3de738ba664cb7fe5 --- CONTRIBUTING.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..ffa6cf3405 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,24 @@ +# Contributing to Lo-Dash + +If you'd like to contribute a feature or bug fix, you can [fork](https://help.github.com/articles/fork-a-repo) Lo-Dash, commit your changes, and [send a pull request](https://help.github.com/articles/using-pull-requests). Please make sure to [search the issue tracker](https://github.com/bestiejs/lodash/issues) first; your issue may have already been discussed or fixed in `master`. + +## Tests + +Please make sure to update the unit tests in the `test` directory as part of your pull request. You can run the tests from the command line via `npm test`, or open `test/index.html` in a web browser. The `test/run-test.sh` script attempts to run the tests in [Rhino](http://www.mozilla.org/rhino/), [RingoJS](http://ringojs.org/), [Narwhal](https://github.com/280north/narwhal), and Node, before starting your default browser. The [Backbone](http://backbonejs.org/) and Underscore test suites are included as well. + +We also use [Travis](https://travis-ci.org/bestiejs/lodash) for continuous integration. + +## Contributor License Agreement + +Lo-Dash is a [Dojo Foundation](http://dojofoundation.org/) project. **As such, we request that all contributors sign the Dojo Foundation [contributor license agreement](http://dojofoundation.org/about/claForm)**. You can [check](http://dojofoundation.org/about/claCheck) if you've already signed a CLA. + +For more information about CLAs, please check out Alex Russell's excellent post, ["Why Do I Need to Sign This?"](http://infrequently.org/2008/06/why-do-i-need-to-sign-this/). + +## Coding Guidelines + +In addition to the following guidelines, please follow the conventions already established in the code. + +- **Spacing**: Use two spaces for indentation. No tabs. +- **Naming**: Keep variable and method names concise and descriptive. `index`, `collection`, and `callback` are preferable to `i`, `arr`, and `fn`. +- **Quotes**: Single-quoted strings are preferred to double-quoted strings; however, please use a double-quoted string if the value contains a single-quote character to avoid unnecessary escaping. +- **Comments**: Please use single-line comments to annotate significant additions, and [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for new methods. We use [Docdown](https://github.com/jdalton/docdown) to generate our documentation. \ No newline at end of file From 11cd924ce133049d54b984a027e1a03861014f8f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 9 Dec 2012 21:58:31 -0800 Subject: [PATCH 13/45] Rework the chaining behavior of `Array` wrapper methods. Former-commit-id: fb8add58a861a19a2df63d6ff377c2a9537a38b6 --- build.js | 92 ++++++++++++++++++++++++++++++++------------ lodash.js | 45 ++++++++++++++-------- lodash.min.js | 4 +- lodash.underscore.js | 23 ++++++----- test/underscore.html | 23 ++++++++--- 5 files changed, 127 insertions(+), 60 deletions(-) diff --git a/build.js b/build.js index 59c515b652..dd877e1d1d 100755 --- a/build.js +++ b/build.js @@ -328,25 +328,6 @@ ].join('\n'); }); - // add `__chain__` checks to `_.mixin` and `Array` function wrappers - _.each([ - matchFunction(source, 'mixin'), - /(?:\s*\/\/.*)*\n( *)forEach\(\['[\s\S]+?\n\1}.+/g - ], function(pattern) { - source = source.replace(pattern, function(match) { - return match.replace(/( *)return new lodash\(([^)]+)\).+/, function(submatch, indent, varName) { - return indent + [ - 'if (this.__chain__) {', - ' varName = new lodash(varName);', - ' varName.__chain__ = true;', - '}', - 'return varName;' - ].join('\n' + indent) - .replace(/varName/g, varName); - }); - }); - }); - // add `lodash.chain` assignment source = source.replace(getMethodAssignments(source), function(match) { return match.replace(/^(?: *\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\n)?( *)lodash\.VERSION *=/m, '$1lodash.chain = chain;\n\n$&'); @@ -372,6 +353,56 @@ ].join('\n'); }); + // add `__chain__` checks to `_.mixin` + source = source.replace(matchFunction(source, 'mixin'), function(match) { + return match.replace(/^( *)return new lodash.+/m, function() { + var indent = arguments[1]; + return indent + [ + 'if (this.__chain__) {', + ' result = new lodash(result);', + ' result.__chain__ = true;', + '}', + 'return result;' + ].join('\n' + indent); + }); + }); + + // replace wrapper `Array` method assignments + source = source.replace(/^(?: *\/\/.*\n)*( *)forEach\(\['[\s\S]+?\n\1}$/m, function() { + return [ + ' // add `Array` mutator functions to the wrapper', + " forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {", + ' var func = arrayRef[methodName];', + ' lodash.prototype[methodName] = function() {', + ' var value = this.__wrapped__;', + ' func.apply(value, arguments);', + '', + ' // avoid array-like object bugs with `Array#shift` and `Array#splice`', + ' // in Firefox < 10 and IE < 9', + ' if (hasObjectSpliceBug && value.length === 0) {', + ' delete value[0];', + ' }', + ' return this;', + ' };', + ' });', + '', + ' // add `Array` accessor functions to the wrapper', + " forEach(['concat', 'join', 'slice'], function(methodName) {", + ' var func = arrayRef[methodName];', + ' lodash.prototype[methodName] = function() {', + ' var value = this.__wrapped__,', + ' result = func.apply(value, arguments);', + '', + ' if (this.__chain__) {', + ' result = new lodash(result);', + ' result.__chain__ = true;', + ' }', + ' return result;', + ' };', + ' });' + ].join('\n'); + }); + return source; } @@ -920,6 +951,19 @@ return source; } + /** + * Removes all `hasObjectSpliceByg` references from `source`. + * + * @private + * @param {String} source The source to process. + * @returns {String} Returns the modified source. + */ + function removeHasObjectSpliceBug(source) { + return removeVar(source, 'hasObjectSpliceBug') + // remove `hasObjectSpliceBug` fix from the `Array` function mixins + .replace(/(?:\s*\/\/.*)*\n( *)if *\(hasObjectSpliceBug[\s\S]+?(?:{\s*}|\n\1})/, ''); + } + /** * Removes a given variable from `source`. * @@ -1762,9 +1806,7 @@ } else { source = removeIsArgumentsFallback(source); - - // remove `hasObjectSpliceBug` fix from the mutator Array functions mixin - source = source.replace(/(?:\s*\/\/.*)*\n( *)if *\(hasObjectSpliceBug[\s\S]+?\n\1}/, ''); + source = removeHasObjectSpliceBug(source); } // remove `thisArg` from unexposed `forIn` and `forOwn` @@ -1908,7 +1950,7 @@ source = removeIsFunctionFallback(source); } if (isRemoved(source, 'mixin')) { - source = removeVar(source, 'hasObjectSpliceBug'); + source = removeHasObjectSpliceBug(source); // simplify the `lodash` function source = replaceFunction(source, 'lodash', [ @@ -1921,8 +1963,8 @@ source = source .replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, '') .replace(/(?:\s*\/\/.*)*\n( *)forEach\(\['[\s\S]+?\n\1}.+/g, '') - .replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+\n/, '') - .replace(/(?:\s*\/\/.*)*\s*lodash\.prototype.+\n/, ''); + .replace(/(?:\s*\/\/.*)*\s*lodash\.prototype.+\n/g, '') + .replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+\n/, ''); } // assign debug source before further modifications that rely on the minifier diff --git a/lodash.js b/lodash.js index 0143819aef..a58208a753 100644 --- a/lodash.js +++ b/lodash.js @@ -4159,7 +4159,6 @@ /*--------------------------------------------------------------------------*/ // add functions that return wrapped values when chaining - lodash.after = after; lodash.assign = assign; lodash.bind = bind; @@ -4323,33 +4322,49 @@ lodash.prototype.value = wrapperValueOf; lodash.prototype.valueOf = wrapperValueOf; - // add mutator `Array` functions to the wrapper - forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { + // add `Array` functions that return unwrapped values + forEach(['join', 'pop', 'shift'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { - var value = this.__wrapped__; - func.apply(value, arguments); + return func.apply(this.__wrapped__, arguments); + }; + }); - // avoid array-like object bugs with `Array#shift` and `Array#splice` - // in Firefox < 10 and IE < 9 - if (hasObjectSpliceBug && value.length === 0) { - delete value[0]; - } + // add `Array` functions that return the wrapped value + forEach(['push', 'reverse', 'sort', 'unshift'], function(methodName) { + var func = arrayRef[methodName]; + lodash.prototype[methodName] = function() { + func.apply(this.__wrapped__, arguments); return this; }; }); - // add accessor `Array` functions to the wrapper - forEach(['concat', 'join', 'slice'], function(methodName) { + // add `Array` functions that return new wrapped values + forEach(['concat', 'slice', 'splice'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { - var value = this.__wrapped__, - result = func.apply(value, arguments); - + var result = func.apply(this.__wrapped__, arguments); return new lodash(result); }; }); + // avoid array-like object bugs with `Array#shift` and `Array#splice` + // in Firefox < 10 and IE < 9 + if (hasObjectSpliceBug) { + forEach(['shift', 'splice'], function(methodName) { + var func = lodash.prototype[methodName]; + lodash.prototype[methodName] = function() { + var value = this.__wrapped__, + result = func.apply(this, arguments); + + if (value.length === 0) { + delete value[0]; + } + return result; + }; + }); + } + // add pseudo private property to be used and removed during the build process lodash._iteratorTemplate = iteratorTemplate; diff --git a/lodash.min.js b/lodash.min.js index 7f68b32d84..18ee06b26f 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -37,5 +37,5 @@ function(e){return kt.call(e)==Ut},s.isString=A,s.isUndefined=function(e){return {var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,u=s.templateSettings,a=0,f=n.interpolate||u.interpolate||mt,l="__p+='",c=n.variable||u.variable,h=c;e.replace(RegExp((n.escape||u.escape||mt).source+"|"+f.source+"|"+(f===vt?dt:mt).source+"|"+(n.evaluate||u.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,u){return i||(i=s),l+=e.slice(a,u).replace(yt,p),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),i&&( l+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),a=u+t.length,t}),l+="';\n",h||(c="obj",r?l="with("+c+"){"+l+"}":(n=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ht,"$&"+c+".").replace(n,"$1__d"))),l=(r?l.replace(at,""):l).replace(ft,"$1").replace(lt,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{i=o("_","return "+ l)(s)}catch(d){throw d.source=l,d}return t?i(t):(i.source=l,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,y)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=D,s.any=R,s.detect=H,s.foldl=I,s.foldr=q,s.include=_,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:g(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function( -e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return""+this.__wrapped__},s.prototype.value=G,s.prototype.valueOf=G,wn("pop push reverse shift sort splice unshift".split(" "),function(e){var t=et[e];s.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Gt&&e.length===0&&delete e[0],this}}),wn(["concat","join","slice"],function(e){var t=et[e];s.prototype[e]= -function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file +e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return""+this.__wrapped__},s.prototype.value=G,s.prototype.valueOf=G,wn(["join","pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),wn(["push","reverse","sort","unshift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),wn(["concat" +,"slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Gt&&wn(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index c3e7970230..5cf31e6fd8 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -185,7 +185,7 @@ * Creates a `lodash` object, that wraps the given `value`, to enable * method chaining. * - * The wrapper functions capable of chaining are: + * The chainable wrapper functions are: * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, * `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, * `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, @@ -194,16 +194,16 @@ * `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, * `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` * - * The wrapper functions that do not chain are: - * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, - * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, - * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, - * `mixin`, `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, - * `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` + * The non-chainable wrapper functions are: + * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, + * `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, + * `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, + * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, `mixin`, + * `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, `some`, + * `sortedIndex`, `template`, `unescape`, and `uniqueId` * * The wrapper functions `first` and `last` return wrapped values when `n` is - * passed, otherwise unwrapped values are returned. + * passed, otherwise return unwrapped values. * * @name _ * @constructor @@ -3656,7 +3656,6 @@ /*--------------------------------------------------------------------------*/ // add functions that return wrapped values when chaining - lodash.after = after; lodash.bind = bind; lodash.bindAll = bindAll; @@ -3794,7 +3793,7 @@ lodash.prototype.chain = wrapperChain; lodash.prototype.value = wrapperValueOf; - // add mutator `Array` functions to the wrapper + // add `Array` mutator functions to the wrapper forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { @@ -3810,7 +3809,7 @@ }; }); - // add accessor `Array` functions to the wrapper + // add `Array` accessor functions to the wrapper forEach(['concat', 'join', 'slice'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { diff --git a/test/underscore.html b/test/underscore.html index 610522bccd..62c954e4ba 100644 --- a/test/underscore.html +++ b/test/underscore.html @@ -33,13 +33,19 @@ document.write(' From 8684f75254461a0933fcaeeba2f3b5d61c80c001 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 9 Dec 2012 21:59:05 -0800 Subject: [PATCH 14/45] Cleanup lib and build unit tests. Former-commit-id: 96171aa70fee408f5237e0615ace4faa6541caa7 --- test/test-build.js | 35 ++++++----- test/test.js | 144 ++++++++++++++++++++++++++------------------- 2 files changed, 105 insertions(+), 74 deletions(-) diff --git a/test/test-build.js b/test/test-build.js index e2d7d8e9c9..ea9c83cd60 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -444,7 +444,7 @@ console.log(e); pass = false; } - equal(pass, true, '_.' + methodName + ': ' + message); + ok(pass, '_.' + methodName + ': ' + message); } /*--------------------------------------------------------------------------*/ @@ -632,7 +632,7 @@ return pass; }); - equal(actual, true, basename); + ok(actual, basename); start(); }); }); @@ -664,12 +664,18 @@ ok(lodash(1).chain() instanceof lodash, '_#chain: ' + basename); var wrapped = lodash(1); - equal(wrapped.clone() instanceof lodash, false, '_(...) wrapped values are not chainable by default: ' + basename); + strictEqual(wrapped.identity(), 1, '_(...) wrapped values are not chainable by default: ' + basename); equal(String(wrapped) === '1', false, '_#toString should not be implemented: ' + basename); equal(Number(wrapped) === 1 , false, '_#valueOf should not be implemented: ' + basename); wrapped.chain(); - equal(wrapped.has('x') instanceof lodash, true, '_#has returns wrapped values when chaining: ' + basename); + ok(wrapped.has('x') instanceof lodash, '_#has returns wrapped values when chaining: ' + basename); + ok(wrapped.join() instanceof lodash, '_#join returns wrapped values when chaining: ' + basename); + + wrapped = lodash([1, 2, 3]); + ok(wrapped.pop() instanceof lodash, '_#pop returns wrapped values: ' + basename); + ok(wrapped.shift() instanceof lodash, '_#shift returns wrapped values: ' + basename); + deepEqual(wrapped.splice(0, 0).value(), [2], '_#splice returns wrapper: ' + basename); start(); }); @@ -697,10 +703,10 @@ var object = { 'fn': lodash.bind(function(foo) { return foo + this.bar; }, { 'bar': 1 }, 1) }; equal(object.fn(), 2, '_.bind: ' + basename); - ok(lodash.clone(array, true)[0] === array[0], '_.clone should be shallow: ' + basename); - equal(lodash.contains({ 'a': 1, 'b': 2 }, 1), true, '_.contains should work with objects: ' + basename); - equal(lodash.contains([1, 2, 3], 1, 2), true, '_.contains should ignore `fromIndex`: ' + basename); - equal(lodash.every([true, false, true]), false, '_.every: ' + basename); + strictEqual(lodash.clone(array, true)[0], array[0], '_.clone should be shallow: ' + basename); + ok(lodash.contains({ 'a': 1, 'b': 2 }, 1), '_.contains should work with objects: ' + basename); + ok(lodash.contains([1, 2, 3], 1, 2), '_.contains should ignore `fromIndex`: ' + basename); + ok(!lodash.every([true, false, true]), '_.every: ' + basename); function Foo() {} Foo.prototype = { 'a': 1 }; @@ -739,7 +745,7 @@ actual = lodash.pick(object, function(value) { return value != 3; }); deepEqual(_.keys(actual), [], '_.pick should not accept a `callback`: ' + basename); - equal(lodash.some([false, true, false]), true, '_.some: ' + basename); + ok(lodash.some([false, true, false]), '_.some: ' + basename); equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename); equal(lodash.uniqueId(0), '1', '_.uniqueId should ignore a prefix of `0`: ' + basename); @@ -843,8 +849,8 @@ case 1: context.exports = {}; vm.runInContext(source, context); - ok(context._ === undefined, basename); - ok(_.isFunction(context.exports._), basename) + ok(_.isFunction(context.exports._), basename); + strictEqual(context._, undefined, basename); break; case 2: @@ -856,13 +862,13 @@ context.exports = {}; context.module = { 'exports': context.exports }; vm.runInContext(source, context); - ok(context._ === undefined, basename); ok(_.isFunction(context.module.exports), basename); + strictEqual(context._, undefined, basename); break; case 4: vm.runInContext(source, context); - ok(context._ === undefined, basename); + strictEqual(context._, undefined, basename); } start(); }); @@ -978,7 +984,6 @@ } catch(e) { console.log(e); } - var underscore = context._ || {}; ok(_.isString(underscore.VERSION)); ok(!/Lo-Dash/.test(result) && result.match(/\n/g).length < source.match(/\n/g).length); @@ -1019,7 +1024,7 @@ deepEqual(lodash.merge(object1, object2), object3, basename); deepEqual(lodash.sortBy([3, 2, 1], _.identity), array, basename); - equal(lodash.isEqual(circular1, circular2), true, basename); + ok(lodash.isEqual(circular1, circular2), basename); var actual = lodash.clone(circular1, true); ok(actual != circular1 && actual.b == actual, basename); diff --git a/test/test.js b/test/test.js index 623c2ce0cc..42da44867d 100644 --- a/test/test.js +++ b/test/test.js @@ -281,7 +281,7 @@ ok(_.isEqual(object, clone)); if (_.isObject(object)) { - ok(clone !== object); + notStrictEqual(clone, object); } else { skipTest(); } @@ -290,8 +290,8 @@ _.forOwn(nonCloneable, function(object, key) { test('should not clone ' + key, function() { - ok(_.clone(object) === object); - ok(_.clone(object, true) === object); + strictEqual(_.clone(object), object); + strictEqual(_.clone(object, true), object); }); }); @@ -325,9 +325,9 @@ test('should clone problem JScript properties (test in IE < 9)', function() { deepEqual(_.clone(shadowed), shadowed); - ok(_.clone(shadowed) != shadowed); + notEqual(_.clone(shadowed), shadowed); deepEqual(_.clone(shadowed, true), shadowed); - ok(_.clone(shadowed, true) != shadowed); + notEqual(_.clone(shadowed, true), shadowed); }); }(1, 2, 3)); @@ -343,7 +343,7 @@ }, function(collection, key) { test('should work with ' + key + ' and a positive `fromIndex`', function() { - equal(_.contains(collection, 1, 2), true); + ok(_.contains(collection, 1, 2)); }); test('should work with ' + key + ' and a `fromIndex` >= collection\'s length', function() { @@ -354,12 +354,12 @@ }); test('should work with ' + key + ' and a negative `fromIndex`', function() { - equal(_.contains(collection, 2, -3), true); + ok(_.contains(collection, 2, -3)); }); test('should work with ' + key + ' and a negative `fromIndex` <= negative collection\'s length', function() { - equal(_.contains(collection, 1, -6), true); - equal(_.contains(collection, 2, -8), true); + ok(_.contains(collection, 1, -6)); + ok(_.contains(collection, 2, -8)); }); }); @@ -369,8 +369,8 @@ }, function(collection, key) { test('should work with a string ' + key + ' for `collection`', function() { - equal(_.contains(collection, 'bc'), true); - equal(_.contains(collection, 'd'), false); + ok(_.contains(collection, 'bc')); + ok(!_.contains(collection, 'd')); }); }); }()); @@ -453,7 +453,7 @@ (function() { test('should return `false` as soon as the `callback` result is falsey', function() { - equal(_.every([true, null, true], _.identity), false); + ok(!_.every([true, null, true], _.identity)); }); }()); @@ -770,7 +770,7 @@ (function() { test('should use strict equality in its duck type check', function() { var element = window.document ? document.body : { 'nodeType': 1 }; - equal(_.isElement(element), true); + ok(_.isElement(element)); equal(_.isElement({ 'nodeType': new Number(1) }), false); equal(_.isElement({ 'nodeType': true }), false); @@ -794,21 +794,21 @@ test('skips the prototype property of functions (test in Firefox < 3.6, Opera > 9.50 - Opera < 11.60, and Safari < 5.1)', function() { function Foo() {} Foo.prototype.a = 1; - equal(_.isEmpty(Foo), true); + ok(_.isEmpty(Foo)); Foo.prototype = { 'a': 1 }; - equal(_.isEmpty(Foo), true); + ok(_.isEmpty(Foo)); }); test('should work with an object that has a `length` property', function() { - equal(_.isEmpty({ 'length': 0 }), false); + ok(!_.isEmpty({ 'length': 0 })); }); test('should work with jQuery/MooTools DOM query collections', function() { function Foo(elements) { Array.prototype.push.apply(this, elements); } Foo.prototype = { 'length': 0, 'splice': Array.prototype.splice }; - equal(_.isEmpty(new Foo([])), true); + ok(_.isEmpty(new Foo([]))); }); test('should work with `arguments` objects (test in IE < 9)', function() { @@ -826,8 +826,8 @@ args2 = (function() { return arguments; }(1, 2, 3)), args3 = (function() { return arguments; }(1, 2)); - equal(_.isEqual(args1, args2), true); - equal(_.isEqual(args1, args3), false); + ok(_.isEqual(args1, args2)); + ok(!_.isEqual(args1, args3)); }); test('fixes the JScript [[DontEnum]] bug (test in IE < 9)', function() { @@ -838,7 +838,7 @@ // ensure `_._object` is assigned (unassigned in Opera 10.00) if (_._object) { var object = { 'a': 1, 'b': 2, 'c': 3 }; - equal(_.isEqual(object, _._object), true); + ok(_.isEqual(object, _._object)); } else { skipTest(); @@ -865,18 +865,18 @@ (function() { test('should return `false` for non-numeric values', function() { - equal(_.isFinite(null), false); - equal(_.isFinite([]), false); - equal(_.isFinite(true), false); - equal(_.isFinite(''), false); - equal(_.isFinite(' '), false); - equal(_.isFinite('2px'), false); + ok(!_.isFinite(null)); + ok(!_.isFinite([])); + ok(!_.isFinite(true)); + ok(!_.isFinite('')); + ok(!_.isFinite(' ')); + ok(!_.isFinite('2px')); }); test('should return `true` for numeric string values', function() { - equal(_.isFinite('2'), true); - equal(_.isFinite('0'), true); - equal(_.isFinite('08'), true); + ok(_.isFinite('2')); + ok(_.isFinite('0')); + ok(_.isFinite('08')); }); }()); @@ -906,7 +906,7 @@ (function() { test('returns `true` for `new Number(NaN)`', function() { - equal(_.isNaN(new Number(NaN)), true) + ok(_.isNaN(new Number(NaN))); }); }()); @@ -920,9 +920,9 @@ this.a = 1; } - equal(_.isPlainObject(new Foo(1)), false); - equal(_.isPlainObject([1, 2, 3]), false); - equal(_.isPlainObject({ 'a': 1 }), true); + ok(!_.isPlainObject(new Foo(1))); + ok(!_.isPlainObject([1, 2, 3])); + ok(_.isPlainObject({ 'a': 1 })); }); }()); @@ -947,7 +947,8 @@ 'isRegExp', 'isString', 'isUndefined' - ], function(methodName) { + ], + function(methodName) { var func = _[methodName]; test('lodash.' + methodName + ' should return a boolean', function() { @@ -1357,7 +1358,7 @@ while ((new Date - start) < 50 && actual == 5) { actual = _.random(5); } - ok(actual != 5); + notEqual(actual, 5); }); }()); @@ -1540,7 +1541,7 @@ (function() { test('should return `true` as soon as the `callback` result is truthy', function() { - equal(_.some([null, true, null], _.identity), true); + ok(_.some([null, true, null], _.identity)); }); }()); @@ -1667,7 +1668,8 @@ '<%= new Boolean %>': 'false', '<%= typeof a %>': 'number', '<%= void a %>': '' - }, function(value, key) { + }, + function(value, key) { var compiled = _.template(key), data = { 'a': 1, 'b': 2 }; @@ -1938,7 +1940,7 @@ test('should coerce the prefix argument to a string', function() { var actual = [_.uniqueId(3), _.uniqueId(2), _.uniqueId(1)]; - equal(/3\d+,2\d+,1\d+/.test(actual), true); + ok(/3\d+,2\d+,1\d+/.test(actual)); }); }()); @@ -2045,24 +2047,20 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash(...) methods capable of returning wrapped and unwrapped values'); + QUnit.module('lodash(...) methods that return wrapped values'); (function() { var array = [1, 2, 3], wrapped = _(array); var funcs = [ - 'first', - 'last' + 'concat', + 'splice' ]; _.each(funcs, function(methodName) { - test('_.' + methodName + ' should return an unwrapped value', function() { - equal(typeof wrapped[methodName](), 'number'); - }); - test('_.' + methodName + ' should return a wrapped value', function() { - ok(wrapped[methodName](1) instanceof _); + ok(wrapped[methodName]() instanceof _); }); }); }()); @@ -2076,6 +2074,7 @@ wrapped = _(array); var funcs = [ + 'clone', 'contains', 'every', 'find', @@ -2098,19 +2097,46 @@ 'isRegExp', 'isString', 'isUndefined', + 'join', 'last', + 'pop', + 'shift', 'reduce', 'reduceRight', 'some' ]; _.each(funcs, function(methodName) { - test('_.' + methodName + ' should return unwrapped values', function() { + test('_.' + methodName + ' should return an unwrapped value', function() { var result = methodName == 'reduceRight' ? wrapped[methodName](_.identity) - : wrapped[methodName]; + : wrapped[methodName](); - notEqual(typeof result, 'object', '_.' + methodName + ' returns unwrapped values'); + equal(result instanceof _, false); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('lodash(...) methods capable of returning wrapped and unwrapped values'); + + (function() { + var array = [1, 2, 3], + wrapped = _(array); + + var funcs = [ + 'first', + 'last' + ]; + + _.each(funcs, function(methodName) { + test('_.' + methodName + ' should return an unwrapped value', function() { + equal(typeof wrapped[methodName](), 'number'); + }); + + test('_.' + methodName + ' should return a wrapped value', function() { + ok(wrapped[methodName](1) instanceof _); }); }); }()); @@ -2122,15 +2148,15 @@ (function() { test('should allow falsey arguments', function() { var returnArrays = [ - 'filter', - 'invoke', - 'map', - 'pluck', - 'reject', - 'shuffle', - 'sortBy', - 'toArray', - 'where' + 'filter', + 'invoke', + 'map', + 'pluck', + 'reject', + 'shuffle', + 'sortBy', + 'toArray', + 'where' ]; var funcs = _.without.apply(_, [_.functions(_)].concat([ @@ -2220,7 +2246,7 @@ } if (expected === null) { - deepEqual(thisArg, null, message); + strictEqual(thisArg, null, message); } else { equal(thisArg, expected, message); } From 4e7b71db1d215e302b523018d56cc833c2c96613 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 9 Dec 2012 22:36:19 -0800 Subject: [PATCH 15/45] Cleanup CONTRIBUTING.md and README.md. Former-commit-id: f0dca3ffc6a23128a877ae4d7d7f409d2e6adb69 --- CONTRIBUTING.md | 20 +++++++++++++------- README.md | 8 ++++---- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ffa6cf3405..19c542ac04 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,24 +1,30 @@ # Contributing to Lo-Dash -If you'd like to contribute a feature or bug fix, you can [fork](https://help.github.com/articles/fork-a-repo) Lo-Dash, commit your changes, and [send a pull request](https://help.github.com/articles/using-pull-requests). Please make sure to [search the issue tracker](https://github.com/bestiejs/lodash/issues) first; your issue may have already been discussed or fixed in `master`. +If youÕd like to contribute a feature or bug fix, you can [fork](https://help.github.com/articles/fork-a-repo) Lo-Dash, commit your changes, and [send a pull request](https://help.github.com/articles/using-pull-requests). +Please make sure to [search the issue tracker](https://github.com/bestiejs/lodash/issues) first; your issue may have already been discussed or fixed in `master`. ## Tests -Please make sure to update the unit tests in the `test` directory as part of your pull request. You can run the tests from the command line via `npm test`, or open `test/index.html` in a web browser. The `test/run-test.sh` script attempts to run the tests in [Rhino](http://www.mozilla.org/rhino/), [RingoJS](http://ringojs.org/), [Narwhal](https://github.com/280north/narwhal), and Node, before starting your default browser. The [Backbone](http://backbonejs.org/) and Underscore test suites are included as well. +Please make sure to update the unit tests in the `test` directory as part of your pull request. +You can run the tests from the command line via `npm test`, or open `test/index.html` in a web browser. +The `test/run-test.sh` script attempts to run the tests in [Rhino](http://www.mozilla.org/rhino/), [RingoJS](http://ringojs.org/), [Narwhal](https://github.com/280north/narwhal), and [Node](http://nodejs.org/), before starting your default browser. +The [Backbone](http://backbonejs.org/) and [Underscore](http://http://underscorejs.org/) test suites are included as well. -We also use [Travis](https://travis-ci.org/bestiejs/lodash) for continuous integration. +We also use [Travis CI](https://travis-ci.org/bestiejs/lodash) for continuous integration. ## Contributor License Agreement -Lo-Dash is a [Dojo Foundation](http://dojofoundation.org/) project. **As such, we request that all contributors sign the Dojo Foundation [contributor license agreement](http://dojofoundation.org/about/claForm)**. You can [check](http://dojofoundation.org/about/claCheck) if you've already signed a CLA. +Lo-Dash is a [Dojo Foundation](http://dojofoundation.org/) project. +As such, we request that all contributors sign the Dojo Foundation [contributor license agreement](http://dojofoundation.org/about/claForm). +You can also [check](http://dojofoundation.org/about/claCheck) if youÕve already signed a CLA. -For more information about CLAs, please check out Alex Russell's excellent post, ["Why Do I Need to Sign This?"](http://infrequently.org/2008/06/why-do-i-need-to-sign-this/). +For more information about CLAs, please check out Alex RussellÕs excellent post, ["Why Do I Need to Sign This?"](http://infrequently.org/2008/06/why-do-i-need-to-sign-this/). ## Coding Guidelines In addition to the following guidelines, please follow the conventions already established in the code. - **Spacing**: Use two spaces for indentation. No tabs. -- **Naming**: Keep variable and method names concise and descriptive. `index`, `collection`, and `callback` are preferable to `i`, `arr`, and `fn`. +- **Naming**: Keep variable and method names concise and descriptive. Variable names `index`, `collection`, and `callback` are preferable to `i`, `arr`, and `fn`. - **Quotes**: Single-quoted strings are preferred to double-quoted strings; however, please use a double-quoted string if the value contains a single-quote character to avoid unnecessary escaping. -- **Comments**: Please use single-line comments to annotate significant additions, and [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for new methods. We use [Docdown](https://github.com/jdalton/docdown) to generate our documentation. \ No newline at end of file +- **Comments**: Please use single-line comments to annotate significant additions, and [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for new methods. We use [Docdown](https://github.com/jdalton/docdown) to generate our documentation. diff --git a/README.md b/README.md index a56b34a6b9..6a2cd350fe 100644 --- a/README.md +++ b/README.md @@ -238,21 +238,21 @@ require({ ## Release Notes -### v1.0.0-rc.2 ### +### v1.0.0-rc.2 * Specified more method chaining behaviors * Updated `underscore` build compatibility to v1.4.3 -### v1.0.0-rc.1 ### +### v1.0.0-rc.1 -#### Compatibility Warnings #### +#### Compatibility Warnings * Made `_(…)` chain automatically without needing to call `_#chain` * Made `_.isEqual` equate `arguments` objects to similar `Object` objects * Made `_.clone` copy the enumerable properties of `arguments` objects and objects
created by constructors other than `Object` are cloned to plain `Object` objects -#### Changes #### +#### Changes * Ensure Lo-Dash runs in the JS engine embedded in Adobe products * Ensured `_.reduce` and `_.reduceRight` pass the correct number of `callback` arguments From 13d62b01d1693fcdeba33c5b775ce6a4b6245d40 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 9 Dec 2012 23:25:59 -0800 Subject: [PATCH 16/45] Ensure utf-8 encoding and tweak text in CONTRIBUTING.md. Former-commit-id: 67a3e585c0a3b815e916e0d38ed2bc113de3220d --- CONTRIBUTING.md | 27 ++++--- vendor/firebug-lite/skin/xp/firebug-1.3a2.css | 28 +++---- vendor/firebug-lite/skin/xp/firebug.css | 68 ++++++++-------- vendor/firebug-lite/skin/xp/firebug.html | 80 +++++++++---------- 4 files changed, 104 insertions(+), 99 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 19c542ac04..db21069c06 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,30 +1,35 @@ # Contributing to Lo-Dash -If youÕd like to contribute a feature or bug fix, you can [fork](https://help.github.com/articles/fork-a-repo) Lo-Dash, commit your changes, and [send a pull request](https://help.github.com/articles/using-pull-requests). +If you’d like to contribute a feature or bug fix, you can [fork](https://help.github.com/articles/fork-a-repo) Lo-Dash, commit your changes, and [send a pull request](https://help.github.com/articles/using-pull-requests). Please make sure to [search the issue tracker](https://github.com/bestiejs/lodash/issues) first; your issue may have already been discussed or fixed in `master`. ## Tests -Please make sure to update the unit tests in the `test` directory as part of your pull request. +Include updated unit tests in the `test` directory as part of your pull request. You can run the tests from the command line via `npm test`, or open `test/index.html` in a web browser. -The `test/run-test.sh` script attempts to run the tests in [Rhino](http://www.mozilla.org/rhino/), [RingoJS](http://ringojs.org/), [Narwhal](https://github.com/280north/narwhal), and [Node](http://nodejs.org/), before starting your default browser. +The `test/run-test.sh` script attempts to run the tests in [Rhino](http://www.mozilla.org/rhino/), [RingoJS](http://ringojs.org/), [Narwhal](https://github.com/280north/narwhal), and [Node](http://nodejs.org/), before running them in your default browser. The [Backbone](http://backbonejs.org/) and [Underscore](http://http://underscorejs.org/) test suites are included as well. -We also use [Travis CI](https://travis-ci.org/bestiejs/lodash) for continuous integration. - ## Contributor License Agreement Lo-Dash is a [Dojo Foundation](http://dojofoundation.org/) project. As such, we request that all contributors sign the Dojo Foundation [contributor license agreement](http://dojofoundation.org/about/claForm). -You can also [check](http://dojofoundation.org/about/claCheck) if youÕve already signed a CLA. -For more information about CLAs, please check out Alex RussellÕs excellent post, ["Why Do I Need to Sign This?"](http://infrequently.org/2008/06/why-do-i-need-to-sign-this/). +For more information about CLAs, please check out Alex Russell’s excellent post, ["Why Do I Need to Sign This?"](http://infrequently.org/2008/06/why-do-i-need-to-sign-this/). ## Coding Guidelines In addition to the following guidelines, please follow the conventions already established in the code. -- **Spacing**: Use two spaces for indentation. No tabs. -- **Naming**: Keep variable and method names concise and descriptive. Variable names `index`, `collection`, and `callback` are preferable to `i`, `arr`, and `fn`. -- **Quotes**: Single-quoted strings are preferred to double-quoted strings; however, please use a double-quoted string if the value contains a single-quote character to avoid unnecessary escaping. -- **Comments**: Please use single-line comments to annotate significant additions, and [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for new methods. We use [Docdown](https://github.com/jdalton/docdown) to generate our documentation. +- **Spacing**:
+ Use two spaces for indentation. No tabs. + +- **Naming**:
+ Keep variable and method names concise and descriptive.
+ Variable names `index`, `collection`, and `callback` are preferable to `i`, `arr`, and `fn`. + +- **Quotes**:
+ Single-quoted strings are preferred to double-quoted strings; however, please use a double-quoted string if the value contains a single-quote character to avoid unnecessary escaping. + +- **Comments**:
+ Please use single-line comments to annotate significant additions, and [JSDoc-style](http://www.2ality.com/2011/08/jsdoc-intro.html) comments for new methods. diff --git a/vendor/firebug-lite/skin/xp/firebug-1.3a2.css b/vendor/firebug-lite/skin/xp/firebug-1.3a2.css index 42f9faf5d5..d929b2bf17 100644 --- a/vendor/firebug-lite/skin/xp/firebug-1.3a2.css +++ b/vendor/firebug-lite/skin/xp/firebug-1.3a2.css @@ -70,7 +70,7 @@ html, body { body { font-family: Lucida Grande, Tahoma, sans-serif; font-size: 11px; - background: #fff; + background: #fff; } .clear { @@ -103,7 +103,7 @@ body { border: 1px solid #ccc; margin: 0 5px 0 0; background: #fff url(search.png) no-repeat 4px 2px; - padding-left: 20px; + padding-left: 20px; font-size: 11px; } @@ -124,7 +124,7 @@ body { height: 14px; background: url(errorIcon.png) no-repeat; color: #f00; - font-weight: bold; + font-weight: bold; } #fbMiniErrors { @@ -139,7 +139,7 @@ body { margin: 3px 4px 0; height: 20px; width: 20px; - float: right; + float: right; background: url(sprite.png) 0 -135px; cursor: pointer; } @@ -192,10 +192,10 @@ body { } /************************************************************************************************ - Sub-Layout + Sub-Layout *************************************************************************************************/ -/* fbToolbar +/* fbToolbar *************************************************************************************************/ #fbToolbarIcon { float: left; @@ -237,7 +237,7 @@ body { position: relative; top: 5px; line-height: 19px; - cursor: default; + cursor: default; } .fbToolbarSeparator{ @@ -262,7 +262,7 @@ body { .fbStatusBar span a:hover { color: blue; - cursor: pointer; + cursor: pointer; } @@ -307,7 +307,7 @@ body { padding-left: 10px; } -/* body +/* body *************************************************************************************************/ .fbPanel { display: none; @@ -340,7 +340,7 @@ body { visibility: hidden !important; } -/* fbBottom +/* fbBottom *************************************************************************************************/ #fbCommand { @@ -391,7 +391,7 @@ div.fbFitHeight { Layout Controls *************************************************************************************************/ -/* fbToolbar buttons +/* fbToolbar buttons *************************************************************************************************/ #fbWindowButtons a { font-size: 1px; @@ -420,7 +420,7 @@ div.fbFitHeight { background: url(sprite.png) -48px -119px; } -/* fbPanelBarBox tabs +/* fbPanelBarBox tabs *************************************************************************************************/ .fbTab { text-decoration: none; @@ -475,7 +475,7 @@ a.fbTab:hover .fbTabR { background: url(sprite.png) -8px -96px !important; } -/* splitters +/* splitters *************************************************************************************************/ #fbHSplitter { position: absolute; @@ -571,7 +571,7 @@ div.objectBox-element { color: #fff !important; } -/* Webkit CSS Hack - bug in "highlight" named color */ +/* Webkit CSS Hack - bug in "highlight" named color */ @media screen and (-webkit-min-device-pixel-ratio:0) { .selectedElement{ background: #316AC5; diff --git a/vendor/firebug-lite/skin/xp/firebug.css b/vendor/firebug-lite/skin/xp/firebug.css index a1465ec5f3..f3bdd8cdee 100644 --- a/vendor/firebug-lite/skin/xp/firebug.css +++ b/vendor/firebug-lite/skin/xp/firebug.css @@ -136,10 +136,10 @@ h1.groupHeader { position: relative; top: -7px; left: -5px; - + outline: none; resize: none; - + /* _border: 1px solid #999 !important; _padding: 1px !important; @@ -311,17 +311,17 @@ h1.groupHeader { outline: none; background-color: transparent } - - .useA11y .a11yCSSView .focusRow:focus .cssSelector, - .useA11y .a11yCSSView .focusRow:focus .cssPropName, + + .useA11y .a11yCSSView .focusRow:focus .cssSelector, + .useA11y .a11yCSSView .focusRow:focus .cssPropName, .useA11y .a11yCSSView .focusRow:focus .cssPropValue, - .useA11y .a11yCSSView .computedStyleRow:focus, + .useA11y .a11yCSSView .computedStyleRow:focus, .useA11y .a11yCSSView .groupHeader:focus { outline: 2px solid #FF9933; outline-offset: -2px; background-color: #FFFFD6; } - + .useA11y .a11yCSSView .groupHeader:focus { outline-offset: -2px; } @@ -731,7 +731,7 @@ h1.groupHeader { /* Time Info tip */ .timeInfoTip { - width: 150px; + width: 150px; height: 40px } @@ -944,7 +944,7 @@ h1.groupHeader { /*overflow-x: auto; HTML is damaged in case of big (2-3MB) responses */ } -/* replaced by .netInfoTextSelected for IE6 support +/* replaced by .netInfoTextSelected for IE6 support .netInfoText[selected="true"] { display: block; } @@ -963,7 +963,7 @@ h1.groupHeader { } .netInfoPostText .netInfoParamName { - width: 1px; /* Google Chrome need this otherwise the first column of + width: 1px; /* Google Chrome need this otherwise the first column of the post variables table will be larger than expected */ } @@ -1148,7 +1148,7 @@ h1.groupHeader { } * html .opened .spyHead .spyTitle, -* html .opened .logGroupLabel, +* html .opened .logGroupLabel, * html .opened .memberLabelCell .memberLabel { background-image: url(tree_close.gif); background-repeat: no-repeat; @@ -1677,7 +1677,7 @@ h1.groupHeader { /* .logRow-errorMessage > .hasTwisty > .errorTitle, .logRow-spy .spyHead .spyTitle, -.logGroup > .logRow +.logGroup > .logRow */ .logRow-errorMessage .hasTwisty .errorTitle, .logRow-spy .spyHead .spyTitle, @@ -2056,11 +2056,11 @@ h1.groupHeader { width: 10px; height: 10px; margin-top: 6px; - background: url(tabMenuTarget.png); + background: url(tabMenuTarget.png); } .fbTabMenuTarget:hover { - background: url(tabMenuTargetHover.png); + background: url(tabMenuTargetHover.png); } .fbShadow { @@ -2098,7 +2098,7 @@ h1.groupHeader { padding: 1px 18px 0; text-decoration: none; color: #000; - cursor: default; + cursor: default; background: #ACA899; margin: 4px 0; } @@ -2149,7 +2149,7 @@ h1.groupHeader { } .fbMenuShortcut { - padding-right: 85px; + padding-right: 85px; } .fbMenuShortcutKey { @@ -2274,7 +2274,7 @@ h1.groupHeader { margin: 0; padding: 0; overflow: hidden; - + font-family: Lucida Grande, Tahoma, sans-serif; font-size: 11px; background: #fff; @@ -2311,7 +2311,7 @@ h1.groupHeader { margin: 0 5px 0 0; background: #fff url(search.png) no-repeat 4px 2px !important; background: #fff url(search.gif) no-repeat 4px 2px; - padding-left: 20px; + padding-left: 20px; font-size: 11px; } @@ -2333,7 +2333,7 @@ h1.groupHeader { background: url(errorIcon.png) no-repeat !important; background: url(errorIcon.gif) no-repeat; color: #f00; - font-weight: bold; + font-weight: bold; } #fbMiniErrors { @@ -2348,7 +2348,7 @@ h1.groupHeader { margin: 3px 4px 0; height: 20px; width: 20px; - float: right; + float: right; background: url(sprite.png) 0 -135px; cursor: pointer; } @@ -2403,10 +2403,10 @@ h1.groupHeader { } /************************************************************************************************ - Sub-Layout + Sub-Layout *************************************************************************************************/ -/* fbToolbar +/* fbToolbar *************************************************************************************************/ #fbToolbarIcon { float: left; @@ -2472,7 +2472,7 @@ h1.groupHeader { #fbStatusBarBox { top: 4px; - cursor: default; + cursor: default; } .fbToolbarSeparator { @@ -2500,7 +2500,7 @@ h1.groupHeader { .fbStatusBar a:hover { color: blue; - cursor: pointer; + cursor: pointer; } @@ -2545,7 +2545,7 @@ h1.groupHeader { padding-left: 4px; } -/* body +/* body *************************************************************************************************/ .fbPanel { display: none; @@ -2609,7 +2609,7 @@ h1.groupHeader { position: absolute; right: 2px; bottom: 3px; - + z-index: 99; } @@ -2624,7 +2624,7 @@ h1.groupHeader { visibility: hidden !important; } -/* fbBottom +/* fbBottom *************************************************************************************************/ #fbCommand { @@ -2689,7 +2689,7 @@ div.fbFitHeight { Layout Controls *************************************************************************************************/ -/* fbToolbar buttons +/* fbToolbar buttons *************************************************************************************************/ .fbSmallButton { overflow: hidden; @@ -2729,7 +2729,7 @@ div.fbFitHeight { } -/* fbPanelBarBox tabs +/* fbPanelBarBox tabs *************************************************************************************************/ .fbTab { text-decoration: none; @@ -2785,7 +2785,7 @@ a.fbTab:hover .fbTabR { background: url(sprite.png) -8px -96px !important; } -/* splitters +/* splitters *************************************************************************************************/ #fbHSplitter { position: fixed; @@ -2888,7 +2888,7 @@ div.objectBox-element { position: relative; } -/* Webkit CSS Hack - bug in "highlight" named color */ +/* Webkit CSS Hack - bug in "highlight" named color */ @media screen and (-webkit-min-device-pixel-ratio:0) { .selectedElement{ background: #316AC5; @@ -2903,7 +2903,7 @@ div.objectBox-element { } /* TODO: remove this? */ -/* TODO: xxxpedro - IE need this in windowless mode (cnn.com) check if the issue is related to +/* TODO: xxxpedro - IE need this in windowless mode (cnn.com) check if the issue is related to position. if so, override it at chrome.js initialization when creating the div */ .logRow { position: relative; @@ -2939,9 +2939,9 @@ position. if so, override it at chrome.js initialization when creating the div * .objectBox-string { color: red; - + /* TODO: xxxpedro make long strings break line */ - /*white-space: pre; */ + /*white-space: pre; */ } .objectBox-number { diff --git a/vendor/firebug-lite/skin/xp/firebug.html b/vendor/firebug-lite/skin/xp/firebug.html index aa078099fb..c2b5c43472 100644 --- a/vendor/firebug-lite/skin/xp/firebug.html +++ b/vendor/firebug-lite/skin/xp/firebug.html @@ -14,71 +14,71 @@ - - - +
     
- +
- +   - - - + Inspect - + Clear - + - - + - - +
- +
- +
- + - +
 
- + - + - +
@@ -150,41 +150,41 @@
- + - +
 
- +
- +
- +
- + - +
Run Clear - +
- + - + - + - +
@@ -193,18 +193,18 @@
- + - + - + - ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4319 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4318 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index a58208a753..5d58a91819 100644 --- a/lodash.js +++ b/lodash.js @@ -1184,7 +1184,7 @@ * // => true */ var isArray = nativeIsArray || function(value) { - return toString.call(value) == arrayClass; + return value instanceof Array || toString.call(value) == arrayClass; }; /** @@ -1218,7 +1218,7 @@ * // => true */ function isDate(value) { - return toString.call(value) == dateClass; + return value instanceof Date || toString.call(value) == dateClass; } /** @@ -1476,7 +1476,7 @@ // fallback for older versions of Chrome and Safari if (isFunction(/x/)) { isFunction = function(value) { - return toString.call(value) == funcClass; + return value instanceof Function || toString.call(value) == funcClass; }; } @@ -1626,7 +1626,7 @@ * // => true */ function isRegExp(value) { - return toString.call(value) == regexpClass; + return value instanceof RegExp || toString.call(value) == regexpClass; } /** diff --git a/lodash.min.js b/lodash.min.js index 18ee06b26f..caaa89c46e 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -22,20 +22,21 @@ exports,Z="object"==typeof global&&global;Z.global===Z&&(e=Z);var et=[],tt=new f ,Ft="[object Boolean]",It="[object Date]",qt="[object Number]",Rt="[object Object]",Ut="[object RegExp]",zt="[object String]",Wt=!/1/.test(Function("1")),Xt=!!e.attachEvent,Vt=Lt&&!/\n|true/.test(Lt+Xt),$t=Lt&&!Vt,Jt=_t&&(Xt||Vt),Kt,Qt,Gt=(Gt={0:1,length:1},et.splice.call(Gt,0,1),Gt[0]),Yt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Yt=!n;Kt=!/valueOf/.test(t),Qt="x"!=t[0]})(1);var Zt=!b(arguments),en="xx"!="x"[0]+Object ("x")[0];try{var tn=("[object Object]",kt.call(document)==Rt)}catch(nn){}var rn={"[object Function]":i};rn[Bt]=rn[jt]=rn[Ft]=rn[It]=rn[qt]=rn[Rt]=rn[Ut]=rn[zt]=n;var sn={};sn[jt]=Array,sn[Ft]=Boolean,sn[It]=Date,sn[Rt]=Object,sn[qt]=Number,sn[Ut]=RegExp,sn[zt]=String;var on={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},un={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate :vt,variable:""};if(Xt||Vt||!Wt)o=Function;var an={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},vn=T(dn),mn=h(an,{g:"if(t[i]==null)"+ -an.g}),gn=At||function(e){return kt.call(e)==jt};C(/x/)&&(C=function(e){return"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!b(e):w(e)}:w,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?E(e):k(e)?_t(e):[]}:E,wn=h(fn);s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},s.assign=cn,s.bind=J,s.bindAll=function(e){for( -var t=arguments,n=1W(i,e)){for(var s=n;--s;)if(!(r[s]||(r[s]=u(t[s])))(e))return;i.push(e)}}),i},s.invert=T,s.invoke=function( -e,t){var n=g(arguments,2),r="function"==typeof t,i=[];return wn(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=O,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&A(e)?a:c(t,n),wn(e,function(e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([n,e])}),t},s.partial=function(e){return l(e,g(arguments,1))},s.pick=function(e, -t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e -);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return C(n)?e[t]():n},s.size=function(e) -{var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,u=s.templateSettings,a=0,f=n.interpolate||u.interpolate||mt,l="__p+='",c=n.variable||u.variable,h=c;e.replace(RegExp((n.escape||u.escape||mt).source+"|"+f.source+"|"+(f===vt?dt:mt).source+"|"+(n.evaluate||u.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,u){return i||(i=s),l+=e.slice(a,u).replace(yt,p),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),i&&( -l+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),a=u+t.length,t}),l+="';\n",h||(c="obj",r?l="with("+c+"){"+l+"}":(n=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ht,"$&"+c+".").replace(n,"$1__d"))),l=(r?l.replace(at,""):l).replace(ft,"$1").replace(lt,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{i=o("_","return "+ -l)(s)}catch(d){throw d.source=l,d}return t?i(t):(i.source=l,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,y)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=D,s.any=R,s.detect=H,s.foldl=I,s.foldr=q,s.include=_,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:g(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function( -e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return""+this.__wrapped__},s.prototype.value=G,s.prototype.valueOf=G,wn(["join","pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),wn(["push","reverse","sort","unshift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),wn(["concat" -,"slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Gt&&wn(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file +an.g}),gn=At||function(e){return e instanceof Array||kt.call(e)==jt};C(/x/)&&(C=function(e){return e instanceof Function||"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!b(e):w(e)}:w,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?E(e):k(e)?_t(e):[]}:E,wn=h(fn);s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},s. +assign=cn,s.bind=J,s.bindAll=function(e){for(var t=arguments,n=1W(i,e)){for(var s=n;--s;)if(!(r[s]||(r[s]=u(t[s])))(e)) +return;i.push(e)}}),i},s.invert=T,s.invoke=function(e,t){var n=g(arguments,2),r="function"==typeof t,i=[];return wn(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=O,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&A(e)?a:c(t,n),wn(e,function(e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([n,e])}),t},s.partial=function( +e){return l(e,g(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.times= +function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight= +q,s.result=function(e,t){var n=e?e[t]:r;return C(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,u=s.templateSettings,a=0,f=n.interpolate||u.interpolate||mt,l="__p+='",c=n.variable||u.variable,h=c;e.replace(RegExp((n.escape||u.escape||mt).source+"|"+f.source+"|"+(f===vt?dt:mt).source+"|"+(n.evaluate||u.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,u){return i||(i=s),l+=e +.slice(a,u).replace(yt,p),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),i&&(l+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),a=u+t.length,t}),l+="';\n",h||(c="obj",r?l="with("+c+"){"+l+"}":(n=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ht,"$&"+c+".").replace(n,"$1__d"))),l=(r?l.replace(at,""):l).replace(ft,"$1").replace(lt,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" +:(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{i=o("_","return "+l)(s)}catch(d){throw d.source=l,d}return t?i(t):(i.source=l,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,y)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=D,s.any=R,s.detect=H,s.foldl=I,s.foldr=q,s.include=_,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i=e.length +;return t==r||n?e[i-1]:g(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return""+this.__wrapped__},s.prototype.value=G,s.prototype.valueOf=G,wn(["join","pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),wn(["push","reverse","sort","unshift"],function(e){var t=et[e];s.prototype +[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),wn(["concat","slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Gt&&wn(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof +module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 5cf31e6fd8..96757bd743 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -908,7 +908,7 @@ * // => true */ var isArray = nativeIsArray || function(value) { - return toString.call(value) == arrayClass; + return value instanceof Array || toString.call(value) == arrayClass; }; /** @@ -942,7 +942,7 @@ * // => true */ function isDate(value) { - return toString.call(value) == dateClass; + return value instanceof Date || toString.call(value) == dateClass; } /** @@ -1190,7 +1190,7 @@ // fallback for older versions of Chrome and Safari if (isFunction(/x/)) { isFunction = function(value) { - return toString.call(value) == funcClass; + return value instanceof Function || toString.call(value) == funcClass; }; } @@ -1304,7 +1304,7 @@ * // => true */ function isRegExp(value) { - return toString.call(value) == regexpClass; + return value instanceof RegExp || toString.call(value) == regexpClass; } /** diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index b32d1a92ee..7874b93754 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -15,19 +15,19 @@ s)?nt.apply(i,t?s:D(s)):i.push(s)}return i}function P(e,t,n){var r=-1,i=e?e.leng e[i],f=n?n(r,i,e):r;if(t?!i||a[a.length-1]!==f:0>P(a,f))n&&a.push(f),u.push(r)}return u}function F(e,t){return bt||it&&2"']/g,G=/['\n\r\t\u2028\u2029\\]/g,Y=Math.ceil,Z=z.concat,et=Math.floor,tt=U.hasOwnProperty,nt=z.push,rt=U.toString,it=J.test(it=f.bind)&&it,st=J.test(st=Array.isArray)&&st,ot=e.isFinite,ut=e.isNaN,at=J.test(at=Object.keys)&&at,ft=Math.max,lt=Math.min,ct=Math.random,ht="[object Array]",pt="[object Boolean]" ,dt="[object Date]",vt="[object Number]",mt="[object Object]",gt="[object RegExp]",yt="[object String]",U=!!e.attachEvent,U=it&&!/\n|true/.test(it+U),bt=it&&!U,wt=(wt={0:1,length:1},z.splice.call(wt,0,1),wt[0]),Et={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},St={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},n.isArguments= -function(e){return"[object Arguments]"==rt.call(e)},n.isArguments(arguments)||(n.isArguments=function(e){return e?tt.call(e,"callee"):!1});var xt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(t(e[n],n,e)===X)break;return e},Tt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(tt.call(e,n)&&t(e[n],n,e)===X)break;return e},Nt={"&":"&","<":"<",">":">",'"':""","'":"'"},Ct=v(Nt),kt=st||function(e){return rt.call(e)==ht};g(/x/)&&(g=function(e){return"[object Function]"== -rt.call(e)});var Lt=at?function(e){return y(e)?at(e):[]}:h,At=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++ne?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=F,n.bindAll=function(e){for(var t=arguments,n=1P(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=D,n.forEach=At,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return At(e,function(e,n,i){n=t(e,n,i),(tt.call(r,n)?r[n]:r[n]=[]). -push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,lt(ft(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=[];return At(e,function(e){if(0>P(r,e)){for(var i=n;--i;)if(0>P(t[i],e))return;r.push(e)}}),r},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return At(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Lt,n.map=C,n.max=k,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply -(this,arguments):arguments[0];return tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!kt(e))t=s(t,n),At(e,function(e,n,i){n=t(e,n,i),nP(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1 -;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Tt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=Z.apply(z,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o|| -(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rP(arguments,i,1)&&r.push(i)}return r},n.wrap= -function(e,t){return function(){var n=[e];return nt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?k(L(arguments,"length")):0,r=Array(n);++tn?ft(0,r+n):lt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=q,n.noConflict=function(){return e._=V,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+et(ct()*((+t||0)-e+1))},n.reduce=A,n.reduceRight=O,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function( -e){var t=e?e.length:0;return"number"==typeof t?t:Lt(e).length},n.some=M,n.sortedIndex=B,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||K).source+"|"+(r.interpolate||K).source+"|"+(r.evaluate||K).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(G,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+ -u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace($,l)},n.uniqueId=function(e){var t=++W+"";return e?e+t:t},n.all=x,n.any=M,n.detect=N,n.foldl=A,n.foldr=O,n.include=S,n.inject=A,n.first=_,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,ft(0,r-t))}},n.take=_,n.head= -_,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.2",q(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},At("pop push reverse shift sort splice unshift".split(" "),function(e){var t=z[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),wt&&e.length===0&&delete e[0],this}}),At(["concat","join","slice"],function(e){var t=z[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__ -,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),R?"object"==typeof module&&module&&module.exports==R?(module.exports=n)._=n:R._=n:e._=n})(this); \ No newline at end of file +function(e){return"[object Arguments]"==rt.call(e)},n.isArguments(arguments)||(n.isArguments=function(e){return e?tt.call(e,"callee"):!1});var xt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(t(e[n],n,e)===X)break;return e},Tt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(tt.call(e,n)&&t(e[n],n,e)===X)break;return e},Nt={"&":"&","<":"<",">":">",'"':""","'":"'"},Ct=v(Nt),kt=st||function(e){return e instanceof Array||rt.call(e)==ht};g(/x/)&&(g=function(e) +{return e instanceof Function||"[object Function]"==rt.call(e)});var Lt=at?function(e){return y(e)?at(e):[]}:h,At=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++ne?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=F,n.bindAll=function(e){for(var t=arguments,n=1P(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=D,n.forEach=At,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return At(e,function( +e,n,i){n=t(e,n,i),(tt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,lt(ft(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=[];return At(e,function(e){if(0>P(r,e)){for(var i=n;--i;)if(0>P(t[i],e))return;r.push(e)}}),r},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return At(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Lt,n.map=C,n.max=k,n.memoize=function( +e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!kt(e))t=s(t,n),At(e,function(e,n,i){n=t(e,n,i),nP(t +,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Tt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=Z.apply(z,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rP(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return nt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?k(L(arguments,"length")):0,r=Array(n);++tn?ft(0,r+n):lt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=q,n.noConflict=function(){return e._=V,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+et(ct()*((+t||0)-e+1))} +,n.reduce=A,n.reduceRight=O,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Lt(e).length},n.some=M,n.sortedIndex=B,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||K).source+"|"+(r.interpolate||K).source+"|"+(r.evaluate||K).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(G,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+ +r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace($,l)},n.uniqueId=function(e){var t=++W+"";return e?e+t:t},n.all=x,n.any=M,n.detect=N,n.foldl=A,n.foldr=O,n.include=S,n.inject=A,n.first= +_,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,ft(0,r-t))}},n.take=_,n.head=_,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.2",q(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},At("pop push reverse shift sort splice unshift".split(" "),function(e){var t=z[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),wt&&e.length===0&&delete e[0],this}}), +At(["concat","join","slice"],function(e){var t=z[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),R?"object"==typeof module&&module&&module.exports==R?(module.exports=n)._=n:R._=n:e._=n})(this); \ No newline at end of file From f14010a09d4afb4f7700c435668df6d3fe832fd0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 11 Dec 2012 00:44:02 -0800 Subject: [PATCH 18/45] Make a private `each` function to be used by `_.forEach`. Former-commit-id: da9e22a66aef1ad9f4688f4fbb07e0806f8f0445 --- build.js | 51 +++++++++++++------------ lodash.js | 112 ++++++++++++++++++++++++++++++------------------------ 2 files changed, 90 insertions(+), 73 deletions(-) diff --git a/build.js b/build.js index dd877e1d1d..f51ea20997 100755 --- a/build.js +++ b/build.js @@ -73,7 +73,7 @@ 'clone': ['assign', 'forEach', 'forOwn', 'isArray', 'isObject'], 'compact': [], 'compose': [], - 'contains': ['forEach', 'indexOf', 'isString'], + 'contains': ['indexOf', 'isString'], 'countBy': ['forEach'], 'debounce': [], 'defaults': ['isArguments'], @@ -81,12 +81,12 @@ 'delay': [], 'difference': ['indexOf'], 'escape': [], - 'every': ['forEach', 'isArray'], - 'filter': ['forEach', 'isArray'], + 'every': ['isArray'], + 'filter': ['isArray'], 'find': ['forEach'], 'first': [], 'flatten': ['isArray'], - 'forEach': ['identity', 'isArguments', 'isString'], + 'forEach': ['identity', 'isArguments', 'isArray', 'isString'], 'forIn': ['identity', 'isArguments'], 'forOwn': ['identity', 'isArguments'], 'functions': ['forIn', 'isFunction'], @@ -95,7 +95,7 @@ 'identity': [], 'indexOf': ['sortedIndex'], 'initial': [], - 'intersection': ['filter', 'indexOf'], + 'intersection': ['forEach', 'indexOf'], 'invert': ['forOwn'], 'invoke': ['forEach'], 'isArguments': [], @@ -118,11 +118,11 @@ 'keys': ['forOwn', 'isArguments', 'isObject'], 'last': [], 'lastIndexOf': [], - 'map': ['forEach', 'isArray'], - 'max': ['forEach', 'isArray', 'isString'], + 'map': ['isArray'], + 'max': ['isArray', 'isString'], 'memoize': [], 'merge': ['forOwn', 'isArray', 'isPlainObject'], - 'min': ['forEach', 'isArray', 'isString'], + 'min': ['isArray', 'isString'], 'mixin': ['forEach', 'forOwn', 'functions'], 'noConflict': [], 'object': [], @@ -134,14 +134,14 @@ 'pluck': ['map'], 'random': [], 'range': [], - 'reduce': ['forEach', 'isArray'], + 'reduce': ['isArray'], 'reduceRight': ['forEach', 'isString', 'keys'], 'reject': ['filter'], 'rest': [], 'result': ['isFunction'], 'shuffle': ['forEach'], 'size': ['keys'], - 'some': ['forEach', 'isArray'], + 'some': ['isArray'], 'sortBy': ['forEach'], 'sortedIndex': ['identity'], 'tap': ['mixin'], @@ -368,10 +368,10 @@ }); // replace wrapper `Array` method assignments - source = source.replace(/^(?: *\/\/.*\n)*( *)forEach\(\['[\s\S]+?\n\1}$/m, function() { + source = source.replace(/^(?: *\/\/.*\n)*( *)each\(\['[\s\S]+?\n\1}$/m, function() { return [ ' // add `Array` mutator functions to the wrapper', - " forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {", + " each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {", ' var func = arrayRef[methodName];', ' lodash.prototype[methodName] = function() {', ' var value = this.__wrapped__;', @@ -387,7 +387,7 @@ ' });', '', ' // add `Array` accessor functions to the wrapper', - " forEach(['concat', 'join', 'slice'], function(methodName) {", + " each(['concat', 'join', 'slice'], function(methodName) {", ' var func = arrayRef[methodName];', ' lodash.prototype[methodName] = function() {', ' var value = this.__wrapped__,', @@ -1274,11 +1274,11 @@ dependencyMap.reduceRight = ['forEach', 'keys']; } if (isUnderscore) { - dependencyMap.contains = ['forEach', 'indexOf']; + dependencyMap.contains = ['indexOf']; dependencyMap.isEqual = ['isArray', 'isFunction']; dependencyMap.isEmpty = ['isArray', 'isString']; - dependencyMap.max = ['forEach', 'isArray']; - dependencyMap.min = ['forEach', 'isArray']; + dependencyMap.max = ['isArray']; + dependencyMap.min = ['isArray']; dependencyMap.pick = []; dependencyMap.template = ['defaults', 'escape']; @@ -1390,7 +1390,7 @@ " if (typeof length == 'number') {", ' result = indexOf(collection, target) > -1;', ' } else {', - ' forEach(collection, function(value) {', + ' each(collection, function(value) {', ' return (result = value === target) && indicatorObject;', ' });', ' }', @@ -1734,7 +1734,8 @@ if (isMobile) { // inline all functions defined with `createIterator` _.functions(lodash).forEach(function(methodName) { - var reFunc = RegExp('(\\bvar ' + methodName + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n'); + // strip leading underscores to match pseudo private functions + var reFunc = RegExp('(\\bvar ' + methodName.replace(/^_/, '') + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n'); if (reFunc.test(source)) { // extract, format, and inject the compiled function's source code source = source.replace(reFunc, function(match, captured) { @@ -1777,13 +1778,15 @@ }); }()); - // remove chainability from `_.forEach` - source = source.replace(matchFunction(source, 'forEach'), function(match) { - return match.replace(/return result([};\s]+)$/, '$1'); + // remove chainability from `each` and `_.forEach` + _.each(['each', 'forEach'], function(methodName) { + source = source.replace(matchFunction(source, methodName), function(match) { + return match.replace(/\n *return .+?([};\s]+)$/, '$1'); + }); }); - // unexpose "exit early" feature from `_.forEach`, `_.forIn`, and `_.forOwn` - _.each(['forEach', 'forIn', 'forOwn'], function(methodName) { + // unexpose "exit early" feature of `each`, `_.forEach`, `_.forIn`, and `_.forOwn` + _.each(['each', 'forEach', 'forIn', 'forOwn'], function(methodName) { source = source.replace(matchFunction(source, methodName), function(match) { return match.replace(/=== *false\)/g, '=== indicatorObject)'); }); @@ -1962,7 +1965,7 @@ // remove all `lodash.prototype` additions source = source .replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, '') - .replace(/(?:\s*\/\/.*)*\n( *)forEach\(\['[\s\S]+?\n\1}.+/g, '') + .replace(/(?:\s*\/\/.*)*\n( *)each\(\['[\s\S]+?\n\1}.+/g, '') .replace(/(?:\s*\/\/.*)*\s*lodash\.prototype.+\n/g, '') .replace(/(?:\s*\/\/.*)*\s*mixin\(lodash\).+\n/, ''); } diff --git a/lodash.js b/lodash.js index 5d58a91819..eb7781b8ae 100644 --- a/lodash.js +++ b/lodash.js @@ -116,8 +116,7 @@ stringClass = '[object String]'; /** Detect various environments */ - var isFirefox = !/1/.test(Function('1')), - isIeOpera = !!window.attachEvent, + var isIeOpera = !!window.attachEvent, isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera); /* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */ @@ -247,24 +246,25 @@ * method chaining. * * The chainable wrapper functions are: - * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, - * `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, + * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, + * `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, * `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, * `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, * `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, - * `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, - * `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` + * `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, + * `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, + * `unshift`, `values`, `where`, `without`, `wrap`, and `zip` * * The non-chainable wrapper functions are: * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, * `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, * `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, - * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, `mixin`, - * `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, `some`, - * `sortedIndex`, `template`, `unescape`, and `uniqueId` + * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, + * `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, + * `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` * * The wrapper functions `first` and `last` return wrapped values when `n` is - * passed, otherwise return unwrapped values. + * passed, otherwise they return unwrapped values. * * @name _ * @constructor @@ -334,25 +334,6 @@ /*--------------------------------------------------------------------------*/ - /** - * Creates a function from the given `args` and `body` strings. - * - * @private - * @param {String} args The comma separated function arguments. - * @param {String} body The function body. - * @returns {Function} The new function. - */ - function createFunction(args, body) { - // the newline, in `'\n}'`, is required to avoid errors if `body` ends - // with a single line comment - return window.eval('(function(' + args + ') {' + body + '\n})'); - } - // use `eval` to avoid Firefox's unoptimized `Function` constructor - // http://bugzil.la/804933 - if (isIeOpera || isV8 || !isFirefox) { - createFunction = Function; - } - /** * The template used to create iterator functions. * @@ -476,9 +457,9 @@ }; /** - * Reusable iterator options shared by `forEach`, `forIn`, and `forOwn`. + * Reusable iterator options shared by `each`, `forIn`, and `forOwn`. */ - var forEachIteratorOptions = { + var eachIteratorOptions = { 'args': 'collection, callback, thisArg', 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)", 'arrayLoop': 'if (callback(iteratee[index], index, collection) === false) return result', @@ -696,7 +677,7 @@ data.firstArg = /^[^,]+/.exec(args)[0]; // create the function factory - var factory = createFunction( + var factory = Function( 'createCallback, hasOwnProperty, isArguments, isString, objectTypes, ' + 'nativeKeys, propertyIsEnumerable', 'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}' @@ -708,6 +689,21 @@ ); } + /** + * A function compiled to iterate `arguments` objects, arrays, objects, and + * strings consistenly across environments, executing the `callback` for each + * element in the `collection`. The `callback` is bound to `thisArg` and invoked + * with three arguments; (value, index|key, collection). Callbacks may exit + * iteration early by explicitly returning `false`. + * + * @private + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|String} Returns `collection`. + */ + var each = createIterator(eachIteratorOptions); + /** * Used by `template` to escape characters for inclusion in compiled * string literals. @@ -867,7 +863,7 @@ * }); * // => alerts 'name' and 'bark' (order is not guaranteed) */ - var forIn = createIterator(forEachIteratorOptions, forOwnIteratorOptions, { + var forIn = createIterator(eachIteratorOptions, forOwnIteratorOptions, { 'useHas': false }); @@ -891,7 +887,7 @@ * }); * // => alerts '0', '1', and 'length' (order is not guaranteed) */ - var forOwn = createIterator(forEachIteratorOptions, forOwnIteratorOptions); + var forOwn = createIterator(eachIteratorOptions, forOwnIteratorOptions); /** * A fallback implementation of `isPlainObject` that checks if a given `value` @@ -1941,7 +1937,7 @@ : indexOf(collection, target, fromIndex) ) > -1; } else { - forEach(collection, function(value) { + each(collection, function(value) { if (++index >= fromIndex) { return !(result = value === target); } @@ -2020,7 +2016,7 @@ } } } else { - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { return (result = !!callback(value, index, collection)); }); } @@ -2060,7 +2056,7 @@ } } } else { - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { if (callback(value, index, collection)) { result.push(value); } @@ -2124,7 +2120,24 @@ * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); * // => alerts each number value (order is not guaranteed) */ - var forEach = createIterator(forEachIteratorOptions); + function forEach(collection, callback, thisArg) { + if (isArray(collection)) { + var index = -1, + length = collection.length; + + if (!callback || typeof thisArg != 'undefined') { + callback = createCallback(callback, thisArg); + } + while (++index < length) { + if (callback(collection[index], index, collection) === false) { + break; + } + } + } else { + each(collection, callback, thisArg); + } + return collection; + } /** * Creates an object composed of keys returned from running each element of @@ -2228,7 +2241,7 @@ result[index] = callback(collection[index], index, collection); } } else { - forEach(collection, function(value, key, collection) { + each(collection, function(value, key, collection) { result[++index] = callback(value, key, collection); }); } @@ -2270,7 +2283,7 @@ ? charAtCallback : createCallback(callback, thisArg); - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { var current = callback(value, index, collection); if (current > computed) { computed = current; @@ -2316,7 +2329,7 @@ ? charAtCallback : createCallback(callback, thisArg); - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { var current = callback(value, index, collection); if (current < computed) { computed = current; @@ -2393,7 +2406,7 @@ accumulator = callback(accumulator, collection[index], index, collection); } } else { - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { accumulator = noaccum ? (noaccum = false, value) : callback(accumulator, value, index, collection) @@ -2550,7 +2563,7 @@ } } } else { - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { return !(result = callback(value, index, collection)); }); } @@ -4006,7 +4019,7 @@ : ''; try { - result = createFunction('_', 'return ' + source + sourceURL)(lodash); + result = Function('_', 'return ' + source + sourceURL)(lodash); } catch(e) { e.source = source; throw e; @@ -4136,7 +4149,7 @@ * // => '1,2,3' */ function wrapperToString() { - return String(this.__wrapped__); + return this.__wrapped__ + ''; } /** @@ -4323,7 +4336,7 @@ lodash.prototype.valueOf = wrapperValueOf; // add `Array` functions that return unwrapped values - forEach(['join', 'pop', 'shift'], function(methodName) { + each(['join', 'pop', 'shift'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { return func.apply(this.__wrapped__, arguments); @@ -4331,7 +4344,7 @@ }); // add `Array` functions that return the wrapped value - forEach(['push', 'reverse', 'sort', 'unshift'], function(methodName) { + each(['push', 'reverse', 'sort', 'unshift'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { func.apply(this.__wrapped__, arguments); @@ -4340,7 +4353,7 @@ }); // add `Array` functions that return new wrapped values - forEach(['concat', 'slice', 'splice'], function(methodName) { + each(['concat', 'slice', 'splice'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { var result = func.apply(this.__wrapped__, arguments); @@ -4351,7 +4364,7 @@ // avoid array-like object bugs with `Array#shift` and `Array#splice` // in Firefox < 10 and IE < 9 if (hasObjectSpliceBug) { - forEach(['shift', 'splice'], function(methodName) { + each(['shift', 'splice'], function(methodName) { var func = lodash.prototype[methodName]; lodash.prototype[methodName] = function() { var value = this.__wrapped__, @@ -4366,6 +4379,7 @@ } // add pseudo private property to be used and removed during the build process + lodash._each = each; lodash._iteratorTemplate = iteratorTemplate; /*--------------------------------------------------------------------------*/ From 749f49b1a00f360c46521ad21a0d3020200de681 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 11 Dec 2012 00:54:09 -0800 Subject: [PATCH 19/45] Add `instanceof` memory leak warning to `_.isArray`. Former-commit-id: f90b1ad1850fb21c1d976f037a382c7388496d1c --- lodash.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lodash.js b/lodash.js index eb7781b8ae..67f451c5a1 100644 --- a/lodash.js +++ b/lodash.js @@ -1180,6 +1180,8 @@ * // => true */ var isArray = nativeIsArray || function(value) { + // `instanceof` may cause a memory leak in IE 7 if `value` is a host object + // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak return value instanceof Array || toString.call(value) == arrayClass; }; From fe3e78cc1cb0aaef664c7a09e5dacb017de6f9aa Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 11 Dec 2012 01:07:25 -0800 Subject: [PATCH 20/45] Update vendors, rebuild minified files, update docs/license. Former-commit-id: 689793b6e5c4bbae917e726dc646902c697ce3a7 --- CONTRIBUTING.md | 2 +- LICENSE.txt | 2 +- README.md | 2 +- doc/README.md | 194 ++++++++++++++--------------- lodash.min.js | 74 +++++------ lodash.underscore.js | 110 ++++++++++------ lodash.underscore.min.js | 54 ++++---- vendor/backbone/backbone.js | 127 ++++++++++++++----- vendor/backbone/test/collection.js | 136 +++++++++++++++++--- vendor/backbone/test/events.js | 120 +++++++++++++++++- vendor/backbone/test/model.js | 26 ++-- vendor/backbone/test/router.js | 14 +-- vendor/underscore/test/objects.js | 12 ++ 13 files changed, 605 insertions(+), 268 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db21069c06..ca4191ac06 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ The [Backbone](http://backbonejs.org/) and [Underscore](http://http://underscore ## Contributor License Agreement -Lo-Dash is a [Dojo Foundation](http://dojofoundation.org/) project. +Lo-Dash is preparing to join [Dojo Foundation](http://dojofoundation.org/). As such, we request that all contributors sign the Dojo Foundation [contributor license agreement](http://dojofoundation.org/about/claForm). For more information about CLAs, please check out Alex Russell’s excellent post, ["Why Do I Need to Sign This?"](http://infrequently.org/2008/06/why-do-i-need-to-sign-this/). diff --git a/LICENSE.txt b/LICENSE.txt index b194ad1deb..cd3ae1777d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ Copyright 2012 John-David Dalton -Based on Underscore.js 1.3.3, copyright 2009-2012 Jeremy Ashkenas, +Based on Underscore.js 1.4.3, copyright 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. Permission is hereby granted, free of charge, to any person obtaining diff --git a/README.md b/README.md index 6a2cd350fe..85a395fac7 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ For more information check out these screencasts over Lo-Dash: ## Support -Lo-Dash has been tested in at least Chrome 5~23, Firefox 1~16, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.15, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. +Lo-Dash has been tested in at least Chrome 5~23, Firefox 1~17, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.15, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5. ## Custom builds diff --git a/doc/README.md b/doc/README.md index 1ee423556d..57a520aa0d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -185,7 +185,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2679 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2694 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -209,7 +209,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2709 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2724 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -234,7 +234,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2759 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -262,7 +262,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2771 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2786 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -290,7 +290,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2813 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2828 "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, passing `true` for `fromIndex` will run a faster binary search. @@ -322,7 +322,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2863 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -347,7 +347,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2872 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2887 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -371,7 +371,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2910 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2925 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -396,7 +396,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2937 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2952 "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. @@ -425,7 +425,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2967 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2982 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -450,7 +450,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3012 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3027 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -488,7 +488,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3051 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3066 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -516,7 +516,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3110 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -560,7 +560,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3127 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3142 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -584,7 +584,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#L3161 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3176 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -623,7 +623,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3221 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3236 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -648,7 +648,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3252 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3267 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -681,7 +681,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L275 "View in source") [Ⓣ][1] -Creates a `lodash` object, that wraps the given `value`, to enable method chaining. The chainable wrapper functions are: `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` The non-chainable wrapper functions are: `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, `mixin`, `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise return unwrapped values. +Creates a `lodash` object, that wraps the given `value`, to enable method chaining. The chainable wrapper functions are: `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` The non-chainable wrapper functions are: `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values. #### Arguments 1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. @@ -697,7 +697,7 @@ Creates a `lodash` object, that wraps the given `value`, to enable method chaini ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4121 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4136 "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. @@ -727,7 +727,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4138 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4153 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -748,7 +748,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4155 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4170 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -779,7 +779,7 @@ _([1, 2, 3]).valueOf(); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1932 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1930 "View in source") [Ⓣ][1] Checks if a given `target` element 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. @@ -817,7 +817,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1979 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1977 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -849,7 +849,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2009 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2007 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -878,7 +878,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2048 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2046 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -907,7 +907,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2092 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2090 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -936,7 +936,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2127 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2125 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -968,7 +968,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2155 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2170 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1000,7 +1000,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2188 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2203 "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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1029,7 +1029,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2235 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1061,7 +1061,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2277 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, 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)*. @@ -1093,7 +1093,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2308 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2323 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, 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)*. @@ -1119,7 +1119,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2357 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2372 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1150,7 +1150,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2381 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2396 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1180,7 +1180,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2423 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2438 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1211,7 +1211,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#L2461 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2476 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -1237,7 +1237,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2482 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2497 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1261,7 +1261,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2514 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2529 "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. @@ -1291,7 +1291,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2539 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2554 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds 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)*. @@ -1320,7 +1320,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2585 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2600 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1352,7 +1352,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2618 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2633 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1376,7 +1376,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2649 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2664 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1414,7 +1414,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3285 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3300 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1442,7 +1442,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3318 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3333 "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 passed to the bound function. @@ -1473,7 +1473,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3348 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3363 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1504,7 +1504,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3394 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3409 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. @@ -1545,7 +1545,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3417 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3432 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1572,7 +1572,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3450 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3465 "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. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1598,7 +1598,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3514 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3529 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1623,7 +1623,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3494 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3509 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1650,7 +1650,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3538 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3553 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1676,7 +1676,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3565 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3580 "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. @@ -1702,7 +1702,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3600 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3615 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1729,7 +1729,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3622 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3637 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1754,7 +1754,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3675 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3690 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1790,7 +1790,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L814 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L810 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1818,7 +1818,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1013 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1009 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, all nested objects will also be cloned, otherwise they will be assigned by reference. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm. See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. @@ -1857,7 +1857,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1097 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1883,7 +1883,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L866 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, 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`. @@ -1919,7 +1919,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L894 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L890 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, 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`. @@ -1947,7 +1947,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1120 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1116 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -1974,7 +1974,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1141 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -1999,7 +1999,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1158 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2023,7 +2023,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L828 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2050,7 +2050,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1186 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1182 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2077,7 +2077,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1203 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1201 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2101,7 +2101,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1218 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2125,7 +2125,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1237 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1235 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2149,7 +2149,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1260 "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". @@ -2179,7 +2179,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1304 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1302 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2210,7 +2210,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1456 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1454 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. @@ -2246,7 +2246,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1473 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1471 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2270,7 +2270,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1536 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1534 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. @@ -2303,7 +2303,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1558 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1556 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2330,7 +2330,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1575 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1573 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2354,7 +2354,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1503 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1501 "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('')`)* @@ -2384,7 +2384,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1603 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1601 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2419,7 +2419,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1628 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1626 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2443,7 +2443,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1645 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1643 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2467,7 +2467,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1662 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1660 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2491,7 +2491,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1679 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1677 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2515,7 +2515,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1717 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1715 "View in source") [Ⓣ][1] Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2550,7 +2550,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1791 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1789 "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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2581,7 +2581,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1825 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1823 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2605,7 +2605,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1858 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1856 "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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2636,7 +2636,7 @@ _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1895 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1893 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2667,7 +2667,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3699 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3714 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2691,7 +2691,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3719 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3734 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: This function is used throughout Lo-Dash as a default callback. @@ -2716,7 +2716,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3745 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3760 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2746,7 +2746,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3771 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3786 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2766,7 +2766,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3809 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2794,7 +2794,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3847 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2829,7 +2829,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3917 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3932 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html @@ -2903,7 +2903,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4048 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4063 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -2935,7 +2935,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4074 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4089 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -2959,7 +2959,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4094 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4109 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -2993,7 +2993,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4318 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4333 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.min.js b/lodash.min.js index caaa89c46e..9bdb48db41 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -2,41 +2,41 @@ Lo-Dash 1.0.0-rc.2 lodash.com/license Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(e,t){function s(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof s))return new s(e);this.__wrapped__=e}function o(t,n){return e.eval("(function("+t+"){"+n+"})")}function u(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||it);if(i)for(var s={},n=t-1;++nt||"undefined"==typeof e)return 1;if(ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" -,o("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(c,Tt,b,A,on,_t,Ct)}function p(e){return"\\"+un[e]}function d(e){return dn[e]}function v(e){return"function"!=typeof e.toString&&"string"==typeof (e+"")}function m(){}function g(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Dt(0,s+n):n)||0;return"number"==typeof s?o=-1<(A(e)?e.indexOf(t,n):W(e,t,n)):wn(e,function(e){if(++r>=n)return!(o=e===t)}),o}function D(e,t,r){var i=n,t=c -(t,r);if(gn(e))for(var r=-1,s=e.length;++rr&&(r=n,o=e)});else for(;++io&&(o=e[i]);return o}function F(e,t){return B(e,t+"")}function I(e,t,r,s){var o=3>arguments.length,t=c(t,s,n);if(gn(e)){var u=-1,a=e.length;for(o&&(r=e[++u]);++uarguments -.length;if("number"!=typeof u)var f=bn(e),u=f.length;else en&&A(e)&&(o=e.split(""));return t=c(t,s,n),wn(e,function(e,n,s){n=f?f[--u]:--u,r=a?(a=i,o[n]):t(r,o[n],n,s)}),r}function R(e,t,n){var r,t=c(t,n);if(gn(e))for(var n=-1,i=e.length;++nn?Dt(0,i+n):n||0)-1;else if(n)return r=V(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])W(a,h))(n||f)&&a.push(h),u.push(r)}return u}function J(e,t){return $t||Lt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ut=/&(?:amp|lt|gt|quot|#x27);/g,at=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,lt=/(__e\(.*?\)|\b__t\))\+'';/g,ct=/\w*$/,ht=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,pt=RegExp("^"+(tt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),dt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,vt=/<%=([\s\S]+?)%>/g -,mt=/($^)/,gt=/[&<>"']/g,yt=/['\n\r\t\u2028\u2029\\]/g,bt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),wt=Math.ceil,Et=et.concat,St=Math.floor,xt=pt.test(xt=Object.getPrototypeOf)&&xt,Tt=tt.hasOwnProperty,Nt=et.push,Ct=tt.propertyIsEnumerable,kt=tt.toString,Lt=pt.test(Lt=g.bind)&&Lt,At=pt.test(At=Array.isArray)&&At,Ot=e.isFinite,Mt=e.isNaN,_t=pt.test(_t=Object.keys)&&_t,Dt=Math.max,Pt=Math.min,Ht=Math.random,Bt="[object Arguments]",jt="[object Array]" -,Ft="[object Boolean]",It="[object Date]",qt="[object Number]",Rt="[object Object]",Ut="[object RegExp]",zt="[object String]",Wt=!/1/.test(Function("1")),Xt=!!e.attachEvent,Vt=Lt&&!/\n|true/.test(Lt+Xt),$t=Lt&&!Vt,Jt=_t&&(Xt||Vt),Kt,Qt,Gt=(Gt={0:1,length:1},et.splice.call(Gt,0,1),Gt[0]),Yt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Yt=!n;Kt=!/valueOf/.test(t),Qt="x"!=t[0]})(1);var Zt=!b(arguments),en="xx"!="x"[0]+Object -("x")[0];try{var tn=("[object Object]",kt.call(document)==Rt)}catch(nn){}var rn={"[object Function]":i};rn[Bt]=rn[jt]=rn[Ft]=rn[It]=rn[qt]=rn[Rt]=rn[Ut]=rn[zt]=n;var sn={};sn[jt]=Array,sn[Ft]=Boolean,sn[It]=Date,sn[Rt]=Object,sn[qt]=Number,sn[Ut]=RegExp,sn[zt]=String;var on={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},un={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate -:vt,variable:""};if(Xt||Vt||!Wt)o=Function;var an={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},vn=T(dn),mn=h(an,{g:"if(t[i]==null)"+ -an.g}),gn=At||function(e){return e instanceof Array||kt.call(e)==jt};C(/x/)&&(C=function(e){return e instanceof Function||"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!b(e):w(e)}:w,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?E(e):k(e)?_t(e):[]}:E,wn=h(fn);s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},s. -assign=cn,s.bind=J,s.bindAll=function(e){for(var t=arguments,n=1W(i,e)){for(var s=n;--s;)if(!(r[s]||(r[s]=u(t[s])))(e)) -return;i.push(e)}}),i},s.invert=T,s.invoke=function(e,t){var n=g(arguments,2),r="function"==typeof t,i=[];return wn(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=O,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&A(e)?a:c(t,n),wn(e,function(e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([n,e])}),t},s.partial=function( -e){return l(e,g(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.times= -function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight= -q,s.result=function(e,t){var n=e?e[t]:r;return C(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,u=s.templateSettings,a=0,f=n.interpolate||u.interpolate||mt,l="__p+='",c=n.variable||u.variable,h=c;e.replace(RegExp((n.escape||u.escape||mt).source+"|"+f.source+"|"+(f===vt?dt:mt).source+"|"+(n.evaluate||u.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,u){return i||(i=s),l+=e -.slice(a,u).replace(yt,p),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),i&&(l+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),a=u+t.length,t}),l+="';\n",h||(c="obj",r?l="with("+c+"){"+l+"}":(n=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ht,"$&"+c+".").replace(n,"$1__d"))),l=(r?l.replace(at,""):l).replace(ft,"$1").replace(lt,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" -:(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{i=o("_","return "+l)(s)}catch(d){throw d.source=l,d}return t?i(t):(i.source=l,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,y)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=D,s.any=R,s.detect=H,s.foldl=I,s.foldr=q,s.include=_,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i=e.length -;return t==r||n?e[i-1]:g(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return""+this.__wrapped__},s.prototype.value=G,s.prototype.valueOf=G,wn(["join","pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),wn(["push","reverse","sort","unshift"],function(e){var t=et[e];s.prototype -[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),wn(["concat","slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Gt&&wn(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof +;(function(e,t){function s(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof s))return new s(e);this.__wrapped__=e}function o(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||it);if(i)for(var s={},n=t-1;++nt||"undefined"==typeof e)return 1;if( +ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t",Function("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(l,Tt,y,L,sn +,_t,Ct)}function h(e){return"\\"+on[e]}function p(e){return dn[e]}function d(e){return"function"!=typeof e.toString&&"string"==typeof (e+"")}function v(){}function m(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Dt(0,s+n):n)||0;return"number"==typeof s?o=-1<(L(e)?e.indexOf(t,n):W(e,t,n)):ln(e,function(e){if(++r>=n)return!(o=e===t)}),o}function _(e,t,r){var i=n,t=l(t,r);if(gn(e))for(var r=-1,s=e.length;++rr&&(r=n,o=e)});else for(;++io&&(o=e[i]);return o}function F(e,t){return B(e,t+"")}function I(e,t,r,s){var o=3>arguments.length,t=l(t,s,n);if(gn(e)){var u=-1,a=e.length;for(o&&(r=e[++u]);++uarguments.length;if("number"!=typeof u)var f=bn(e),u=f.length;else Zt&&L(e)&&(o=e.split(""));return t=l(t,s,n),H(e,function(e,n,s){n=f?f[--u]:--u,r=a?(a=i,o[n]):t(r,o[n],n,s)}),r}function R(e,t,n){var r,t=l(t,n);if(gn(e))for(var n=-1,i=e.length;++nn?Dt(0,i+n):n||0)-1;else if(n)return r=V(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])W(a,h))(n||f)&&a.push(h),u.push(r)}return u}function J(e,t){return Vt||Lt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ut=/&(?:amp|lt|gt|quot|#x27);/g,at=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,lt=/(__e\(.*?\)|\b__t\))\+'';/g,ct=/\w*$/,ht=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,pt=RegExp("^"+(tt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g +,".+?")+"$"),dt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,vt=/<%=([\s\S]+?)%>/g,mt=/($^)/,gt=/[&<>"']/g,yt=/['\n\r\t\u2028\u2029\\]/g,bt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),wt=Math.ceil,Et=et.concat,St=Math.floor,xt=pt.test(xt=Object.getPrototypeOf)&&xt,Tt=tt.hasOwnProperty,Nt=et.push,Ct=tt.propertyIsEnumerable,kt=tt.toString,Lt=pt.test(Lt=m.bind)&&Lt,At=pt.test(At=Array.isArray)&&At,Ot=e.isFinite,Mt=e.isNaN,_t=pt.test(_t=Object.keys)&& +_t,Dt=Math.max,Pt=Math.min,Ht=Math.random,Bt="[object Arguments]",jt="[object Array]",Ft="[object Boolean]",It="[object Date]",qt="[object Number]",Rt="[object Object]",Ut="[object RegExp]",zt="[object String]",Wt=!!e.attachEvent,Xt=Lt&&!/\n|true/.test(Lt+Wt),Vt=Lt&&!Xt,$t=_t&&(Wt||Xt),Jt,Kt,Qt=(Qt={0:1,length:1},et.splice.call(Qt,0,1),Qt[0]),Gt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Gt=!n;Jt=!/valueOf/.test(t),Kt="x"!= +t[0]})(1);var Yt=!y(arguments),Zt="xx"!="x"[0]+Object("x")[0];try{var en=("[object Object]",kt.call(document)==Rt)}catch(tn){}var nn={"[object Function]":i};nn[Bt]=nn[jt]=nn[Ft]=nn[It]=nn[qt]=nn[Rt]=nn[Ut]=nn[zt]=n;var rn={};rn[jt]=Array,rn[Ft]=Boolean,rn[It]=Date,rn[Rt]=Object,rn[qt]=Number,rn[Ut]=RegExp,rn[zt]=String;var sn={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},on={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape +:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:vt,variable:""};var un={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'" +},vn=x(dn),mn=c(un,{g:"if(t[i]==null)"+un.g}),gn=At||function(e){return e instanceof Array||kt.call(e)==jt};N(/x/)&&(N=function(e){return e instanceof Function||"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!y(e):b(e)}:b,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?w(e):C(e)?_t(e):[]}:w;s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t +.apply(this,arguments)}},s.assign=cn,s.bind=J,s.bindAll=function(e){for(var t=arguments,n=1W(i,e)){for(var s=n;--s;)if(!(r[ +s]||(r[s]=o(t[s])))(e))return;i.push(e)}}),i},s.invert=x,s.invoke=function(e,t){var n=m(arguments,2),r="function"==typeof t,i=[];return H(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=A,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&L(e)?u:l(t,n),ln(e,function(e,n,i){n=t(e,n,i), +nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([ +n,e])}),t},s.partial=function(e){return f(e,m(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout +(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I, +s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return N(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,o=s.templateSettings,u=0,a=n.interpolate||o.interpolate||mt,f="__p+='",l=n.variable||o.variable,c=l;e.replace(RegExp((n.escape||o.escape||mt).source+"|"+a.source+"|"+(a===vt?dt:mt).source+"|"+(n.evaluate||o.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,a){return i|| +(i=s),f+=e.slice(u,a).replace(yt,h),n&&(f+="'+__e("+n+")+'"),o&&(f+="';"+o+";__p+='"),i&&(f+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),u=a+t.length,t}),f+="';\n",c||(l="obj",r?f="with("+l+"){"+f+"}":(n=RegExp("(\\(\\s*)"+l+"\\."+l+"\\b","g"),f=f.replace(ht,"$&"+l+".").replace(n,"$1__d"))),f=(r?f.replace(at,""):f).replace(ft,"$1").replace(lt,"$1;"),f="function("+l+"){"+(c?"":l+"||("+l+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" +:(c?"":",__d="+l+"."+l+"||"+l)+";")+f+"return __p}";try{i=Function("_","return "+f)(s)}catch(p){throw p.source=f,p}return t?i(t):(i.source=f,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,g)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=_,s.any=R,s.detect=P,s.foldl=I,s.foldr=q,s.include=M,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i= +e.length;return t==r||n?e[i-1]:m(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return this.__wrapped__+""},s.prototype.value=G,s.prototype.valueOf=G,ln(["join","pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),ln(["push","reverse","sort","unshift"],function(e){var t=et[e]; +s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),ln(["concat","slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Qt&&ln(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 96757bd743..1edc4d1d26 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -186,24 +186,25 @@ * method chaining. * * The chainable wrapper functions are: - * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, - * `compose`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, + * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, + * `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, * `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, * `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, * `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, - * `range`, `reject`, `rest`, `shuffle`, `sortBy`, `tap`, `throttle`, `times`, - * `toArray`, `union`, `uniq`, `values`, `where`, `without`, `wrap`, and `zip` + * `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, + * `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, + * `unshift`, `values`, `where`, `without`, `wrap`, and `zip` * * The non-chainable wrapper functions are: * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, * `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, * `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, - * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `lastIndexOf`, `mixin`, - * `noConflict`, `random`, `reduce`, `reduceRight`, `result`, `size`, `some`, - * `sortedIndex`, `template`, `unescape`, and `uniqueId` + * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, + * `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, + * `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` * * The wrapper functions `first` and `last` return wrapped values when `n` is - * passed, otherwise return unwrapped values. + * passed, otherwise they return unwrapped values. * * @name _ * @constructor @@ -272,6 +273,7 @@ }; /*--------------------------------------------------------------------------*/ + /** Reusable iterator options for `assign` and `defaults` */ var assignIteratorOptions = { 'args': 'object, source, guard', @@ -283,9 +285,9 @@ }; /** - * Reusable iterator options shared by `forEach`, `forIn`, and `forOwn`. + * Reusable iterator options shared by `each`, `forIn`, and `forOwn`. */ - var forEachIteratorOptions = { + var eachIteratorOptions = { 'args': 'collection, callback, thisArg', 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)", 'arrayLoop': 'if (callback(iteratee[index], index, collection) === false) return result', @@ -462,6 +464,38 @@ ); } + /** + * A function compiled to iterate `arguments` objects, arrays, objects, and + * strings consistenly across environments, executing the `callback` for each + * element in the `collection`. The `callback` is bound to `thisArg` and invoked + * with three arguments; (value, index|key, collection). Callbacks may exit + * iteration early by explicitly returning `false`. + * + * @private + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|String} Returns `collection`. + */ + var each = function (collection, callback, thisArg) { + var index, iteratee = collection, result = collection; + if (!collection) return result; + callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg); + var length = iteratee.length; index = -1; + if (typeof length == 'number') { + while (++index < length) { + if (callback(iteratee[index], index, collection) === indicatorObject) return result + } + } + else { + for (index in iteratee) { + if (hasOwnProperty.call(iteratee, index)) { + if (callback(iteratee[index], index, collection) === indicatorObject) return result; + } + } + } + }; + /** * Used by `template` to escape characters for inclusion in compiled * string literals. @@ -908,6 +942,8 @@ * // => true */ var isArray = nativeIsArray || function(value) { + // `instanceof` may cause a memory leak in IE 7 if `value` is a host object + // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak return value instanceof Array || toString.call(value) == arrayClass; }; @@ -1513,7 +1549,7 @@ if (typeof length == 'number') { result = indexOf(collection, target) > -1; } else { - forEach(collection, function(value) { + each(collection, function(value) { return (result = value === target) && indicatorObject; }); } @@ -1590,7 +1626,7 @@ } } } else { - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { return !(result = !!callback(value, index, collection)) && indicatorObject; }); } @@ -1630,7 +1666,7 @@ } } } else { - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { if (callback(value, index, collection)) { result.push(value); } @@ -1694,25 +1730,23 @@ * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); * // => alerts each number value (order is not guaranteed) */ - var forEach = function (collection, callback, thisArg) { - var index, iteratee = collection, result = collection; - if (!collection) return result; - callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg); - var length = iteratee.length; index = -1; - if (typeof length == 'number') { - while (++index < length) { - if (callback(iteratee[index], index, collection) === indicatorObject) return result + function forEach(collection, callback, thisArg) { + if (isArray(collection)) { + var index = -1, + length = collection.length; + + if (!callback || typeof thisArg != 'undefined') { + callback = createCallback(callback, thisArg); } - } - else { - for (index in iteratee) { - if (hasOwnProperty.call(iteratee, index)) { - if (callback(iteratee[index], index, collection) === indicatorObject) return result; + while (++index < length) { + if (callback(collection[index], index, collection) === indicatorObject) { + break; } - } - } - - }; + } + } else { + each(collection, callback, thisArg); + }; + } /** * Creates an object composed of keys returned from running each element of @@ -1816,7 +1850,7 @@ result[index] = callback(collection[index], index, collection); } } else { - forEach(collection, function(value, key, collection) { + each(collection, function(value, key, collection) { result[++index] = callback(value, key, collection); }); } @@ -1856,7 +1890,7 @@ if (callback || !isArray(collection)) { callback = createCallback(callback, thisArg); - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { var current = callback(value, index, collection); if (current > computed) { computed = current; @@ -1900,7 +1934,7 @@ if (callback || !isArray(collection)) { callback = createCallback(callback, thisArg); - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { var current = callback(value, index, collection); if (current < computed) { computed = current; @@ -1977,7 +2011,7 @@ accumulator = callback(accumulator, collection[index], index, collection); } } else { - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { accumulator = noaccum ? (noaccum = false, value) : callback(accumulator, value, index, collection) @@ -2132,7 +2166,7 @@ } } } else { - forEach(collection, function(value, index, collection) { + each(collection, function(value, index, collection) { return (result = callback(value, index, collection)) && indicatorObject; }); } @@ -3633,7 +3667,7 @@ * // => '1,2,3' */ function wrapperToString() { - return String(this.__wrapped__); + return this.__wrapped__ + ''; } /** @@ -3794,7 +3828,7 @@ lodash.prototype.value = wrapperValueOf; // add `Array` mutator functions to the wrapper - forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { var value = this.__wrapped__; @@ -3810,7 +3844,7 @@ }); // add `Array` accessor functions to the wrapper - forEach(['concat', 'join', 'slice'], function(methodName) { + each(['concat', 'join', 'slice'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { var value = this.__wrapped__, diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 7874b93754..01833b1e0e 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -4,30 +4,30 @@ Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(e,t){function n(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||"undefined"==typeof e)return 1;if(en?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function L(e,t){return C(e,t+"")}function A(e,t,n,r){var i=3>arguments.length,t=s(t,r,!0);if(kt(e)){var o=-1,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if("number"!=typeof i)var u=Lt(e),i=u.length;return t=s(t,r,!0),At(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function M(e,t,n){var r,t=s(t,n);if(kt(e))for(var n=-1,i=e.length;++nn?ft(0,i+n):n||0)-1;else if(n)return r=B(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])P(a,f))n&&a.push(f),u.push(r)}return u}function F(e,t){return bt||it&&2"']/g,G=/['\n\r\t\u2028\u2029\\]/g,Y=Math.ceil,Z=z.concat,et=Math.floor,tt=U.hasOwnProperty,nt=z.push,rt=U.toString,it=J.test(it=f.bind)&&it,st=J.test(st=Array.isArray)&&st,ot=e.isFinite,ut=e.isNaN,at=J.test(at=Object.keys)&&at,ft=Math.max,lt=Math.min,ct=Math.random,ht="[object Array]",pt="[object Boolean]" -,dt="[object Date]",vt="[object Number]",mt="[object Object]",gt="[object RegExp]",yt="[object String]",U=!!e.attachEvent,U=it&&!/\n|true/.test(it+U),bt=it&&!U,wt=(wt={0:1,length:1},z.splice.call(wt,0,1),wt[0]),Et={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},St={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},n.isArguments= -function(e){return"[object Arguments]"==rt.call(e)},n.isArguments(arguments)||(n.isArguments=function(e){return e?tt.call(e,"callee"):!1});var xt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(t(e[n],n,e)===X)break;return e},Tt=function(e,t){var n;if(!e)return e;t||(t=I);for(n in e)if(tt.call(e,n)&&t(e[n],n,e)===X)break;return e},Nt={"&":"&","<":"<",">":">",'"':""","'":"'"},Ct=v(Nt),kt=st||function(e){return e instanceof Array||rt.call(e)==ht};g(/x/)&&(g=function(e) -{return e instanceof Function||"[object Function]"==rt.call(e)});var Lt=at?function(e){return y(e)?at(e):[]}:h,At=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++ne?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=F,n.bindAll=function(e){for(var t=arguments,n=1P(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=D,n.forEach=At,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return At(e,function( -e,n,i){n=t(e,n,i),(tt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,lt(ft(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=[];return At(e,function(e){if(0>P(r,e)){for(var i=n;--i;)if(0>P(t[i],e))return;r.push(e)}}),r},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return At(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Lt,n.map=C,n.max=k,n.memoize=function( -e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!kt(e))t=s(t,n),At(e,function(e,n,i){n=t(e,n,i),nP(t -,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Tt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=Z.apply(z,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rP(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return nt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?k(L(arguments,"length")):0,r=Array(n);++tn?ft(0,r+n):lt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=q,n.noConflict=function(){return e._=V,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+et(ct()*((+t||0)-e+1))} -,n.reduce=A,n.reduceRight=O,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Lt(e).length},n.some=M,n.sortedIndex=B,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||K).source+"|"+(r.interpolate||K).source+"|"+(r.evaluate||K).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(G,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+ -r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace($,l)},n.uniqueId=function(e){var t=++W+"";return e?e+t:t},n.all=x,n.any=M,n.detect=N,n.foldl=A,n.foldr=O,n.include=S,n.inject=A,n.first= -_,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,ft(0,r-t))}},n.take=_,n.head=_,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.2",q(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},At("pop push reverse shift sort splice unshift".split(" "),function(e){var t=z[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),wt&&e.length===0&&delete e[0],this}}), -At(["concat","join","slice"],function(e){var t=z[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),R?"object"==typeof module&&module&&module.exports==R?(module.exports=n)._=n:R._=n:e._=n})(this); \ No newline at end of file +(e,t,n){return e?"function"!=typeof e?function(t){return t[e]}:"undefined"!=typeof t?n?function(n,r,i,s){return e.call(t,n,r,i,s)}:function(n,r,i){return e.call(t,n,r,i)}:e:q}function o(e){return"\\"+xt[e]}function u(e){return kt[e]}function a(){}function f(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,!0);if(At(e) +){var o=-1,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if("number"!=typeof i)var u=Ot(e),i=u.length;return t=s(t,r,!0),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(At(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st=f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite +,at=e.isNaN,ft=K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},xt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings= +{escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Tt=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++n":">",'"':""","'":"'"},Lt=v(kt),At=ot||function(e){return e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Ot=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply +(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i} +,n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=[];return C(e,function(e){if(0>H(r,e)){for(var i=n;--i;)if(0>H(t[i],e))return;r.push(e)}}),r},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof +t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Ot,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!At(e))t=s(t,n),Tt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Ct(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random= +function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Ot(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function( +t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++ +X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.2",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Tt("pop push reverse shift sort splice unshift".split(" "),function(e){var t=W[e];n.prototype[e]=function( +){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Tt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?"object"==typeof module&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file diff --git a/vendor/backbone/backbone.js b/vendor/backbone/backbone.js index 105f2fc76b..df82a11fbf 100644 --- a/vendor/backbone/backbone.js +++ b/vendor/backbone/backbone.js @@ -1,4 +1,4 @@ -// Backbone.js 0.9.2 +// Backbone.js 0.9.9-pre // (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. // Backbone may be freely distributed under the MIT license. @@ -34,7 +34,7 @@ } // Current version of the library. Keep in sync with `package.json`. - Backbone.VERSION = '0.9.2'; + Backbone.VERSION = '0.9.9-pre'; // Require Underscore, if we're on the server, and it's not already present. var _ = root._; @@ -67,6 +67,9 @@ // Regular expression used to split event strings var eventSplitter = /\s+/; + // Internal flag used to set event callbacks `once`. + var once = false; + // A module that can be mixed in to *any object* in order to provide it with // custom events. You may bind with `on` or remove with `off` callback functions // to an event; `trigger`-ing an event fires all callbacks in succession. @@ -81,6 +84,13 @@ // Bind one or more space separated events, `events`, to a `callback` // function. Passing `"all"` will bind the callback to all events fired. on: function(events, callback, context) { + if (_.isObject(events)) { + for (var key in events) { + this.on(key, events[key], callback); + } + return this; + } + var calls, event, list; if (!callback) return this; @@ -89,16 +99,32 @@ while (event = events.shift()) { list = calls[event] || (calls[event] = []); - list.push(callback, context); + list.push(callback, context, once ? {} : null); } return this; }, + // Bind events to only be triggered a single time. After the first time + // the callback is invoked, it will be removed. + once: function(events, callback, context) { + once = true; + this.on(events, callback, context); + once = false; + return this; + }, + // Remove one or many callbacks. If `context` is null, removes all callbacks // with that function. If `callback` is null, removes all callbacks for the // event. If `events` is null, removes all bound callbacks for all events. off: function(events, callback, context) { + if (_.isObject(events)) { + for (var key in events) { + this.off(key, events[key], callback); + } + return this; + } + var event, calls, list, i; // No events, or removing *all* events. @@ -117,9 +143,9 @@ continue; } - for (i = list.length - 2; i >= 0; i -= 2) { + for (i = list.length - 3; i >= 0; i -= 3) { if (!(callback && list[i] !== callback || context && list[i + 1] !== context)) { - list.splice(i, 2); + list.splice(i, 3); } } } @@ -132,7 +158,7 @@ // (unless you're listening on `"all"`, which will cause your callback to // receive the true name of the event as the first argument). trigger: function(events) { - var event, calls, list, i, length, args, all, rest; + var event, calls, list, i, length, args, all, rest, callback, context, onced; if (!(calls = this._callbacks)) return this; rest = []; @@ -153,15 +179,18 @@ // Execute event callbacks. if (list) { - for (i = 0, length = list.length; i < length; i += 2) { - list[i].apply(list[i + 1] || this, rest); + for (i = 0, length = list.length; i < length; i += 3) { + callback = list[i], context = list[i + 1], onced = list[i + 2]; + if (onced) calls[event].splice(i, 3); + if (!onced || !onced.dead) callback.apply(context || this, rest); + if (onced) onced.dead = true; } } // Execute "all" callbacks. if (all) { args = [event].concat(rest); - for (i = 0, length = all.length; i < length; i += 2) { + for (i = 0, length = all.length; i < length; i += 3) { all[i].apply(all[i + 1] || this, args); } } @@ -176,6 +205,10 @@ Events.bind = Events.on; Events.unbind = Events.off; + // Allow the `Backbone` object to serve as a global event bus, for folks who + // want global "pubsub" in a convenient place. + _.extend(Backbone, Events); + // Backbone.Model // -------------- @@ -390,7 +423,9 @@ }; // Finish configuring and sending the Ajax request. - var xhr = this.sync(this.isNew() ? 'create' : 'update', this, options); + var method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); + if (method == 'patch') options.attrs = attrs; + var xhr = this.sync(method, this, options); // When using `wait`, reset attributes to original values unless // `success` has been called already. @@ -565,7 +600,7 @@ // returning `true` if all is well. If a specific `error` callback has // been passed, call that instead of firing the general `"error"` event. _validate: function(attrs, options) { - if (options && options.silent || !this.validate) return true; + if (!this.validate) return true; attrs = _.extend({}, this.attributes, attrs); var error = this.validate(attrs, options); if (!error) return true; @@ -588,10 +623,7 @@ if (options.comparator !== void 0) this.comparator = options.comparator; this._reset(); this.initialize.apply(this, arguments); - if (models) { - if (options.parse) models = this.parse(models); - this.reset(models, {silent: true, parse: options.parse}); - } + if (models) this.reset(models, _.extend({silent: true}, options)); }; // Define the Collection's inheritable methods. @@ -679,7 +711,7 @@ options || (options = {}); models = _.isArray(models) ? models.slice() : [models]; for (i = 0, l = models.length; i < l; i++) { - model = this.getByCid(models[i]) || this.get(models[i]); + model = this.get(models[i]); if (!model) continue; delete this._byId[model.id]; delete this._byCid[model.cid]; @@ -729,14 +761,9 @@ }, // Get a model from the set by id. - get: function(id) { - if (id == null) return void 0; - return this._byId[id.id != null ? id.id : id]; - }, - - // Get a model from the set by client id. - getByCid: function(cid) { - return cid && this._byCid[cid.cid || cid]; + get: function(obj) { + if (obj == null) return void 0; + return this._byId[obj.id != null ? obj.id : obj] || this._byCid[obj.cid || obj]; }, // Get the model at the given index. @@ -769,7 +796,7 @@ this.models.sort(_.bind(this.comparator, this)); } - if (!options || !options.silent) this.trigger('reset', this, options); + if (!options || !options.silent) this.trigger('sort', this, options); return this; }, @@ -778,16 +805,46 @@ return _.invoke(this.models, 'get', attr); }, + // Smartly update a collection with a change set of models, adding, + // removing, and merging as necessary. + update: function(models, options) { + var model, i, l, id, cid, existing; + var add = [], remove = []; + options = _.extend({add: true, merge: true, remove: false}, options); + + // Determine which models to add and merge, and which to remove. + for (i = 0, l = models.length; i < l; i++) { + model = models[i]; + existing = this.get(model); + if (options.add || options.merge && existing) add.push(model); + } + if (options.remove) { + var changeset = new Collection(models); + for (i = 0, l = this.models.length; i < l; i++) { + model = this.models[i]; + if (!changeset.get(model)) remove.push(model); + } + } + + // Remove models (if applicable) before we add and merge the rest. + if (remove.length) this.remove(remove, options); + if (add.length) this.add(add, options); + return this; + }, + // When you have more items than you want to add or remove individually, // you can reset the entire set with a new list of models, without firing // any `add` or `remove` events. Fires `reset` when finished. reset: function(models, options) { + options || (options = {}); + if (options.parse) models = this.parse(models); for (var i = 0, l = this.models.length; i < l; i++) { this._removeReference(this.models[i]); } + options.previousModels = this.models; this._reset(); if (models) this.add(models, _.extend({silent: true}, options)); - if (!options || !options.silent) this.trigger('reset', this, options); + if (!options.silent) this.trigger('reset', this, options); return this; }, @@ -800,7 +857,8 @@ var collection = this; var success = options.success; options.success = function(resp, status, xhr) { - collection[options.add ? 'add' : 'reset'](collection.parse(resp, xhr), options); + var method = options.update ? 'update' : 'reset'; + collection[method](collection.parse(resp, xhr), options); if (success) success(collection, resp, options); }; return this.sync('read', this, options); @@ -859,7 +917,7 @@ options || (options = {}); options.collection = this; var model = new this.model(attrs, options); - if (!model._validate(model.attributes, options)) return false; + if (!model._validate(attrs, options)) return false; return model; }, @@ -932,7 +990,7 @@ var optionalParam = /\((.*?)\)/g; var namedParam = /:\w+/g; var splatParam = /\*\w+/g; - var escapeRegExp = /[-{}[\]+?.,\\^$|#\s]/g; + var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; // Set up all inheritable **Backbone.Router** properties and methods. _.extend(Router.prototype, Events, { @@ -1051,7 +1109,7 @@ fragment = this.getHash(); } } - return decodeURIComponent(fragment.replace(routeStripper, '')); + return fragment.replace(routeStripper, ''); }, // Start the hash change handling, returning `true` if the current URL matches @@ -1364,6 +1422,7 @@ var methodMap = { 'create': 'POST', 'update': 'PUT', + 'patch': 'PATCH', 'delete': 'DELETE', 'read': 'GET' }; @@ -1401,9 +1460,9 @@ } // Ensure that we have the appropriate request data. - if (!options.data && model && (method === 'create' || method === 'update')) { + if (options.data == null && model && (method === 'create' || method === 'update')) { params.contentType = 'application/json'; - params.data = JSON.stringify(model.toJSON(options)); + params.data = JSON.stringify(options.attrs || model.toJSON(options)); } // For older servers, emulate JSON by encoding the request into an HTML-form. @@ -1442,7 +1501,9 @@ }; // Make the request, allowing the user to override any Ajax options. - return Backbone.ajax(_.extend(params, options)); + var xhr = Backbone.ajax(_.extend(params, options)); + model.trigger('request', model, xhr, options); + return xhr; }; // Set the default implementation of `Backbone.ajax` to proxy through to `$`. diff --git a/vendor/backbone/test/collection.js b/vendor/backbone/test/collection.js index cabb65ca4c..a9e652e243 100644 --- a/vendor/backbone/test/collection.js +++ b/vendor/backbone/test/collection.js @@ -18,17 +18,21 @@ $(document).ready(function() { })); - test("new and sort", 7, function() { + test("new and sort", 9, function() { + var counter = 0; + col.on('sort', function(){ counter++; }); equal(col.first(), a, "a should be first"); equal(col.last(), d, "d should be last"); col.comparator = function(a, b) { return a.id > b.id ? -1 : 1; }; col.sort(); + equal(counter, 1); equal(col.first(), a, "a should be first"); equal(col.last(), d, "d should be last"); col.comparator = function(model) { return model.id; }; col.sort(); + equal(counter, 2); equal(col.first(), d, "d should be first"); equal(col.last(), a, "a should be last"); equal(col.length, 4); @@ -58,10 +62,10 @@ $(document).ready(function() { strictEqual(collection.last().get('a'), 4); }); - test("get, getByCid", 3, function() { + test("get", 3, function() { equal(col.get(0), d); equal(col.get(2), b); - equal(col.getByCid(col.first().cid), col.first()); + equal(col.get(col.first().cid), col.first()); }); test("get with non-default ids", 2, function() { @@ -304,13 +308,13 @@ $(document).ready(function() { var colE = new Backbone.Collection([e]); var colF = new Backbone.Collection([f]); ok(e != f); - ok(colE.length == 1); - ok(colF.length == 1); + ok(colE.length === 1); + ok(colF.length === 1); colE.remove(e); equal(passed, false); - ok(colE.length == 0); + ok(colE.length === 0); colF.remove(e); - ok(colF.length == 0); + ok(colF.length === 0); equal(passed, true); }); @@ -338,13 +342,13 @@ $(document).ready(function() { }); equal(colE, e.collection); colF.remove(e); - ok(colF.length == 0); - ok(colE.length == 1); + ok(colF.length === 0); + ok(colE.length === 1); equal(counter, 1); equal(colE, e.collection); colE.remove(e); equal(null, e.collection); - ok(colE.length == 0); + ok(colE.length === 0); equal(counter, 2); }); @@ -354,8 +358,8 @@ $(document).ready(function() { var colE = new Backbone.Collection([e]); var colF = new Backbone.Collection([e]); e.destroy(); - ok(colE.length == 0); - ok(colF.length == 0); + ok(colE.length === 0); + ok(colF.length === 0); equal(undefined, e.collection); }); @@ -365,8 +369,8 @@ $(document).ready(function() { var colE = new Backbone.Collection([e]); var colF = new Backbone.Collection([e]); e.destroy(); - ok(colE.length == 0); - ok(colF.length == 0); + ok(colE.length === 0); + ok(colF.length === 0); equal(undefined, e.collection); }); @@ -542,7 +546,7 @@ $(document).ready(function() { equal(col.length, 0); }); - test("#861, adding models to a collection which do not pass validation", 2, function() { + test("#861, adding models to a collection which do not pass validation", function() { var Model = Backbone.Model.extend({ validate: function(attrs) { if (attrs.id == 3) return "id can't be 3"; @@ -567,9 +571,9 @@ $(document).ready(function() { validate: function(attrs){ if (!attrs.valid) return 'invalid'; } }); var model = new collection.model({id: 1, valid: true}); - collection.add([model, {id: 2}]);; + collection.add([model, {id: 2}]); model.trigger('test'); - ok(collection.getByCid(model.cid)); + ok(collection.get(model.cid)); ok(collection.get(1)); ok(!collection.get(2)); equal(collection.length, 1); @@ -726,4 +730,102 @@ $(document).ready(function() { c.add({id: 4}); }); + test("#1407 parse option on constructor parses collection and models", 2, function() { + var model = { + namespace : [{id: 1}, {id:2}] + }; + var Collection = Backbone.Collection.extend({ + model: Backbone.Model.extend({ + parse: function(model) { + model.name = 'test'; + return model; + } + }), + parse: function(model) { + return model.namespace; + } + }); + var c = new Collection(model, {parse:true}); + + equal(c.length, 2); + equal(c.at(0).get('name'), 'test'); + }); + + test("#1407 parse option on reset parses collection and models", 2, function() { + var model = { + namespace : [{id: 1}, {id:2}] + }; + var Collection = Backbone.Collection.extend({ + model: Backbone.Model.extend({ + parse: function(model) { + model.name = 'test'; + return model; + } + }), + parse: function(model) { + return model.namespace; + } + }); + var c = new Collection(); + c.reset(model, {parse:true}); + + equal(c.length, 2); + equal(c.at(0).get('name'), 'test'); + }); + + + test("Reset includes previous models in triggered event.", 1, function() { + var model = new Backbone.Model(); + var collection = new Backbone.Collection([model]) + .on('reset', function(collection, options) { + deepEqual(options.previousModels, [model]); + }); + collection.reset([]); + }); + + test("update", function() { + var m1 = new Backbone.Model(); + var m2 = new Backbone.Model({id: 2}); + var m3 = new Backbone.Model(); + var c = new Backbone.Collection([m1, m2]); + + // Test add/change/remove events + c.on('add', function(model) { + strictEqual(model, m3); + }); + c.on('change', function(model) { + strictEqual(model, m2); + }); + c.on('remove', function(model) { + strictEqual(model, m1); + }); + + // remove: false doesn't remove any models + c.update([], {remove: false}); + strictEqual(c.length, 2); + + // add: false doesn't add any models + c.update([m1, m2, m3], {add: false}); + strictEqual(c.length, 2); + + // merge: false doesn't change any models + c.update([m1, {id: 2, a: 1}], {merge: false, remove: true}); + strictEqual(m2.get('a'), void 0); + + // add: false, remove: false only merges existing models + c.update([m1, {id: 2, a: 0}, m3, {id: 4}], {add: false, remove: false}); + strictEqual(c.length, 2); + strictEqual(m2.get('a'), 0); + + // default options add/remove/merge as appropriate + c.update([{id: 2, a: 1}, m3]); + strictEqual(c.length, 3); + strictEqual(m2.get('a'), 1); + + // Test removing models not passing an argument + c.off('remove'); + c.update([], {remove: true}); + strictEqual(c.length, 0); + }); + }); diff --git a/vendor/backbone/test/events.js b/vendor/backbone/test/events.js index c10a728364..9cb9d8a428 100644 --- a/vendor/backbone/test/events.js +++ b/vendor/backbone/test/events.js @@ -17,7 +17,7 @@ $(document).ready(function() { test("binding and triggering multiple events", 4, function() { var obj = { counter: 0 }; - _.extend(obj,Backbone.Events); + _.extend(obj, Backbone.Events); obj.on('a b c', function() { obj.counter += 1; }); @@ -35,6 +35,38 @@ $(document).ready(function() { equal(obj.counter, 5); }); + test("binding and triggering with event maps", function() { + var obj = { counter: 0 }; + _.extend(obj, Backbone.Events); + + var increment = function() { + this.counter += 1; + }; + + obj.on({ + a: increment, + b: increment, + c: increment + }, obj); + + obj.trigger('a'); + equal(obj.counter, 1); + + obj.trigger('a b'); + equal(obj.counter, 3); + + obj.trigger('c'); + equal(obj.counter, 4); + + obj.off({ + a: increment, + c: increment + }, obj); + obj.trigger('a b c'); + equal(obj.counter, 5); + }); + + test("trigger all for each event", 3, function() { var a, b, obj = { counter: 0 }; _.extend(obj, Backbone.Events); @@ -192,4 +224,90 @@ $(document).ready(function() { obj.trigger('event'); }); + test("once", 2, function() { + // Same as the previous test, but we use once rather than having to explicitly unbind + var obj = { counterA: 0, counterB: 0 }; + _.extend(obj,Backbone.Events); + var incrA = function(){ obj.counterA += 1; obj.trigger('event'); }; + var incrB = function(){ obj.counterB += 1 }; + obj.once('event', incrA); + obj.once('event', incrB); + obj.trigger('event'); + obj.trigger('event'); + obj.trigger('event'); + equal(obj.counterA, 1, 'counterA should have only been incremented once.'); + equal(obj.counterB, 1, 'counterB should have only been incremented once.'); + }); + + test("once variant one", 3, function() { + var f = function(){ ok(true); }; + + var a = _.extend({}, Backbone.Events).once('event', f); + var b = _.extend({}, Backbone.Events).on('event', f); + + a.trigger('event'); + + b.trigger('event'); + b.trigger('event'); + }); + + test("once variant two", 3, function() { + var f = function(){ ok(true); }; + var obj = _.extend({}, Backbone.Events); + + obj + .once('event', f) + .on('event', f) + .trigger('event') + .trigger('event'); + }); + + test("once with off", 0, function() { + var f = function(){ ok(true); }; + var obj = _.extend({}, Backbone.Events); + + obj.once('event', f); + obj.off('event', f); + obj.trigger('event'); + }); + + test("once with event maps", function() { + var obj = { counter: 0 }; + _.extend(obj, Backbone.Events); + + var increment = function() { + this.counter += 1; + }; + + obj.once({ + a: increment, + b: increment, + c: increment + }, obj); + + obj.trigger('a'); + equal(obj.counter, 1); + + obj.trigger('a b'); + equal(obj.counter, 2); + + obj.trigger('c'); + equal(obj.counter, 3); + + obj.trigger('a b c'); + equal(obj.counter, 3); + }); + + test("Backbone object inherits Events", function() { + ok(Backbone.on === Backbone.Events.on); + }); + + asyncTest("once with asynchronous events", 1, function() { + var func = _.debounce(function() { ok(true); start(); }, 50); + var obj = _.extend({}, Backbone.Events).once('async', func); + + obj.trigger('async'); + obj.trigger('async'); + }); + }); diff --git a/vendor/backbone/test/model.js b/vendor/backbone/test/model.js index fd0be2d5b3..cf2f2bb111 100644 --- a/vendor/backbone/test/model.js +++ b/vendor/backbone/test/model.js @@ -270,7 +270,7 @@ $(document).ready(function() { }; } }); - var model = new Defaulted({two: null}); + model = new Defaulted({two: null}); equal(model.get('one'), 3); equal(model.get('two'), null); }); @@ -351,7 +351,7 @@ $(document).ready(function() { equal(lastError, "Can't change admin status."); }); - test("isValid", 5, function() { + test("isValid", function() { var model = new Backbone.Model({valid: true}); model.validate = function(attrs) { if (!attrs.valid) return "invalid"; @@ -359,8 +359,7 @@ $(document).ready(function() { equal(model.isValid(), true); equal(model.set({valid: false}), false); equal(model.isValid(), true); - ok(model.set('valid', false, {silent: true})); - equal(model.isValid(), false); + ok(!model.set('valid', false, {silent: true})); }); test("save", 2, function() { @@ -369,6 +368,19 @@ $(document).ready(function() { ok(_.isEqual(this.syncArgs.model, doc)); }); + test("save with PATCH", function() { + doc.clear().set({id: 1, a: 1, b: 2, c: 3, d: 4}); + doc.save(); + equal(this.syncArgs.method, 'update'); + equal(this.syncArgs.options.attrs, undefined); + + doc.save({b: 2, d: 4}, {patch: true}); + equal(this.syncArgs.method, 'patch'); + equal(_.size(this.syncArgs.options.attrs), 2); + equal(this.syncArgs.options.attrs.d, 4); + equal(this.syncArgs.options.attrs.a, undefined); + }); + test("save in positional style", 1, function() { var model = new Backbone.Model(); model.sync = function(method, model, options) { @@ -402,7 +414,7 @@ $(document).ready(function() { ok(true, "non-persisted model should not call sync"); }); - test("validate", 7, function() { + test("validate", function() { var lastError; var model = new Backbone.Model(); model.validate = function(attrs) { @@ -415,8 +427,6 @@ $(document).ready(function() { equal(result, model); equal(model.get('a'), 100); equal(lastError, undefined); - result = model.set({admin: true}, {silent: true}); - equal(model.get('admin'), true); result = model.set({a: 200, admin: false}); equal(lastError, "Can't change admin status."); equal(result, false); @@ -639,7 +649,7 @@ $(document).ready(function() { equal(model.get('x'), 3); }); - test("save with wait validates attributes", 1, function() { + test("save with wait validates attributes", function() { var model = new Backbone.Model(); model.url = '/test'; model.validate = function() { ok(true); }; diff --git a/vendor/backbone/test/router.js b/vendor/backbone/test/router.js index f9327fcc35..923880abc8 100644 --- a/vendor/backbone/test/router.js +++ b/vendor/backbone/test/router.js @@ -107,7 +107,7 @@ $(document).ready(function() { }, optionalItem: function(arg){ - this.arg = arg !== undefined ? arg : null; + this.arg = arg !== void 0 ? arg : null; }, splat : function(args) { @@ -139,7 +139,7 @@ $(document).ready(function() { location.replace('http://example.com#search/news'); Backbone.history.checkUrl(); equal(router.query, 'news'); - equal(router.page, undefined); + equal(router.page, void 0); equal(lastRoute, 'search'); equal(lastArgs[0], 'news'); }); @@ -265,12 +265,12 @@ $(document).ready(function() { if (!Backbone.history.iframe) ok(true); }); - test("route callback gets passed decoded values", 3, function() { + test("#967 - Route callback gets passed encoded values.", 3, function() { var route = 'has%2Fslash/complex-has%23hash/has%20space'; Backbone.history.navigate(route, {trigger: true}); - equal(router.first, 'has/slash'); - equal(router.part, 'has#hash'); - equal(router.rest, 'has space'); + strictEqual(router.first, 'has%2Fslash'); + strictEqual(router.part, 'has%23hash'); + strictEqual(router.rest, 'has%20space'); }); test("correctly handles URLs with % (#868)", 3, function() { @@ -279,7 +279,7 @@ $(document).ready(function() { location.replace('http://example.com#search/fat'); Backbone.history.checkUrl(); equal(router.query, 'fat'); - equal(router.page, undefined); + equal(router.page, void 0); equal(lastRoute, 'search'); }); diff --git a/vendor/underscore/test/objects.js b/vendor/underscore/test/objects.js index 932f489194..939bffddf6 100644 --- a/vendor/underscore/test/objects.js +++ b/vendor/underscore/test/objects.js @@ -555,4 +555,16 @@ $(document).ready(function() { value(); ok(returned == 6 && intercepted == 6, 'can use tapped objects in a chain'); }); + + test("has", function () { + var obj = {foo: "bar", func: function () {} }; + ok (_.has(obj, "foo"), "has() checks that the object has a property."); + ok (_.has(obj, "baz") == false, "has() returns false if the object doesn't have the property."); + ok (_.has(obj, "func"), "has() works for functions too."); + obj.hasOwnProperty = null; + ok (_.has(obj, "foo"), "has() works even when the hasOwnProperty method is deleted."); + child = {}; + child.prototype = obj; + ok (_.has(child, "foo") == false, "has() does not check the prototype chain for a property.") + }); }); From 1a3c20f91dfefb41336cb1efdddba743ec5be4a9 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 11 Dec 2012 01:10:52 -0800 Subject: [PATCH 21/45] Tweak `_.throttle` unit test pass more consistently. Former-commit-id: 91063b5c6ae0c9beb2c86cc21153d75f060afef1 --- test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index 42da44867d..91a6058a85 100644 --- a/test/test.js +++ b/test/test.js @@ -1818,12 +1818,12 @@ actual = counter + 2; throttled(); throttled(); - }, 64); + }, 128); setTimeout(function() { equal(counter, actual); QUnit.start(); - }, 128); + }, 256); ok(counter > 1); }); From 24fce891559d399f8191943cf9b2b0d20a28d74b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 11 Dec 2012 09:35:51 -0800 Subject: [PATCH 22/45] Remove "Collections" method `_.forEach` dependency from "Arrays" method `_.intersection`. Former-commit-id: 83197c7ac47654c6fc2d2f37df8ff77d4adb9096 --- build.js | 18 ++++++---- doc/README.md | 74 ++++++++++++++++++++-------------------- lodash.js | 16 +++++---- lodash.min.js | 22 ++++++------ lodash.underscore.js | 16 +++++---- lodash.underscore.min.js | 24 ++++++------- 6 files changed, 91 insertions(+), 79 deletions(-) diff --git a/build.js b/build.js index f51ea20997..a787436650 100755 --- a/build.js +++ b/build.js @@ -95,7 +95,7 @@ 'identity': [], 'indexOf': ['sortedIndex'], 'initial': [], - 'intersection': ['forEach', 'indexOf'], + 'intersection': ['indexOf'], 'invert': ['forOwn'], 'invoke': ['forEach'], 'isArguments': [], @@ -1441,19 +1441,23 @@ ' function intersection(array) {', ' var args = arguments,', ' argsLength = args.length,', + ' index = -1,', + ' length = array ? array.length : 0,', ' result = [];', '', - ' forEach(array, function(value) {', + ' outer:', + ' while (++index < length) {', + ' var value = array[index];', ' if (indexOf(result, value) < 0) {', - ' var length = argsLength;', - ' while (--length) {', - ' if (indexOf(args[length], value) < 0) {', - ' return;', + ' var argsIndex = argsLength;', + ' while (--argsIndex) {', + ' if (indexOf(args[argsIndex], value) < 0) {', + ' continue outer;', ' }', ' }', ' result.push(value);', ' }', - ' });', + ' }', ' return result;', ' }' ].join('\n')); diff --git a/doc/README.md b/doc/README.md index 57a520aa0d..46c05b083d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -371,7 +371,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2925 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2929 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -396,7 +396,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2952 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2956 "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. @@ -425,7 +425,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2982 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2986 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -450,7 +450,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3027 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3031 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -488,7 +488,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3066 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3070 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -516,7 +516,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3110 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3114 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -560,7 +560,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3142 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3146 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -584,7 +584,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#L3176 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3180 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -623,7 +623,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3236 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3240 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -648,7 +648,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3267 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3271 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -697,7 +697,7 @@ Creates a `lodash` object, that wraps the given `value`, to enable method chaini ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4136 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4140 "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. @@ -727,7 +727,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4153 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4157 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -748,7 +748,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4170 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4174 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1414,7 +1414,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3300 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3304 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1442,7 +1442,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3333 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3337 "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 passed to the bound function. @@ -1473,7 +1473,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3363 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3367 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1504,7 +1504,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3409 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3413 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. @@ -1545,7 +1545,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3432 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3436 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1572,7 +1572,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3465 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3469 "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. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1598,7 +1598,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3529 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3533 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1623,7 +1623,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3509 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3513 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1650,7 +1650,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3553 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3557 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1676,7 +1676,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3580 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3584 "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. @@ -1702,7 +1702,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3615 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3619 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1729,7 +1729,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3637 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3641 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1754,7 +1754,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3690 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3694 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2667,7 +2667,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3714 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3718 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2691,7 +2691,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3738 "View in source") [Ⓣ][1] This function returns the first argument passed to it. Note: This function is used throughout Lo-Dash as a default callback. @@ -2716,7 +2716,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3760 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3764 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2746,7 +2746,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3786 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3790 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2766,7 +2766,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3809 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3813 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2794,7 +2794,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3847 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3851 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2829,7 +2829,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3932 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3936 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html @@ -2903,7 +2903,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4063 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4067 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -2935,7 +2935,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4089 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4093 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -2959,7 +2959,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4109 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4113 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -2993,7 +2993,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4333 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4337 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 67f451c5a1..ed106ac63d 100644 --- a/lodash.js +++ b/lodash.js @@ -2887,20 +2887,24 @@ function intersection(array) { var args = arguments, argsLength = args.length, + index = -1, + length = array ? array.length : 0, cache = {}, result = []; - forEach(array, function(value) { + outer: + while (++index < length) { + var value = array[index]; if (indexOf(result, value) < 0) { - var length = argsLength; - while (--length) { - if (!(cache[length] || (cache[length] = cachedContains(args[length])))(value)) { - return; + var argsIndex = argsLength; + while (--argsIndex) { + if (!(cache[argsIndex] || (cache[argsIndex] = cachedContains(args[argsIndex])))(value)) { + continue outer; } } result.push(value); } - }); + } return result; } diff --git a/lodash.min.js b/lodash.min.js index 9bdb48db41..8eefacbd67 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -25,17 +25,17 @@ t[0]})(1);var Yt=!y(arguments),Zt="xx"!="x"[0]+Object("x")[0];try{var en=("[obje },vn=x(dn),mn=c(un,{g:"if(t[i]==null)"+un.g}),gn=At||function(e){return e instanceof Array||kt.call(e)==jt};N(/x/)&&(N=function(e){return e instanceof Function||"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!y(e):b(e)}:b,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?w(e):C(e)?_t(e):[]}:w;s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t .apply(this,arguments)}},s.assign=cn,s.bind=J,s.bindAll=function(e){for(var t=arguments,n=1W(i,e)){for(var s=n;--s;)if(!(r[ -s]||(r[s]=o(t[s])))(e))return;i.push(e)}}),i},s.invert=x,s.invoke=function(e,t){var n=m(arguments,2),r="function"==typeof t,i=[];return H(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=A,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&L(e)?u:l(t,n),ln(e,function(e,n,i){n=t(e,n,i), -nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([ -n,e])}),t},s.partial=function(e){return f(e,m(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout -(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I, -s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return N(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,o=s.templateSettings,u=0,a=n.interpolate||o.interpolate||mt,f="__p+='",l=n.variable||o.variable,c=l;e.replace(RegExp((n.escape||o.escape||mt).source+"|"+a.source+"|"+(a===vt?dt:mt).source+"|"+(n.evaluate||o.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,a){return i|| -(i=s),f+=e.slice(u,a).replace(yt,h),n&&(f+="'+__e("+n+")+'"),o&&(f+="';"+o+";__p+='"),i&&(f+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),u=a+t.length,t}),f+="';\n",c||(l="obj",r?f="with("+l+"){"+f+"}":(n=RegExp("(\\(\\s*)"+l+"\\."+l+"\\b","g"),f=f.replace(ht,"$&"+l+".").replace(n,"$1__d"))),f=(r?f.replace(at,""):f).replace(ft,"$1").replace(lt,"$1;"),f="function("+l+"){"+(c?"":l+"||("+l+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" +.apply(et,arguments),r=o(r,n),i=[];++tW(u,a)){for( +var f=n;--f;)if(!(s[f]||(s[f]=o(t[f])))(a))break e;u.push(a)}}return u},s.invert=x,s.invoke=function(e,t){var n=m(arguments,2),r="function"==typeof t,i=[];return H(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=A,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&L(e)?u:l(t,n),ln(e,function( +e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function( +e,n){t.push([n,e])}),t},s.partial=function(e){return f(e,m(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply +(o,i)):u||(u=setTimeout(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht +()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return N(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,o=s.templateSettings,u=0,a=n.interpolate||o.interpolate||mt,f="__p+='",l=n.variable||o.variable,c=l;e.replace(RegExp((n.escape||o.escape||mt).source+"|"+a.source+"|"+(a===vt?dt:mt).source+"|"+(n.evaluate||o.evaluate||mt).source+"|$","g" +),function(t,n,i,s,o,a){return i||(i=s),f+=e.slice(u,a).replace(yt,h),n&&(f+="'+__e("+n+")+'"),o&&(f+="';"+o+";__p+='"),i&&(f+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),u=a+t.length,t}),f+="';\n",c||(l="obj",r?f="with("+l+"){"+f+"}":(n=RegExp("(\\(\\s*)"+l+"\\."+l+"\\b","g"),f=f.replace(ht,"$&"+l+".").replace(n,"$1__d"))),f=(r?f.replace(at,""):f).replace(ft,"$1").replace(lt,"$1;"),f="function("+l+"){"+(c?"":l+"||("+l+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" :(c?"":",__d="+l+"."+l+"||"+l)+";")+f+"return __p}";try{i=Function("_","return "+f)(s)}catch(p){throw p.source=f,p}return t?i(t):(i.source=f,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,g)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=_,s.any=R,s.detect=P,s.foldl=I,s.foldr=q,s.include=M,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i= e.length;return t==r||n?e[i-1]:m(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return this.__wrapped__+""},s.prototype.value=G,s.prototype.valueOf=G,ln(["join","pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),ln(["push","reverse","sort","unshift"],function(e){var t=et[e]; s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),ln(["concat","slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Qt&&ln(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof diff --git a/lodash.underscore.js b/lodash.underscore.js index 1edc4d1d26..c448a776c4 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -2485,19 +2485,23 @@ function intersection(array) { var args = arguments, argsLength = args.length, + index = -1, + length = array ? array.length : 0, result = []; - forEach(array, function(value) { + outer: + while (++index < length) { + var value = array[index]; if (indexOf(result, value) < 0) { - var length = argsLength; - while (--length) { - if (indexOf(args[length], value) < 0) { - return; + var argsIndex = argsLength; + while (--argsIndex) { + if (indexOf(args[argsIndex], value) < 0) { + continue outer; } } result.push(value); } - }); + } return result; } diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 01833b1e0e..768268b5ab 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -19,15 +19,15 @@ e.__chain__=!0),e}})}var U="object"==typeof exports&&exports,z="object"==typeof ;t||(t=q);for(n in e)if(t(e[n],n,e)===V)break;return e},Ct=function(e,t){var n;if(!e)return e;t||(t=q);for(n in e)if(nt.call(e,n)&&t(e[n],n,e)===V)break;return e},kt={"&":"&","<":"<",">":">",'"':""","'":"'"},Lt=v(kt),At=ot||function(e){return e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Ot=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply (this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i} -,n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=[];return C(e,function(e){if(0>H(r,e)){for(var i=n;--i;)if(0>H(t[i],e))return;r.push(e)}}),r},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof -t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Ot,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!At(e))t=s(t,n),Tt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Ct(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random= -function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Ot(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function( -t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++ -X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.2",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Tt("pop push reverse shift sort splice unshift".split(" "),function(e){var t=W[e];n.prototype[e]=function( -){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Tt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?"object"==typeof module&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file +,n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))break e;s.push(o)}}return s},n.invert=v,n.invoke=function(e,t){var n=f(arguments +,2),r="function"==typeof t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Ot,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!At(e))t=s(t,n),Tt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Ct(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e +._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Ot(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$" +,"g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace(J,l)},n.uniqueId= +function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.2",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Tt("pop push reverse shift sort splice unshift".split(" "),function(e){var t=W +[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Tt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?"object"==typeof module&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file From 0ba05e4de0c9797445e9ebf5afbb04c2360557e1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 12 Dec 2012 00:37:56 -0800 Subject: [PATCH 23/45] Add `@license` to minified copyright header to preserve it in case of double minification. [closes #138] Former-commit-id: 6c9b72f9c807daac613ff2d4339c0e3c4e7cafe3 --- build.js | 5 +++-- build/post-compile.js | 7 ++++--- lodash.min.js | 21 +++++++++++---------- lodash.underscore.min.js | 13 +++++++------ test/test-build.js | 9 +++++++++ 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/build.js b/build.js index a787436650..fb5c26441c 100755 --- a/build.js +++ b/build.js @@ -415,7 +415,7 @@ * @returns {String} Returns the modified source. */ function addCommandsToHeader(source, commands) { - return source.replace(/(\/\*!\n)( \*)?( *Lo-Dash [\w.-]+)(.*)/, function() { + return source.replace(/(\/\*!\n)( \*)?( *@license[\s*]+)?( *Lo-Dash [\w.-]+)(.*)/, function() { // convert unmatched groups to empty strings var parts = _.map(slice.call(arguments, 1), function(part) { return part || ''; @@ -436,7 +436,8 @@ }); // add build commands to copyright/license header return ( - parts[0] + parts[1] + parts[2] + ' (Custom Build)' + parts[3] + '\n' + + parts[0] + parts[1] + parts[2] + parts[3] + + ' (Custom Build)' + parts[4] + '\n' + parts[1] + ' Build: `lodash ' + commands.join(' ') + '`' ); }); diff --git a/build/post-compile.js b/build/post-compile.js index 4d7ba68b8d..ac242eab2e 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -9,11 +9,12 @@ var licenseTemplate = { 'lodash': '/*!\n' + - ' Lo-Dash @VERSION lodash.com/license\n' + + ' @license\n' + + ' Lo-Dash <%= VERSION %> lodash.com/license\n' + ' Underscore.js 1.4.3 underscorejs.org/LICENSE\n' + '*/', 'underscore': - '/*! Underscore.js @VERSION underscorejs.org/LICENSE */' + '/*! @license Underscore.js <%= VERSION %> underscorejs.org/LICENSE */' }; /*--------------------------------------------------------------------------*/ @@ -51,7 +52,7 @@ } // add copyright/license header return licenseTemplate[/call\(this\);?$/.test(source) ? 'underscore' : 'lodash'] - .replace('@VERSION', snippet[2]) + '\n;' + source; + .replace('<%= VERSION %>', snippet[2]) + '\n;' + source; } /*--------------------------------------------------------------------------*/ diff --git a/lodash.min.js b/lodash.min.js index 8eefacbd67..f22800ecae 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,4 +1,5 @@ /*! + @license Lo-Dash 1.0.0-rc.2 lodash.com/license Underscore.js 1.4.3 underscorejs.org/LICENSE */ @@ -26,16 +27,16 @@ t[0]})(1);var Yt=!y(arguments),Zt="xx"!="x"[0]+Object("x")[0];try{var en=("[obje .apply(this,arguments)}},s.assign=cn,s.bind=J,s.bindAll=function(e){for(var t=arguments,n=1W(u,a)){for( -var f=n;--f;)if(!(s[f]||(s[f]=o(t[f])))(a))break e;u.push(a)}}return u},s.invert=x,s.invoke=function(e,t){var n=m(arguments,2),r="function"==typeof t,i=[];return H(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=A,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&L(e)?u:l(t,n),ln(e,function( -e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function( -e,n){t.push([n,e])}),t},s.partial=function(e){return f(e,m(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply -(o,i)):u||(u=setTimeout(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht -()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return N(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,o=s.templateSettings,u=0,a=n.interpolate||o.interpolate||mt,f="__p+='",l=n.variable||o.variable,c=l;e.replace(RegExp((n.escape||o.escape||mt).source+"|"+a.source+"|"+(a===vt?dt:mt).source+"|"+(n.evaluate||o.evaluate||mt).source+"|$","g" -),function(t,n,i,s,o,a){return i||(i=s),f+=e.slice(u,a).replace(yt,h),n&&(f+="'+__e("+n+")+'"),o&&(f+="';"+o+";__p+='"),i&&(f+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),u=a+t.length,t}),f+="';\n",c||(l="obj",r?f="with("+l+"){"+f+"}":(n=RegExp("(\\(\\s*)"+l+"\\."+l+"\\b","g"),f=f.replace(ht,"$&"+l+".").replace(n,"$1__d"))),f=(r?f.replace(at,""):f).replace(ft,"$1").replace(lt,"$1;"),f="function("+l+"){"+(c?"":l+"||("+l+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" +var f=n;--f;)if(!(s[f]||(s[f]=o(t[f])))(a))continue e;u.push(a)}}return u},s.invert=x,s.invoke=function(e,t){var n=m(arguments,2),r="function"==typeof t,i=[];return H(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=A,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&L(e)?u:l(t,n),ln( +e,function(e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn +(e,function(e,n){t.push([n,e])}),t},s.partial=function(e){return f(e,m(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r +,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0 +),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return N(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,o=s.templateSettings,u=0,a=n.interpolate||o.interpolate||mt,f="__p+='",l=n.variable||o.variable,c=l;e.replace(RegExp((n.escape||o.escape||mt).source+"|"+a.source+"|"+(a===vt?dt:mt).source+"|"+(n.evaluate||o.evaluate||mt).source+"|$" +,"g"),function(t,n,i,s,o,a){return i||(i=s),f+=e.slice(u,a).replace(yt,h),n&&(f+="'+__e("+n+")+'"),o&&(f+="';"+o+";__p+='"),i&&(f+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),u=a+t.length,t}),f+="';\n",c||(l="obj",r?f="with("+l+"){"+f+"}":(n=RegExp("(\\(\\s*)"+l+"\\."+l+"\\b","g"),f=f.replace(ht,"$&"+l+".").replace(n,"$1__d"))),f=(r?f.replace(at,""):f).replace(ft,"$1").replace(lt,"$1;"),f="function("+l+"){"+(c?"":l+"||("+l+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" :(c?"":",__d="+l+"."+l+"||"+l)+";")+f+"return __p}";try{i=Function("_","return "+f)(s)}catch(p){throw p.source=f,p}return t?i(t):(i.source=f,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,g)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=_,s.any=R,s.detect=P,s.foldl=I,s.foldr=q,s.include=M,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i= e.length;return t==r||n?e[i-1]:m(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return this.__wrapped__+""},s.prototype.value=G,s.prototype.valueOf=G,ln(["join","pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),ln(["push","reverse","sort","unshift"],function(e){var t=et[e]; s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),ln(["concat","slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Qt&&ln(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 768268b5ab..cc82ef03ee 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -1,4 +1,5 @@ /*! + @license Lo-Dash 1.0.0-rc.2 (Custom Build) lodash.com/license Build: `lodash underscore -m -o ./lodash.underscore.min.js` Underscore.js 1.4.3 underscorejs.org/LICENSE @@ -19,12 +20,12 @@ e.__chain__=!0),e}})}var U="object"==typeof exports&&exports,z="object"==typeof ;t||(t=q);for(n in e)if(t(e[n],n,e)===V)break;return e},Ct=function(e,t){var n;if(!e)return e;t||(t=q);for(n in e)if(nt.call(e,n)&&t(e[n],n,e)===V)break;return e},kt={"&":"&","<":"<",">":">",'"':""","'":"'"},Lt=v(kt),At=ot||function(e){return e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Ot=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply (this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i} -,n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))break e;s.push(o)}}return s},n.invert=v,n.invoke=function(e,t){var n=f(arguments -,2),r="function"==typeof t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Ot,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!At(e))t=s(t,n),Tt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Ct(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))continue e;s.push(o)}}return s},n.invert=v,n.invoke=function(e,t){var n=f +(arguments,2),r="function"==typeof t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Ot,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!At(e))t=s(t,n),Tt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Ct(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e ._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Ot(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$" diff --git a/test/test-build.js b/test/test-build.js index ea9c83cd60..796cefa6b6 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -560,6 +560,9 @@ QUnit.module('independent builds'); (function() { + var reComment = /\/\*![\s\S]+?\*\//, + reCustom = /Custom Build/; + asyncTest('debug only', function() { var start = _.once(QUnit.start); build(['-d', '-s'], function(source, filePath) { @@ -572,6 +575,9 @@ var start = _.once(QUnit.start); build(['-d', '-s', 'backbone'], function(source, filePath) { equal(path.basename(filePath, '.js'), 'lodash.custom'); + + var comment = source.match(reComment); + ok(reCustom.test(comment)); start(); }); }); @@ -588,6 +594,9 @@ var start = _.once(QUnit.start); build(['-m', '-s', 'backbone'], function(source, filePath) { equal(path.basename(filePath, '.js'), 'lodash.custom.min'); + + var comment = source.match(reComment); + ok(reCustom.test(comment)); start(); }); }); From 4def1ea1dc09f0a69e325133e87a03ade0f99a23 Mon Sep 17 00:00:00 2001 From: Kit Cambridge Date: Thu, 13 Dec 2012 10:31:33 -0800 Subject: [PATCH 24/45] Fix installation mode detection on Windows. Closes #139. The global `node_modules` directory does not exist if no modules have been installed globally, causing `realpathSync` to throw an exception. Former-commit-id: 5a59e6b53c7afe5d5c5728352e9cd722744b2247 --- build/post-install.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build/post-install.js b/build/post-install.js index 9656f5af47..244c5e309a 100644 --- a/build/post-install.js +++ b/build/post-install.js @@ -25,6 +25,9 @@ /** The media type for raw blob data */ var mediaType = 'application/vnd.github.v3.raw'; + /** Reassign `existsSync` for older versions of Node */ + fs.existsSync || (fs.existsSync = path.existsSync); + /** Used to reference parts of the blob href */ var location = (function() { var host = 'api.github.com', @@ -101,7 +104,8 @@ exec('npm -g root', function(exception, stdout) { if (!exception) { try { - var isGlobal = path.resolve(basePath, '..') == fs.realpathSync(stdout.trim()); + var root = stdout.trim(), + isGlobal = fs.existsSync(root) && path.resolve(basePath, '..') == fs.realpathSync(root); } catch(e) { exception = e; } From c56bb56708c9dc4fbcbadd32b8c2c67a9ba637da Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 12 Dec 2012 23:24:13 -0800 Subject: [PATCH 25/45] Cleanup benchmarks. Former-commit-id: 805c0091cd6cec85729ee7511005c233545a9899 --- build.js | 4 +- lodash.js | 2 +- perf/perf.js | 222 +++++++++++++++++---------------------------------- 3 files changed, 78 insertions(+), 150 deletions(-) diff --git a/build.js b/build.js index fb5c26441c..7962cc5be9 100755 --- a/build.js +++ b/build.js @@ -436,8 +436,8 @@ }); // add build commands to copyright/license header return ( - parts[0] + parts[1] + parts[2] + parts[3] + - ' (Custom Build)' + parts[4] + '\n' + + parts[0] + + parts[1] + parts[2] + parts[3] + ' (Custom Build)' + parts[4] + '\n' + parts[1] + ' Build: `lodash ' + commands.join(' ') + '`' ); }); diff --git a/lodash.js b/lodash.js index ed106ac63d..eb0dc4e94e 100644 --- a/lodash.js +++ b/lodash.js @@ -3190,7 +3190,7 @@ isSorted = false; } // init value cache for large arrays - var isLarge = !isSorted && length > 74; + var isLarge = !isSorted && length >= 75; if (isLarge) { var cache = {}; } diff --git a/perf/perf.js b/perf/perf.js index a53ea27a99..d8dda55b30 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -297,41 +297,77 @@ nestedNumbers2 = [1, [2], [3, [[4]]]];\ \ for (index = 0; index < limit; index++) {\ - numbers2[index] = index;\ object2["key" + index] = index;\ objects2[index] = { "num": index };\ + numbers2[index] = index;\ }\ }\ \ if (typeof multiArrays != "undefined") {\ - var twentyFiveValues = Array(25),\ + var twentyValues = Array(20),\ + twentyValues2 = Array(20),\ + twentyFiveValues = Array(25),\ twentyFiveValues2 = Array(25),\ + thirtyValues = Array(30),\ + thirtyValues2 = Array(30),\ + fortyValues = Array(40),\ + fortyValues2 = Array(40),\ fiftyValues = Array(50),\ + fiftyValues2 = Array(50),\ seventyFiveValues = Array(75),\ seventyFiveValues2 = Array(75),\ + hundredValues = Array(100),\ + hundredValues2 = Array(100),\ lowerChars = "abcdefghijklmnopqrstuvwxyz".split(""),\ upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");\ \ - for (index = 0; index < 75; index++) {\ - if (index < 26) {\ - if (index < 20) {\ - twentyFiveValues[index] = lowerChars[index];\ - twentyFiveValues2[index] = upperChars[index];\ - }\ - else if (index < 25) {\ - twentyFiveValues[index] =\ - twentyFiveValues2[index] = index;\ - }\ + for (index = 0; index < 100; index++) {\ + if (index < 15) {\ + twentyValues[index] = lowerChars[index];\ + twentyValues2[index] = upperChars[index];\ + }\ + if (index < 20) {\ + twentyValues[index] =\ + twentyValues2[index] = index;\ + \ + twentyFiveValues[index] = lowerChars[index];\ + twentyFiveValues2[index] = upperChars[index];\ + }\ + if (index < 25) {\ + twentyFiveValues[index] =\ + twentyFiveValues2[index] = index;\ + \ + thirtyValues[index] =\ + fortyValues[index] =\ fiftyValues[index] =\ - seventyFiveValues[index] = lowerChars[index];\ - seventyFiveValues2[index] = upperChars[index];\ + seventyFiveValues[index] =\ + hundredValues[index] = lowerChars[index];\ + \ + thirtyValues2[index] =\ + fortyValues2[index] =\ + fiftyValues2[index] =\ + seventyFiveValues2[index] =\ + hundredValues2[index] = upperChars[index];\ }\ else {\ + if (index < 30) {\ + thirtyValues[index] =\ + thirtyValues2[index] = index;\ + }\ + if (index < 40) {\ + fortyValues[index] =\ + fortyValues2[index] = index;\ + }\ if (index < 50) {\ - fiftyValues[index] = index;\ + fiftyValues[index] =\ + fiftyValues2[index] = index;\ + }\ + if (index < 75) {\ + seventyFiveValues[index] =\ + seventyFiveValues2[index] = index;\ }\ - seventyFiveValues[index] = index;\ - seventyFiveValues2[index] = index + (index < 60 ? 75 : 0);\ + hundredValues[index] =\ + hundredValues2[index] = index;\ }\ }\ }\ @@ -630,45 +666,33 @@ suites.push( Benchmark.Suite('`_.difference`') .add(buildName, '\ - lodash.difference(numbers, fourNumbers, twoNumbers)' + lodash.difference(numbers, twoNumbers, fourNumbers)' ) .add(otherName, '\ - _.difference(numbers, fourNumbers, twoNumbers)' + _.difference(numbers, twoNumbers, fourNumbers)' ) ); suites.push( - Benchmark.Suite('`_.difference` iterating 25 elements') + Benchmark.Suite('`_.difference` iterating 30 elements') .add(buildName, { - 'fn': 'lodash.difference(twentyFiveValues, twentyFiveValues2)', + 'fn': 'lodash.difference(thirtyValues, thirtyValues2)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { - 'fn': '_.difference(twentyFiveValues, twentyFiveValues2)', + 'fn': '_.difference(thirtyValues, thirtyValues2)', 'teardown': 'function multiArrays(){}' }) ); suites.push( - Benchmark.Suite('`_.difference` iterating 50 and 75 elements') + Benchmark.Suite('`_.difference` iterating 20 and 40 elements') .add(buildName, { - 'fn': 'lodash.difference(fiftyValues, seventyFiveValues2)', + 'fn': 'lodash.difference(twentyValues, fortyValues2)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { - 'fn': '_.difference(fiftyValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.difference` iterating 75 elements') - .add(buildName, { - 'fn': 'lodash.difference(seventyFiveValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.difference(seventyFiveValues, seventyFiveValues2)', + 'fn': '_.difference(twentyValues, fortyValues2)', 'teardown': 'function multiArrays(){}' }) ); @@ -936,45 +960,21 @@ suites.push( Benchmark.Suite('`_.intersection`') .add(buildName, '\ - lodash.intersection(numbers, fourNumbers, twoNumbers)' + lodash.intersection(numbers, twoNumbers, fourNumbers)' ) .add(otherName, '\ - _.intersection(numbers, fourNumbers, twoNumbers)' + _.intersection(numbers, twoNumbers, fourNumbers)' ) ); suites.push( - Benchmark.Suite('`_.intersection` iterating 25 elements') + Benchmark.Suite('`_.intersection` iterating 100 elements') .add(buildName, { - 'fn': 'lodash.intersection(twentyFiveValues, twentyFiveValues2)', + 'fn': 'lodash.intersection(hundredValues, hundredValues2)', 'teardown': 'function multiArrays(){}' }) .add(otherName, { - 'fn': '_.intersection(twentyFiveValues, twentyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.intersection` iterating 50 and 75 elements') - .add(buildName, { - 'fn': 'lodash.intersection(fiftyValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.intersection(fiftyValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.intersection` iterating 75 elements') - .add(buildName, { - 'fn': 'lodash.intersection(seventyFiveValues, seventyFiveValues2)', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.intersection(seventyFiveValues, seventyFiveValues2)', + 'fn': '_.intersection(hundredValues, hundredValues2)', 'teardown': 'function multiArrays(){}' }) ); @@ -1624,25 +1624,13 @@ suites.push( Benchmark.Suite('`_.union`') .add(buildName, '\ - lodash.union(numbers, fourNumbers, twoNumbers)' + lodash.union(numbers, twoNumbers, fourNumbers)' ) .add(otherName, '\ - _.union(numbers, fourNumbers, twoNumbers)' + _.union(numbers, twoNumbers, fourNumbers)' ) ); - suites.push( - Benchmark.Suite('`_.union` iterating an array of 50 elements') - .add(buildName, { - 'fn': 'lodash.union(twentyFiveValues, twentyFiveValues2);', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.union(twentyFiveValues, twentyFiveValues2);', - 'teardown': 'function multiArrays(){}' - }) - ); - suites.push( Benchmark.Suite('`_.union` iterating an array of 75 elements') .add(buildName, { @@ -1655,56 +1643,32 @@ }) ); - suites.push( - Benchmark.Suite('`_.union` iterating an array of 100 elements') - .add(buildName, { - 'fn': 'lodash.union(seventyFiveValues, twentyFiveValues2);', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.union(seventyFiveValues, twentyFiveValues2);', - 'teardown': 'function multiArrays(){}' - }) - ); - /*--------------------------------------------------------------------------*/ suites.push( Benchmark.Suite('`_.uniq`') .add(buildName, '\ - lodash.uniq(numbers.concat(fourNumbers, twoNumbers))' + lodash.uniq(numbers.concat(twoNumbers, fourNumbers))' ) .add(otherName, '\ - _.uniq(numbers.concat(fourNumbers, twoNumbers))' + _.uniq(numbers.concat(twoNumbers, fourNumbers))' ) ); suites.push( Benchmark.Suite('`_.uniq` with `callback`') .add(buildName, '\ - lodash.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {\ + lodash.uniq(numbers.concat(twoNumbers, fourNumbers), function(num) {\ return num % 2;\ });' ) .add(otherName, '\ - _.uniq(numbers.concat(fourNumbers, twoNumbers), function(num) {\ + _.uniq(numbers.concat(twoNumbers, fourNumbers), function(num) {\ return num % 2;\ })' ) ); - suites.push( - Benchmark.Suite('`_.uniq` iterating an array of 50 elements') - .add(buildName, { - 'fn': 'lodash.uniq(twentyFiveValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.uniq(twentyFiveValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - ); - suites.push( Benchmark.Suite('`_.uniq` iterating an array of 75 elements') .add(buildName, { @@ -1717,18 +1681,6 @@ }) ); - suites.push( - Benchmark.Suite('`_.uniq` iterating an array of 100 elements') - .add(buildName, { - 'fn': 'lodash.uniq(seventyFiveValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.uniq(seventyFiveValues.concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - ); - /*--------------------------------------------------------------------------*/ suites.push( @@ -1766,37 +1718,13 @@ ); suites.push( - Benchmark.Suite('`_.without` iterating an array of 25 elements') - .add(buildName, { - 'fn': 'lodash.without.apply(lodash, [twentyFiveValues].concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.without.apply(_, [twentyFiveValues].concat(twentyFiveValues2));', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.without` iterating an array of 75 and 50 elements') - .add(buildName, { - 'fn': 'lodash.without.apply(lodash, [seventyFiveValues2].concat(fiftyValues));', - 'teardown': 'function multiArrays(){}' - }) - .add(otherName, { - 'fn': '_.without.apply(_, [seventyFiveValues2].concat(fiftyValues));', - 'teardown': 'function multiArrays(){}' - }) - ); - - suites.push( - Benchmark.Suite('`_.without` iterating an array of 75 elements') + Benchmark.Suite('`_.without` iterating an array of 20 elements') .add(buildName, { - 'fn': 'lodash.without.apply(lodash, [seventyFiveValues].concat(seventyFiveValues2));', + 'fn': 'lodash.without.apply(lodash, [twentyValues].concat(twentyValues2));', 'teardown': 'function multiArrays(){}' }) .add(otherName, { - 'fn': '_.without.apply(_, [seventyFiveValues].concat(seventyFiveValues2));', + 'fn': '_.without.apply(_, [twentyValues].concat(twentyValues2));', 'teardown': 'function multiArrays(){}' }) ); From 05dbf41fdc9ca49a3059a2c91ded7c6b138a9f22 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 13 Dec 2012 23:48:19 -0800 Subject: [PATCH 26/45] Optimize `_.intersection`. Former-commit-id: 017b20ad958a9dd7be09872456b1d26a59361c5a --- lodash.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lodash.js b/lodash.js index eb0dc4e94e..d3c829cd0b 100644 --- a/lodash.js +++ b/lodash.js @@ -2877,8 +2877,8 @@ * @memberOf _ * @category Arrays * @param {Array} [array1, array2, ...] Arrays to process. - * @returns {Array} Returns a new array of unique elements, in order, that are - * present in **all** of the arrays. + * @returns {Array} Returns a new array of unique elements that are present + * in **all** of the arrays. * @example * * _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); @@ -2887,18 +2887,28 @@ function intersection(array) { var args = arguments, argsLength = args.length, + cache = { '0': {} }, index = -1, length = array ? array.length : 0, - cache = {}, - result = []; + isLarge = length >= 100, + result = [], + seen = result; outer: while (++index < length) { var value = array[index]; - if (indexOf(result, value) < 0) { + if (isLarge) { + var inited = hasOwnProperty.call(cache[0], value + '') + ? !(seen = cache[0][value]) + : (seen = cache[0][value] = []); + } + if (inited || indexOf(seen, value) < 0) { + if (isLarge) { + seen.push(value); + } var argsIndex = argsLength; while (--argsIndex) { - if (!(cache[argsIndex] || (cache[argsIndex] = cachedContains(args[argsIndex])))(value)) { + if (!(cache[argsIndex] || (cache[argsIndex] = cachedContains(args[argsIndex], 0, 100)))(value)) { continue outer; } } @@ -3203,11 +3213,9 @@ computed = callback ? callback(value, index, array) : value; if (isLarge) { - // manually coerce `computed` to a string because `hasOwnProperty`, in - // some older versions of Firefox, coerces objects incorrectly var inited = hasOwnProperty.call(cache, computed + '') ? !(seen = cache[computed]) - : (seen = []); + : (seen = cache[computed] = []); } if (isSorted ? !index || seen[seen.length - 1] !== computed From 90597530a47b1997b561961410248f8c282b92a0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 14 Dec 2012 00:24:02 -0800 Subject: [PATCH 27/45] =?UTF-8?q?Add=20`=5F.cloneDeep`=20alias=20of=20`=5F?= =?UTF-8?q?.clone(=E2=80=A6,=20true)`.=20[closes=20#140]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: b71397d5c5b71cb28a60eb4656cbaf12f6b03d1a --- build.js | 2 ++ build/pre-compile.js | 1 + lodash.js | 49 ++++++++++++++++++++++++++++++-------------- test/test-build.js | 2 ++ test/test.js | 14 ++++++------- 5 files changed, 46 insertions(+), 22 deletions(-) diff --git a/build.js b/build.js index 7962cc5be9..fdb692ea96 100755 --- a/build.js +++ b/build.js @@ -71,6 +71,7 @@ 'bindAll': ['bind', 'functions'], 'bindKey': ['isFunction', 'isObject'], 'clone': ['assign', 'forEach', 'forOwn', 'isArray', 'isObject'], + 'cloneDeep': ['clone'], 'compact': [], 'compose': [], 'contains': ['indexOf', 'isString'], @@ -239,6 +240,7 @@ /** List of methods used by Underscore */ var underscoreMethods = _.without.apply(_, [allMethods].concat([ 'bindKey', + 'cloneDeep', 'forIn', 'forOwn', 'isPlainObject', diff --git a/build/pre-compile.js b/build/pre-compile.js index e02f303e2c..67f96e2764 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -69,6 +69,7 @@ 'bindAll', 'bindKey', 'clone', + 'cloneDeep', 'collect', 'compact', 'compose', diff --git a/lodash.js b/lodash.js index d3c829cd0b..5523aba2d0 100644 --- a/lodash.js +++ b/lodash.js @@ -256,8 +256,8 @@ * `unshift`, `values`, `where`, `without`, `wrap`, and `zip` * * The non-chainable wrapper functions are: - * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, - * `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, + * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, + * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, * `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, * `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, @@ -967,14 +967,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a clone of `value`. If `deep` is `true`, all nested objects will - * also be cloned, otherwise they will be assigned by reference. Functions and - * DOM nodes are **not** cloned. The enumerable properties of `arguments` objects - * and objects created by constructors other than `Object` are cloned to plain - * `Object` objects. - * - * Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm. - * See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. + * Creates a clone of `value`. If `deep` is `true`, nested objects will also + * be cloned, otherwise they will be assigned by reference. * * @static * @memberOf _ @@ -995,9 +989,6 @@ * { 'name': 'curly', 'age': 60 } * ]; * - * _.clone({ 'name': 'moe' }); - * // => { 'name': 'moe' } - * * var shallow = _.clone(stooges); * shallow[0] === stooges[0]; * // => true @@ -1076,6 +1067,35 @@ return result; } + /** + * Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. + * The enumerable properties of `arguments` objects and objects created by + * constructors other than `Object` are cloned to plain `Object` objects. + * + * Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm. + * See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to deep clone. + * @returns {Mixed} Returns the deep cloned `value`. + * @example + * + * var stooges = [ + * { 'name': 'moe', 'age': 40 }, + * { 'name': 'larry', 'age': 50 }, + * { 'name': 'curly', 'age': 60 } + * ]; + * + * var deep = _.cloneDeep(stooges); + * deep[0] === stooges[0]; + * // => false + */ + function cloneDeep(value) { + return clone(value, true); + } + /** * Assigns own enumerable properties of source object(s) to the `destination` * object for all `destination` properties that resolve to `null`/`undefined`. @@ -3730,8 +3750,6 @@ /** * This function returns the first argument passed to it. * - * Note: This function is used throughout Lo-Dash as a default callback. - * * @static * @memberOf _ * @category Utilities @@ -4257,6 +4275,7 @@ // add functions that return unwrapped values when chaining lodash.clone = clone; + lodash.cloneDeep = cloneDeep; lodash.contains = contains; lodash.escape = escape; lodash.every = every; diff --git a/test/test-build.js b/test/test-build.js index 796cefa6b6..31c7162949 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -147,6 +147,7 @@ var objectsMethods = [ 'assign', 'clone', + 'cloneDeep', 'defaults', 'extend', 'forIn', @@ -248,6 +249,7 @@ /** List of methods used by Underscore */ var underscoreMethods = _.without.apply(_, [allMethods].concat([ 'bindKey', + 'cloneDeep', 'forIn', 'forOwn', 'isPlainObject', diff --git a/test/test.js b/test/test.js index 91a6058a85..e34fb7886f 100644 --- a/test/test.js +++ b/test/test.js @@ -243,7 +243,7 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.clone'); + QUnit.module('cloning'); (function() { function Klass() { this.a = 1; } @@ -277,7 +277,7 @@ _.forOwn(objects, function(object, key) { test('should deep clone ' + key, function() { - var clone = _.clone(object, true); + var clone = _.cloneDeep(object); ok(_.isEqual(object, clone)); if (_.isObject(object)) { @@ -291,7 +291,7 @@ _.forOwn(nonCloneable, function(object, key) { test('should not clone ' + key, function() { strictEqual(_.clone(object), object); - strictEqual(_.clone(object, true), object); + strictEqual(_.cloneDeep(object), object); }); }); @@ -304,7 +304,7 @@ test('should deep clone `index` and `input` array properties', function() { var array = /x/.exec('x'), - actual = _.clone(array, true); + actual = _.cloneDeep(array); equal(actual.index, 0); equal(actual.input, 'x'); @@ -319,15 +319,15 @@ object.foo.b.foo.c = object; object.bar.b = object.foo.b; - var clone = _.clone(object, true); + var clone = _.cloneDeep(object); ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.foo.c && clone !== object); }); test('should clone problem JScript properties (test in IE < 9)', function() { deepEqual(_.clone(shadowed), shadowed); notEqual(_.clone(shadowed), shadowed); - deepEqual(_.clone(shadowed, true), shadowed); - notEqual(_.clone(shadowed, true), shadowed); + deepEqual(_.cloneDeep(shadowed), shadowed); + notEqual(_.cloneDeep(shadowed), shadowed); }); }(1, 2, 3)); From 33bc3d6a1eae844a900facb6aa8dfa1359cf761e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 14 Dec 2012 00:31:07 -0800 Subject: [PATCH 28/45] Update vendors, builds, and docs. Former-commit-id: d57931d657ac0e73d91ac1bd1b33e24be5a16f35 --- .travis.yml | 2 +- build/post-install.js | 2 +- doc/README.md | 227 ++++++++------- lodash.min.js | 32 +-- lodash.underscore.js | 23 +- vendor/backbone/backbone.js | 412 +++++++++++++--------------- vendor/backbone/test/collection.js | 90 +++++- vendor/backbone/test/events.js | 58 +++- vendor/backbone/test/model.js | 61 ++-- vendor/backbone/test/router.js | 4 +- vendor/backbone/test/view.js | 34 +-- vendor/underscore/underscore-min.js | 6 +- vendor/underscore/underscore.js | 7 +- 13 files changed, 539 insertions(+), 419 deletions(-) diff --git a/.travis.yml b/.travis.yml index b9d6964b6a..2b22b6adb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,4 @@ node_js: - 0.8 before_script: - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/a2787b470c577cee2404d186c562dd9835f779f5 | tar xvz -C vendor" - - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/3390b259e04829538e4d3635d12b317dd6103eca | tar xvz -C vendor" + - "curl -H 'Accept: application/vnd.github.v3.raw' https://api.github.com/repos/bestiejs/lodash/git/blobs/7ecae09d413eb48dd5785fe877f24e60ac3bbcef | tar xvz -C vendor" diff --git a/build/post-install.js b/build/post-install.js index 244c5e309a..8b59affce7 100644 --- a/build/post-install.js +++ b/build/post-install.js @@ -20,7 +20,7 @@ var closureId = 'a2787b470c577cee2404d186c562dd9835f779f5'; /** The Git object ID of `uglifyjs.tar.gz` */ - var uglifyId = '3390b259e04829538e4d3635d12b317dd6103eca'; + var uglifyId = '7ecae09d413eb48dd5785fe877f24e60ac3bbcef'; /** The media type for raw blob data */ var mediaType = 'application/vnd.github.v3.raw'; diff --git a/doc/README.md b/doc/README.md index 46c05b083d..f2b991e377 100644 --- a/doc/README.md +++ b/doc/README.md @@ -107,6 +107,7 @@ ## `Objects` * [`_.assign`](#_assignobject--source1-source2-) * [`_.clone`](#_clonevalue-deep) +* [`_.cloneDeep`](#_clonedeepvalue) * [`_.defaults`](#_defaultsobject--default1-default2-) * [`_.extend`](#_assignobject--source1-source2-) * [`_.forIn`](#_forinobject--callbackidentity-thisarg) @@ -185,7 +186,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2694 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2714 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -209,7 +210,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -234,7 +235,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2759 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2779 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -262,7 +263,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2786 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2806 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -290,7 +291,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2828 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "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, passing `true` for `fromIndex` will run a faster binary search. @@ -322,7 +323,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2863 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2883 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -347,7 +348,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2887 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2907 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -355,7 +356,7 @@ Computes the intersection of all the passed-in arrays using strict equality for 1. `[array1, array2, ...]` *(Array)*: Arrays to process. #### Returns -*(Array)*: Returns a new array of unique elements, in order, that are present in **all** of the arrays. +*(Array)*: Returns a new array of unique elements that are present in **all** of the arrays. #### Example ```js @@ -371,7 +372,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2929 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2959 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -396,7 +397,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2956 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2986 "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. @@ -425,7 +426,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2986 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3016 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -450,7 +451,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3031 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3061 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -488,7 +489,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3070 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3100 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -516,7 +517,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3114 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3144 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -560,7 +561,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3146 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3176 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -584,7 +585,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#L3180 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3210 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -623,7 +624,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3240 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3268 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -648,7 +649,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3271 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3299 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -681,7 +682,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L275 "View in source") [Ⓣ][1] -Creates a `lodash` object, that wraps the given `value`, to enable method chaining. The chainable wrapper functions are: `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` The non-chainable wrapper functions are: `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values. +Creates a `lodash` object, that wraps the given `value`, to enable method chaining. The chainable wrapper functions are: `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` The non-chainable wrapper functions are: `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values. #### Arguments 1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. @@ -697,7 +698,7 @@ Creates a `lodash` object, that wraps the given `value`, to enable method chaini ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4140 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4166 "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. @@ -727,7 +728,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4157 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4183 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -748,7 +749,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4174 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4200 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -779,7 +780,7 @@ _([1, 2, 3]).valueOf(); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1930 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1950 "View in source") [Ⓣ][1] Checks if a given `target` element 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. @@ -817,7 +818,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1977 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1997 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -849,7 +850,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2007 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2027 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -878,7 +879,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2046 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2066 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -907,7 +908,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2110 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -936,7 +937,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2125 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2145 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -968,7 +969,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2170 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2190 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1000,7 +1001,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2203 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2223 "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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1029,7 +1030,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2235 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2255 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1061,7 +1062,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2277 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2297 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, 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)*. @@ -1093,7 +1094,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2323 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2343 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, 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)*. @@ -1119,7 +1120,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2372 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2392 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1150,7 +1151,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2396 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2416 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1180,7 +1181,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2438 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2458 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1211,7 +1212,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#L2476 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2496 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -1237,7 +1238,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2497 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2517 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1261,7 +1262,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2529 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2549 "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. @@ -1291,7 +1292,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2554 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2574 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds 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)*. @@ -1320,7 +1321,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2600 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2620 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1352,7 +1353,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2633 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1376,7 +1377,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2664 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2684 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1414,7 +1415,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3304 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3332 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1442,7 +1443,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3337 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3365 "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 passed to the bound function. @@ -1473,7 +1474,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3367 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3395 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1504,7 +1505,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3413 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3441 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. @@ -1545,7 +1546,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3436 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3464 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1572,7 +1573,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3469 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3497 "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. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1598,7 +1599,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3533 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3561 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1623,7 +1624,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3513 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3541 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1650,7 +1651,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3557 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3585 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1676,7 +1677,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3584 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3612 "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. @@ -1702,7 +1703,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3619 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3647 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1729,7 +1730,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3641 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3669 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1754,7 +1755,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3694 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3722 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1818,9 +1819,9 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1009 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1000 "View in source") [Ⓣ][1] -Creates a clone of `value`. If `deep` is `true`, all nested objects will also be cloned, otherwise they will be assigned by reference. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm. See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. +Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. #### Arguments 1. `value` *(Mixed)*: The value to clone. @@ -1837,9 +1838,6 @@ var stooges = [ { 'name': 'curly', 'age': 60 } ]; -_.clone({ 'name': 'moe' }); -// => { 'name': 'moe' } - var shallow = _.clone(stooges); shallow[0] === stooges[0]; // => true @@ -1854,10 +1852,41 @@ deep[0] === stooges[0]; + + +### `_.cloneDeep(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1095 "View in source") [Ⓣ][1] + +Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm. See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. + +#### Arguments +1. `value` *(Mixed)*: The value to deep clone. + +#### Returns +*(Mixed)*: Returns the deep cloned `value`. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 }, + { 'name': 'curly', 'age': 60 } +]; + +var deep = _.cloneDeep(stooges); +deep[0] === stooges[0]; +// => false +``` + +* * * + + + + ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1097 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1117 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1947,7 +1976,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1116 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1136 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -1974,7 +2003,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1141 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1161 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -1999,7 +2028,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1158 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1178 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2050,7 +2079,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1182 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1202 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2077,7 +2106,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1201 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1221 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2101,7 +2130,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1218 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1238 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2125,7 +2154,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1235 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1255 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2149,7 +2178,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1260 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1280 "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". @@ -2179,7 +2208,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1302 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1322 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2210,7 +2239,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1454 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1474 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. @@ -2246,7 +2275,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1471 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1491 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2270,7 +2299,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1534 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1554 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. @@ -2303,7 +2332,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1556 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1576 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2330,7 +2359,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1573 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1593 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2354,7 +2383,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1501 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1521 "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('')`)* @@ -2384,7 +2413,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1601 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1621 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2419,7 +2448,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1626 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1646 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2443,7 +2472,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1643 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1663 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2467,7 +2496,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1660 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1680 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2491,7 +2520,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1677 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1697 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2515,7 +2544,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1715 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1735 "View in source") [Ⓣ][1] Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2550,7 +2579,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1789 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1809 "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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2581,7 +2610,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1823 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1843 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2605,7 +2634,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1876 "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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2636,7 +2665,7 @@ _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1913 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2667,7 +2696,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3718 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3746 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2691,9 +2720,9 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3764 "View in source") [Ⓣ][1] -This function returns the first argument passed to it. Note: This function is used throughout Lo-Dash as a default callback. +This function returns the first argument passed to it. #### Arguments 1. `value` *(Mixed)*: Any value. @@ -2716,7 +2745,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3764 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3790 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2746,7 +2775,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3790 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3816 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2766,7 +2795,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3813 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3839 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2794,7 +2823,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3851 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3877 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2829,7 +2858,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3936 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3962 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html @@ -2903,7 +2932,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4067 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4093 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -2935,7 +2964,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4093 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4119 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -2959,7 +2988,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4113 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4139 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -2993,7 +3022,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4337 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4364 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.min.js b/lodash.min.js index f22800ecae..a244e73206 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -17,7 +17,7 @@ t))){for(var f=u.length;f--;)if(i=u[f]==t)break;i?e[n]=a[f]:(u.push(t),a.push(o= i?i:0),t=l(t,n);if(gn(e))for(;++rr&&(r=n,o=e)});else for(;++io&&(o=e[i]);return o}function F(e,t){return B(e,t+"")}function I(e,t,r,s){var o=3>arguments.length,t=l(t,s,n);if(gn(e)){var u=-1,a=e.length;for(o&&(r=e[++u]);++uarguments.length;if("number"!=typeof u)var f=bn(e),u=f.length;else Zt&&L(e)&&(o=e.split(""));return t=l(t,s,n),H(e,function(e,n,s){n=f?f[--u]:--u,r=a?(a=i,o[n]):t(r,o[n],n,s)}),r}function R(e,t,n){var r,t=l(t,n);if(gn(e))for(var n=-1,i=e.length;++nn?Dt(0,i+n):n||0)-1;else if(n)return r=V(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])W(a,h))(n||f)&&a.push(h),u.push(r)}return u}function J(e,t){return Vt||Lt&&2W(a,h))(n||f)&&a.push(h),u.push(r)}return u}function J(e,t){return Vt||Lt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ut=/&(?:amp|lt|gt|quot|#x27);/g,at=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,lt=/(__e\(.*?\)|\b__t\))\+'';/g,ct=/\w*$/,ht=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,pt=RegExp("^"+(tt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g ,".+?")+"$"),dt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,vt=/<%=([\s\S]+?)%>/g,mt=/($^)/,gt=/[&<>"']/g,yt=/['\n\r\t\u2028\u2029\\]/g,bt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),wt=Math.ceil,Et=et.concat,St=Math.floor,xt=pt.test(xt=Object.getPrototypeOf)&&xt,Tt=tt.hasOwnProperty,Nt=et.push,Ct=tt.propertyIsEnumerable,kt=tt.toString,Lt=pt.test(Lt=m.bind)&&Lt,At=pt.test(At=Array.isArray)&&At,Ot=e.isFinite,Mt=e.isNaN,_t=pt.test(_t=Object.keys)&& _t,Dt=Math.max,Pt=Math.min,Ht=Math.random,Bt="[object Arguments]",jt="[object Array]",Ft="[object Boolean]",It="[object Date]",qt="[object Number]",Rt="[object Object]",Ut="[object RegExp]",zt="[object String]",Wt=!!e.attachEvent,Xt=Lt&&!/\n|true/.test(Lt+Wt),Vt=Lt&&!Xt,$t=_t&&(Wt||Xt),Jt,Kt,Qt=(Qt={0:1,length:1},et.splice.call(Qt,0,1),Qt[0]),Gt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Gt=!n;Jt=!/valueOf/.test(t),Kt="x"!= @@ -26,18 +26,18 @@ t[0]})(1);var Yt=!y(arguments),Zt="xx"!="x"[0]+Object("x")[0];try{var en=("[obje },vn=x(dn),mn=c(un,{g:"if(t[i]==null)"+un.g}),gn=At||function(e){return e instanceof Array||kt.call(e)==jt};N(/x/)&&(N=function(e){return e instanceof Function||"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!y(e):b(e)}:b,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?w(e):C(e)?_t(e):[]}:w;s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t .apply(this,arguments)}},s.assign=cn,s.bind=J,s.bindAll=function(e){for(var t=arguments,n=1W(u,a)){for( -var f=n;--f;)if(!(s[f]||(s[f]=o(t[f])))(a))continue e;u.push(a)}}return u},s.invert=x,s.invoke=function(e,t){var n=m(arguments,2),r="function"==typeof t,i=[];return H(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=A,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&L(e)?u:l(t,n),ln( -e,function(e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn -(e,function(e,n){t.push([n,e])}),t},s.partial=function(e){return f(e,m(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r -,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0 -),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return N(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,o=s.templateSettings,u=0,a=n.interpolate||o.interpolate||mt,f="__p+='",l=n.variable||o.variable,c=l;e.replace(RegExp((n.escape||o.escape||mt).source+"|"+a.source+"|"+(a===vt?dt:mt).source+"|"+(n.evaluate||o.evaluate||mt).source+"|$" -,"g"),function(t,n,i,s,o,a){return i||(i=s),f+=e.slice(u,a).replace(yt,h),n&&(f+="'+__e("+n+")+'"),o&&(f+="';"+o+";__p+='"),i&&(f+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),u=a+t.length,t}),f+="';\n",c||(l="obj",r?f="with("+l+"){"+f+"}":(n=RegExp("(\\(\\s*)"+l+"\\."+l+"\\b","g"),f=f.replace(ht,"$&"+l+".").replace(n,"$1__d"))),f=(r?f.replace(at,""):f).replace(ft,"$1").replace(lt,"$1;"),f="function("+l+"){"+(c?"":l+"||("+l+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}" -:(c?"":",__d="+l+"."+l+"||"+l)+";")+f+"return __p}";try{i=Function("_","return "+f)(s)}catch(p){throw p.source=f,p}return t?i(t):(i.source=f,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,g)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=_,s.any=R,s.detect=P,s.foldl=I,s.foldr=q,s.include=M,s.inject=I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i= -e.length;return t==r||n?e[i-1]:m(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return this.__wrapped__+""},s.prototype.value=G,s.prototype.valueOf=G,ln(["join","pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),ln(["push","reverse","sort","unshift"],function(e){var t=et[e]; -s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),ln(["concat","slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Qt&&ln(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof -module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file +.apply(et,arguments),r=o(r,n),i=[];++tW(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(r[h]||(r[h]=o(t[h],0,100)))(l))continue e;a.push(l)}}return a},s.invert=x,s.invoke=function(e,t){var n=m(arguments,2),r="function"==typeof t,i=[];return H(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge=A +,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&L(e)?u:l(t,n),ln(e,function(e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function( +){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([n,e])}),t},s.partial=function(e){return f(e,m(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s. +mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return N(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,o=s.templateSettings,u=0,a=n.interpolate||o.interpolate||mt,f="__p+='",l=n.variable||o.variable,c=l;e.replace +(RegExp((n.escape||o.escape||mt).source+"|"+a.source+"|"+(a===vt?dt:mt).source+"|"+(n.evaluate||o.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,a){return i||(i=s),f+=e.slice(u,a).replace(yt,h),n&&(f+="'+__e("+n+")+'"),o&&(f+="';"+o+";__p+='"),i&&(f+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),u=a+t.length,t}),f+="';\n",c||(l="obj",r?f="with("+l+"){"+f+"}":(n=RegExp("(\\(\\s*)"+l+"\\."+l+"\\b","g"),f=f.replace(ht,"$&"+l+".").replace(n,"$1__d"))),f=(r?f.replace(at,""):f).replace +(ft,"$1").replace(lt,"$1;"),f="function("+l+"){"+(c?"":l+"||("+l+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(c?"":",__d="+l+"."+l+"||"+l)+";")+f+"return __p}";try{i=Function("_","return "+f)(s)}catch(p){throw p.source=f,p}return t?i(t):(i.source=f,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,g)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=_,s.any=R,s.detect=P,s.foldl=I,s.foldr=q,s.include=M,s.inject= +I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:m(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.2",s.prototype.toString=function(){return this.__wrapped__+""},s.prototype.value=G,s.prototype.valueOf=G,ln(["join" +,"pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),ln(["push","reverse","sort","unshift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),ln(["concat","slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Qt&&ln(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__ +,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index c448a776c4..14efc61ab3 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -196,8 +196,8 @@ * `unshift`, `values`, `where`, `without`, `wrap`, and `zip` * * The non-chainable wrapper functions are: - * `clone`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, - * `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, + * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, + * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, * `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, * `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, * `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, @@ -780,14 +780,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a clone of `value`. If `deep` is `true`, all nested objects will - * also be cloned, otherwise they will be assigned by reference. Functions and - * DOM nodes are **not** cloned. The enumerable properties of `arguments` objects - * and objects created by constructors other than `Object` are cloned to plain - * `Object` objects. - * - * Note: Lo-Dash's deep clone functionality is loosely based on the structured clone algorithm. - * See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. + * Creates a clone of `value`. If `deep` is `true`, nested objects will also + * be cloned, otherwise they will be assigned by reference. * * @static * @memberOf _ @@ -808,9 +802,6 @@ * { 'name': 'curly', 'age': 60 } * ]; * - * _.clone({ 'name': 'moe' }); - * // => { 'name': 'moe' } - * * var shallow = _.clone(stooges); * shallow[0] === stooges[0]; * // => true @@ -2475,8 +2466,8 @@ * @memberOf _ * @category Arrays * @param {Array} [array1, array2, ...] Arrays to process. - * @returns {Array} Returns a new array of unique elements, in order, that are - * present in **all** of the arrays. + * @returns {Array} Returns a new array of unique elements that are present + * in **all** of the arrays. * @example * * _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); @@ -3245,8 +3236,6 @@ /** * This function returns the first argument passed to it. * - * Note: This function is used throughout Lo-Dash as a default callback. - * * @static * @memberOf _ * @category Utilities diff --git a/vendor/backbone/backbone.js b/vendor/backbone/backbone.js index df82a11fbf..7391faac34 100644 --- a/vendor/backbone/backbone.js +++ b/vendor/backbone/backbone.js @@ -1,4 +1,4 @@ -// Backbone.js 0.9.9-pre +// Backbone.js 0.9.9 // (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. // Backbone may be freely distributed under the MIT license. @@ -19,10 +19,10 @@ var previousBackbone = root.Backbone; // Create a local reference to array methods. - var ArrayProto = Array.prototype; - var push = ArrayProto.push; - var slice = ArrayProto.slice; - var splice = ArrayProto.splice; + var array = []; + var push = array.push; + var slice = array.slice; + var splice = array.splice; // The top-level namespace. All public Backbone classes and modules will // be attached to this. Exported for both CommonJS and the browser. @@ -34,7 +34,7 @@ } // Current version of the library. Keep in sync with `package.json`. - Backbone.VERSION = '0.9.9-pre'; + Backbone.VERSION = '0.9.9'; // Require Underscore, if we're on the server, and it's not already present. var _ = root._; @@ -64,15 +64,49 @@ // Backbone.Events // --------------- - // Regular expression used to split event strings + // Regular expression used to split event strings. var eventSplitter = /\s+/; - // Internal flag used to set event callbacks `once`. - var once = false; + // Implement fancy features of the Events API such as multiple event + // names `"change blur"` and jQuery-style event maps `{change: action}` + // in terms of the existing API. + var eventsApi = function(obj, action, name, rest) { + if (!name) return true; + if (typeof name === 'object') { + for (var key in name) { + obj[action].apply(obj, [key, name[key]].concat(rest)); + } + } else if (eventSplitter.test(name)) { + var names = name.split(eventSplitter); + for (var i = 0, l = names.length; i < l; i++) { + obj[action].apply(obj, [names[i]].concat(rest)); + } + } else { + return true; + } + }; + + // Optimized internal dispatch function for triggering events. Tries to + // keep the usual cases speedy (most Backbone events have 3 arguments). + var triggerEvents = function(obj, events, args) { + var ev, i = -1, l = events.length; + switch (args.length) { + case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); + return; + case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0]); + return; + case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1]); + return; + case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1], args[2]); + return; + default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); + } + }; // A module that can be mixed in to *any object* in order to provide it with - // custom events. You may bind with `on` or remove with `off` callback functions - // to an event; `trigger`-ing an event fires all callbacks in succession. + // custom events. You may bind with `on` or remove with `off` callback + // functions to an event; `trigger`-ing an event fires all callbacks in + // succession. // // var object = {}; // _.extend(object, Backbone.Events); @@ -81,72 +115,58 @@ // var Events = Backbone.Events = { - // Bind one or more space separated events, `events`, to a `callback` - // function. Passing `"all"` will bind the callback to all events fired. - on: function(events, callback, context) { - if (_.isObject(events)) { - for (var key in events) { - this.on(key, events[key], callback); - } - return this; - } - - var calls, event, list; - if (!callback) return this; - - events = events.split(eventSplitter); - calls = this._callbacks || (this._callbacks = {}); - - while (event = events.shift()) { - list = calls[event] || (calls[event] = []); - list.push(callback, context, once ? {} : null); - } - + // Bind one or more space separated events, or an events map, + // to a `callback` function. Passing `"all"` will bind the callback to + // all events fired. + on: function(name, callback, context) { + if (!(eventsApi(this, 'on', name, [callback, context]) && callback)) return this; + this._events || (this._events = {}); + var list = this._events[name] || (this._events[name] = []); + list.push({callback: callback, context: context, ctx: context || this}); return this; }, // Bind events to only be triggered a single time. After the first time // the callback is invoked, it will be removed. - once: function(events, callback, context) { - once = true; - this.on(events, callback, context); - once = false; + once: function(name, callback, context) { + if (!(eventsApi(this, 'once', name, [callback, context]) && callback)) return this; + var self = this; + var once = _.once(function() { + self.off(name, once); + callback.apply(this, arguments); + }); + once._callback = callback; + this.on(name, once, context); return this; }, - // Remove one or many callbacks. If `context` is null, removes all callbacks - // with that function. If `callback` is null, removes all callbacks for the - // event. If `events` is null, removes all bound callbacks for all events. - off: function(events, callback, context) { - if (_.isObject(events)) { - for (var key in events) { - this.off(key, events[key], callback); - } - return this; - } - - var event, calls, list, i; - - // No events, or removing *all* events. - if (!(calls = this._callbacks)) return this; - if (!(events || callback || context)) { - delete this._callbacks; + // Remove one or many callbacks. If `context` is null, removes all + // callbacks with that function. If `callback` is null, removes all + // callbacks for the event. If `events` is null, removes all bound + // callbacks for all events. + off: function(name, callback, context) { + var list, ev, events, names, i, l, j, k; + if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this; + if (!name && !callback && !context) { + this._events = {}; return this; } - events = events ? events.split(eventSplitter) : _.keys(calls); - - // Loop through the callback list, splicing where appropriate. - while (event = events.shift()) { - if (!(list = calls[event]) || !(callback || context)) { - delete calls[event]; - continue; - } - - for (i = list.length - 3; i >= 0; i -= 3) { - if (!(callback && list[i] !== callback || context && list[i + 1] !== context)) { - list.splice(i, 3); + names = name ? [name] : _.keys(this._events); + for (i = 0, l = names.length; i < l; i++) { + name = names[i]; + if (list = this._events[name]) { + events = []; + if (callback || context) { + for (j = 0, k = list.length; j < k; j++) { + ev = list[j]; + if ((callback && callback !== (ev.callback._callback || ev.callback)) || + (context && context !== ev.context)) { + events.push(ev); + } + } } + this._events[name] = events; } } @@ -157,48 +177,43 @@ // passed the same arguments as `trigger` is, apart from the event name // (unless you're listening on `"all"`, which will cause your callback to // receive the true name of the event as the first argument). - trigger: function(events) { - var event, calls, list, i, length, args, all, rest, callback, context, onced; - if (!(calls = this._callbacks)) return this; - - rest = []; - events = events.split(eventSplitter); - - // Fill up `rest` with the callback arguments. Since we're only copying - // the tail of `arguments`, a loop is much faster than Array#slice. - for (i = 1, length = arguments.length; i < length; i++) { - rest[i - 1] = arguments[i]; - } + trigger: function(name) { + if (!this._events) return this; + var args = slice.call(arguments, 1); + if (!eventsApi(this, 'trigger', name, args)) return this; + var events = this._events[name]; + var allEvents = this._events.all; + if (events) triggerEvents(this, events, args); + if (allEvents) triggerEvents(this, allEvents, arguments); + return this; + }, - // For each event, walk through the list of callbacks twice, first to - // trigger the event, then to trigger any `"all"` callbacks. - while (event = events.shift()) { - // Copy callback lists to prevent modification. - if (all = calls.all) all = all.slice(); - if (list = calls[event]) list = list.slice(); - - // Execute event callbacks. - if (list) { - for (i = 0, length = list.length; i < length; i += 3) { - callback = list[i], context = list[i + 1], onced = list[i + 2]; - if (onced) calls[event].splice(i, 3); - if (!onced || !onced.dead) callback.apply(context || this, rest); - if (onced) onced.dead = true; - } - } + // An inversion-of-control version of `on`. Tell *this* object to listen to + // an event in another object ... keeping track of what it's listening to. + listenTo: function(object, events, callback) { + var listeners = this._listeners || (this._listeners = {}); + var id = object._listenerId || (object._listenerId = _.uniqueId('l')); + listeners[id] = object; + object.on(events, callback || this, this); + return this; + }, - // Execute "all" callbacks. - if (all) { - args = [event].concat(rest); - for (i = 0, length = all.length; i < length; i += 3) { - all[i].apply(all[i + 1] || this, args); - } + // Tell this object to stop listening to either specific events ... or + // to every object it's currently listening to. + stopListening: function(object, events, callback) { + var listeners = this._listeners; + if (!listeners) return; + if (object) { + object.off(events, callback, this); + if (!events && !callback) delete listeners[object._listenerId]; + } else { + for (var id in listeners) { + listeners[id].off(null, null, this); } + this._listeners = {}; } - return this; } - }; // Aliases for backwards compatibility. @@ -220,17 +235,12 @@ this.cid = _.uniqueId('c'); this.changed = {}; this.attributes = {}; - this._escapedAttributes = {}; - this._modelState = []; + this._changes = []; if (options && options.collection) this.collection = options.collection; if (options && options.parse) attrs = this.parse(attrs); - if (defaults = _.result(this, 'defaults')) { - attrs = _.extend({}, defaults, attrs); - } + if (defaults = _.result(this, 'defaults')) _.defaults(attrs, defaults); this.set(attrs, {silent: true}); - this._cleanChange = true; - this._modelState = []; - this._currentState = _.clone(this.attributes); + this._currentAttributes = _.clone(this.attributes); this._previousAttributes = _.clone(this.attributes); this.initialize.apply(this, arguments); }; @@ -241,27 +251,6 @@ // A hash of attributes whose current and previous value differ. changed: null, - // Whether there is a pending request to fire in the final `change` loop. - _pending: false, - - // Whether the model is in the midst of a change cycle. - _changing: false, - - // Whether there has been a `set` call since the last - // calculation of the changed hash, for efficiency. - _cleanChange: true, - - // The model state used for comparison in determining if a - // change should be fired. - _currentState: null, - - // An array queue of all changes attributed to a model - // on the next non-silent change event. - _modelState: null, - - // A hash of the model's attributes when the last `change` occured. - _previousAttributes: null, - // The default name for the JSON `id` attribute is `"id"`. MongoDB and // CouchDB users may want to set this to `"_id"`. idAttribute: 'id', @@ -287,10 +276,7 @@ // Get the HTML-escaped value of an attribute. escape: function(attr) { - var html; - if (html = this._escapedAttributes[attr]) return html; - var val = this.get(attr); - return this._escapedAttributes[attr] = _.escape(val == null ? '' : '' + val); + return _.escape(this.get(attr)); }, // Returns `true` if the attribute contains a value that is not null @@ -317,9 +303,6 @@ var silent = options && options.silent; var unset = options && options.unset; - if (attrs instanceof Model) attrs = attrs.attributes; - if (unset) for (attr in attrs) attrs[attr] = void 0; - // Run validation. if (!this._validate(attrs, options)) return false; @@ -327,24 +310,19 @@ if (this.idAttribute in attrs) this.id = attrs[this.idAttribute]; var now = this.attributes; - var esc = this._escapedAttributes; // For each `set` attribute... for (attr in attrs) { val = attrs[attr]; - // If an escaped attr exists, and the new and current value differ, remove the escaped attr. - if (esc[attr] && !_.isEqual(now[attr], val) || (unset && _.has(now, attr))) delete esc[attr]; - - // Update or delete the current value. + // Update or delete the current value, and track the change. unset ? delete now[attr] : now[attr] = val; - - // Track any action on the attribute. - this._modelState.push(attr, val, unset); + this._changes.push(attr, val); } - // Signal that the model's state has potentially changed. - this._cleanChange = false; + // Signal that the model's state has potentially changed, and we need + // to recompute the actual changes. + this._hasComputed = false; // Fire the `"change"` events. if (!silent) this.change(options); @@ -354,15 +332,15 @@ // Remove an attribute from the model, firing `"change"` unless you choose // to silence it. `unset` is a noop if the attribute doesn't exist. unset: function(attr, options) { - options = _.extend({}, options, {unset: true}); - return this.set(attr, null, options); + return this.set(attr, void 0, _.extend({}, options, {unset: true})); }, // Clear all attributes on the model, firing `"change"` unless you choose // to silence it. clear: function(options) { - options = _.extend({}, options, {unset: true}); - return this.set(_.clone(this.attributes), options); + var attrs = {}; + for (var key in this.attributes) attrs[key] = void 0; + return this.set(attrs, _.extend({}, options, {unset: true})); }, // Fetch the model from the server. If the server's representation of the @@ -374,7 +352,7 @@ var model = this; var success = options.success; options.success = function(resp, status, xhr) { - if (!model.set(model.parse(resp, xhr), options)) return false; + if (!model.set(model.parse(resp), options)) return false; if (success) success(model, resp, options); }; return this.sync('read', this, options); @@ -416,7 +394,7 @@ var success = options.success; options.success = function(resp, status, xhr) { done = true; - var serverAttrs = model.parse(resp, xhr); + var serverAttrs = model.parse(resp); if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); if (!model.set(serverAttrs, options)) return false; if (success) success(model, resp, options); @@ -475,7 +453,7 @@ // **parse** converts a response into the hash of attributes to be `set` on // the model. The default implementation is just to pass the response along. - parse: function(resp, xhr) { + parse: function(resp) { return resp; }, @@ -493,14 +471,15 @@ // a `"change:attribute"` event for each changed attribute. // Calling this will cause all objects observing the model to update. change: function(options) { - var i, changing = this._changing; + var changing = this._changing; this._changing = true; // Generate the changes to be triggered on the model. - var triggers = this._changeCenter(true); - this._pending = triggers.length; + var triggers = this._computeChanges(true); + + this._pending = !!triggers.length; - for (i = triggers.length - 2; i >= 0; i -= 2) { + for (var i = triggers.length - 2; i >= 0; i -= 2) { this.trigger('change:' + triggers[i], this, triggers[i + 1], options); } @@ -513,14 +492,14 @@ this._previousAttributes = _.clone(this.attributes); } - this._changing = null; + this._changing = false; return this; }, // Determine if the model has changed since the last `"change"` event. // If you specify an attribute name, determine if that attribute has changed. hasChanged: function(attr) { - if (!this._cleanChange) this._changeCenter(); + if (!this._hasComputed) this._computeChanges(); if (attr == null) return !_.isEmpty(this.changed); return _.has(this.changed, attr); }, @@ -541,39 +520,36 @@ return changed; }, - // Calculates and handles any changes in `this._modelState`, - // checking against `this._currentState` to determine current changes. - _changeCenter: function (change) { + // Looking at the built up list of `set` attribute changes, compute how + // many of the attributes have actually changed. If `loud`, return a + // boiled-down list of only the real changes. + _computeChanges: function(loud) { this.changed = {}; - var local = {}; + var already = {}; var triggers = []; - var modelState = this._modelState; - var currentState = this._currentState; + var current = this._currentAttributes; + var changes = this._changes; // Loop through the current queue of potential model changes. - for (var i = modelState.length - 3; i >= 0; i -= 3) { - var key = modelState[i], val = modelState[i + 1], unset = modelState[i + 2]; - - // If the item hasn't been set locally this round, proceed. - if (!local[key]) { - local[key] = val; - - // Check if the attribute has been modified since the last change, - // and update `this.changed` accordingly. - if (currentState[key] !== val || (_.has(currentState, key) && unset)) { - this.changed[key] = val; - - // Triggers & modifications are only created inside a `change` call. - if (!change) continue; - triggers.push(key, val); - (!unset) ? currentState[key] = val : delete currentState[key]; - } + for (var i = changes.length - 2; i >= 0; i -= 2) { + var key = changes[i], val = changes[i + 1]; + if (already[key]) continue; + already[key] = true; + + // Check if the attribute has been modified since the last change, + // and update `this.changed` accordingly. If we're inside of a `change` + // call, also add a trigger to the list. + if (current[key] !== val) { + this.changed[key] = val; + if (!loud) continue; + triggers.push(key, val); + current[key] = val; } - modelState.splice(i,3); } + if (loud) this._changes = []; // Signals `this.changed` is current to prevent duplicate calls from `this.hasChanged`. - this._cleanChange = true; + this._hasComputed = true; return triggers; }, @@ -590,12 +566,6 @@ return _.clone(this._previousAttributes); }, - // Check if the model is currently in a valid state. It's only possible to - // get into an *invalid* state if you're using silent changes. - isValid: function(options) { - return !this.validate || !this.validate(this.attributes, options); - }, - // Run validation against the next complete set of model attributes, // returning `true` if all is well. If a specific `error` callback has // been passed, call that instead of firing the general `"error"` event. @@ -651,8 +621,9 @@ // Add a model, or list of models to the set. Pass **silent** to avoid // firing the `add` event for every new model. add: function(models, options) { - var i, args, length, model, existing, sort; + var i, args, length, model, existing, needsSort; var at = options && options.at; + var sort = ((options && options.sort) == null ? true : options.sort); models = _.isArray(models) ? models.slice() : [models]; // Turn bare objects into model references, and prevent invalid models @@ -670,8 +641,8 @@ // optionally merge it into the existing model. if (existing || this._byCid[model.cid]) { if (options && options.merge && existing) { - existing.set(model, options); - sort = true; + existing.set(model.attributes, options); + needsSort = sort; } models.splice(i, 1); continue; @@ -685,14 +656,14 @@ } // See if sorting is needed, update `length` and splice in new models. - if (models.length) sort = true; + if (models.length) needsSort = sort; this.length += models.length; args = [at != null ? at : this.models.length, 0]; push.apply(args, models); splice.apply(this.models, args); // Sort the collection if appropriate. - if (sort && this.comparator && at == null) this.sort({silent: true}); + if (needsSort && this.comparator && at == null) this.sort({silent: true}); if (options && options.silent) return this; @@ -730,7 +701,7 @@ // Add a model to the end of the collection. push: function(model, options) { model = this._prepareModel(model, options); - this.add(model, options); + this.add(model, _.extend({at: this.length}, options)); return model; }, @@ -808,21 +779,31 @@ // Smartly update a collection with a change set of models, adding, // removing, and merging as necessary. update: function(models, options) { - var model, i, l, id, cid, existing; - var add = [], remove = []; - options = _.extend({add: true, merge: true, remove: false}, options); + var model, i, l, existing; + var add = [], remove = [], modelMap = {}; + var idAttr = this.model.prototype.idAttribute; + options = _.extend({add: true, merge: true, remove: true}, options); + if (options.parse) models = this.parse(models); + + // Allow a single model (or no argument) to be passed. + if (!_.isArray(models)) models = models ? [models] : []; + + // Proxy to `add` for this case, no need to iterate... + if (options.add && !options.remove) return this.add(models, options); // Determine which models to add and merge, and which to remove. for (i = 0, l = models.length; i < l; i++) { model = models[i]; - existing = this.get(model); - if (options.add || options.merge && existing) add.push(model); + existing = this.get(model.id || model.cid || model[idAttr]); + if (options.remove && existing) modelMap[existing.cid] = true; + if ((options.add && !existing) || (options.merge && existing)) { + add.push(model); + } } if (options.remove) { - var changeset = new Collection(models); for (i = 0, l = this.models.length; i < l; i++) { model = this.models[i]; - if (!changeset.get(model)) remove.push(model); + if (!modelMap[model.cid]) remove.push(model); } } @@ -858,7 +839,7 @@ var success = options.success; options.success = function(resp, status, xhr) { var method = options.update ? 'update' : 'reset'; - collection[method](collection.parse(resp, xhr), options); + collection[method](resp, options); if (success) success(collection, resp, options); }; return this.sync('read', this, options); @@ -884,7 +865,7 @@ // **parse** converts a response into a list of models to be added to the // collection. The default implementation is just to pass it through. - parse: function(resp, xhr) { + parse: function(resp) { return resp; }, @@ -1309,20 +1290,11 @@ return this; }, - // Clean up references to this view in order to prevent latent effects and - // memory leaks. - dispose: function() { - this.undelegateEvents(); - if (this.model && this.model.off) this.model.off(null, null, this); - if (this.collection && this.collection.off) this.collection.off(null, null, this); - return this; - }, - - // Remove this view from the DOM. Note that the view isn't present in the - // DOM by default, so calling this method may be a no-op. + // Remove this view by taking the element out of the DOM, and removing any + // applicable Backbone.Events listeners. remove: function() { - this.dispose(); this.$el.remove(); + this.stopListening(); return this; }, @@ -1460,7 +1432,7 @@ } // Ensure that we have the appropriate request data. - if (options.data == null && model && (method === 'create' || method === 'update')) { + if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { params.contentType = 'application/json'; params.data = JSON.stringify(options.attrs || model.toJSON(options)); } @@ -1473,7 +1445,7 @@ // For older servers, emulate HTTP by mimicking the HTTP method with `_method` // And an `X-HTTP-Method-Override` header. - if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE')) { + if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) { params.type = 'POST'; if (options.emulateJSON) params.data._method = type; var beforeSend = options.beforeSend; diff --git a/vendor/backbone/test/collection.js b/vendor/backbone/test/collection.js index a9e652e243..339a50e8b2 100644 --- a/vendor/backbone/test/collection.js +++ b/vendor/backbone/test/collection.js @@ -386,6 +386,19 @@ $(document).ready(function() { equal(this.syncArgs.options.parse, false); }); + test("ensure fetch only parses once", 1, function() { + var collection = new Backbone.Collection; + var counter = 0; + collection.parse = function(models) { + counter++; + return models; + }; + collection.url = '/test'; + collection.fetch(); + this.syncArgs.options.success([]); + equal(counter, 1); + }); + test("create", 4, function() { var collection = new Backbone.Collection; collection.url = '/test'; @@ -809,7 +822,7 @@ $(document).ready(function() { strictEqual(c.length, 2); // merge: false doesn't change any models - c.update([m1, {id: 2, a: 1}], {merge: false, remove: true}); + c.update([m1, {id: 2, a: 1}], {merge: false}); strictEqual(m2.get('a'), void 0); // add: false, remove: false only merges existing models @@ -819,13 +832,82 @@ $(document).ready(function() { // default options add/remove/merge as appropriate c.update([{id: 2, a: 1}, m3]); - strictEqual(c.length, 3); + strictEqual(c.length, 2); strictEqual(m2.get('a'), 1); // Test removing models not passing an argument - c.off('remove'); - c.update([], {remove: true}); + c.off('remove').on('remove', function(model) { + ok(model === m2 || model === m3); + }); + c.update([]); strictEqual(c.length, 0); }); + test("update with only cids", 3, function() { + var m1 = new Backbone.Model; + var m2 = new Backbone.Model; + var c = new Backbone.Collection; + c.update([m1, m2]); + equal(c.length, 2); + c.update([m1]); + equal(c.length, 1); + c.update([m1, m1, m1, m2, m2], {remove: false}); + equal(c.length, 2); + }); + + test("update with only idAttribute", 3, function() { + var m1 = { _id: 1 }; + var m2 = { _id: 2 }; + var col = Backbone.Collection.extend({ + model: Backbone.Model.extend({ + idAttribute: '_id' + }) + }); + var c = new col; + c.update([m1, m2]); + equal(c.length, 2); + c.update([m1]); + equal(c.length, 1); + c.update([m1, m1, m1, m2, m2], {remove: false}); + equal(c.length, 2); + }); + + test("#1894 - Push should not trigger a sort", 0, function() { + var Collection = Backbone.Collection.extend({ + comparator: 'id', + sort: function() { + ok(false); + } + }); + new Collection().push({id: 1}); + }); + + // test("`update` with non-normal id", function() { + // var Collection = Backbone.Collection.extend({ + // model: Backbone.Model.extend({idAttribute: '_id'}) + // }); + // var collection = new Collection({_id: 1}); + // collection.update([{_id: 1, a: 1}], {add: false}); + // equal(collection.first().get('a'), 1); + // }); + + test("#1894 - `sort` can optionally be turned off", 0, function() { + var Collection = Backbone.Collection.extend({ + comparator: 'id', + sort: function() { ok(true); } + }); + new Collection().add({id: 1}, {sort: false}); + }); + + test("#1915 - `parse` data in the right order in `update`", function() { + var collection = new (Backbone.Collection.extend({ + parse: function (data) { + strictEqual(data.status, 'ok'); + return data.data; + } + })); + var res = {status: 'ok', data:[{id: 1}]} + collection.update(res, {parse: true}); + }); + }); diff --git a/vendor/backbone/test/events.js b/vendor/backbone/test/events.js index 9cb9d8a428..c3f1d61dd0 100644 --- a/vendor/backbone/test/events.js +++ b/vendor/backbone/test/events.js @@ -66,6 +66,25 @@ $(document).ready(function() { equal(obj.counter, 5); }); + test("listenTo and stopListening", 1, function() { + var a = _.extend({}, Backbone.Events); + var b = _.extend({}, Backbone.Events); + a.listenTo(b, 'all', function(){ ok(true); }); + b.trigger('anything'); + a.listenTo(b, 'all', function(){ ok(false); }); + a.stopListening(); + b.trigger('anything'); + }); + + test("listenTo and stopListening with event maps", 1, function() { + var a = _.extend({}, Backbone.Events); + var b = _.extend({}, Backbone.Events); + a.listenTo(b, {change: function(){ ok(true); }}); + b.trigger('change'); + a.listenTo(b, {change: function(){ ok(false); }}); + a.stopListening(); + b.trigger('change'); + }); test("trigger all for each event", 3, function() { var a, b, obj = { counter: 0 }; @@ -227,14 +246,12 @@ $(document).ready(function() { test("once", 2, function() { // Same as the previous test, but we use once rather than having to explicitly unbind var obj = { counterA: 0, counterB: 0 }; - _.extend(obj,Backbone.Events); + _.extend(obj, Backbone.Events); var incrA = function(){ obj.counterA += 1; obj.trigger('event'); }; - var incrB = function(){ obj.counterB += 1 }; + var incrB = function(){ obj.counterB += 1; }; obj.once('event', incrA); obj.once('event', incrB); obj.trigger('event'); - obj.trigger('event'); - obj.trigger('event'); equal(obj.counterA, 1, 'counterA should have only been incremented once.'); equal(obj.counterB, 1, 'counterB should have only been incremented once.'); }); @@ -298,6 +315,14 @@ $(document).ready(function() { equal(obj.counter, 3); }); + test("once with off only by context", 0, function() { + var context = {}; + var obj = _.extend({}, Backbone.Events); + obj.once('event', function(){ ok(false); }, context); + obj.off(null, null, context); + obj.trigger('event'); + }); + test("Backbone object inherits Events", function() { ok(Backbone.on === Backbone.Events.on); }); @@ -310,4 +335,29 @@ $(document).ready(function() { obj.trigger('async'); }); + test("once with multiple events.", 2, function() { + var obj = _.extend({}, Backbone.Events); + obj.once('x y', function() { ok(true); }); + obj.trigger('x y'); + }); + + test("Off during iteration with once.", 2, function() { + var obj = _.extend({}, Backbone.Events); + var f = function(){ this.off('event', f); }; + obj.on('event', f); + obj.once('event', function(){}); + obj.on('event', function(){ ok(true); }); + + obj.trigger('event'); + obj.trigger('event'); + }); + + test("`once` on `all` should work as expected", 1, function() { + Backbone.once('all', function() { + ok(true); + Backbone.trigger('all'); + }); + Backbone.trigger('all'); + }); + }); diff --git a/vendor/backbone/test/model.js b/vendor/backbone/test/model.js index cf2f2bb111..d8e42380d2 100644 --- a/vendor/backbone/test/model.js +++ b/vendor/backbone/test/model.js @@ -55,6 +55,18 @@ $(document).ready(function() { equal(model.get('value'), 2); }); + test("initialize with defaults", 2, function() { + var Model = Backbone.Model.extend({ + defaults: { + first_name: 'Unknown', + last_name: 'Unknown' + } + }); + var model = new Model({'first_name': 'John'}); + equal(model.get('first_name'), 'John'); + equal(model.get('last_name'), 'Unknown'); + }); + test("parse can return null", 1, function() { var Model = Backbone.Model.extend({ parse: function(obj) { @@ -114,7 +126,7 @@ $(document).ready(function() { var foo = new Backbone.Model({p: 1}); var bar = new Backbone.Model({p: 2}); - bar.set(foo.clone(), {unset: true}); + bar.set(foo.clone().attributes, {unset: true}); equal(foo.get('p'), 1); equal(bar.get('p'), undefined); }); @@ -201,6 +213,27 @@ $(document).ready(function() { equal(a.id, undefined, "Unsetting the id should remove the id property."); }); + test("set triggers changes in the correct order", function() { + var value = null; + var model = new Backbone.Model; + model.on('last', function(){ value = 'last'; }); + model.on('first', function(){ value = 'first'; }); + model.trigger('first'); + model.trigger('last'); + equal(value, 'last'); + }); + + test("set falsy values in the correct order", 1, function() { + var model = new Backbone.Model({result: 'result'}); + model.on('change', function() { + equal(model.changed.result, false); + }); + model.set({result: void 0}, {silent: true}); + model.set({result: null}, {silent: true}); + model.set({result: false}, {silent: true}); + model.change(); + }); + test("multiple unsets", 1, function() { var i = 0; var counter = function(){ i++; }; @@ -261,7 +294,7 @@ $(document).ready(function() { }); var model = new Defaulted({two: null}); equal(model.get('one'), 1); - equal(model.get('two'), null); + equal(model.get('two'), 2); Defaulted = Backbone.Model.extend({ defaults: function() { return { @@ -272,7 +305,7 @@ $(document).ready(function() { }); model = new Defaulted({two: null}); equal(model.get('one'), 3); - equal(model.get('two'), null); + equal(model.get('two'), 4); }); test("change, hasChanged, changedAttributes, previous, previousAttributes", 12, function() { @@ -351,17 +384,6 @@ $(document).ready(function() { equal(lastError, "Can't change admin status."); }); - test("isValid", function() { - var model = new Backbone.Model({valid: true}); - model.validate = function(attrs) { - if (!attrs.valid) return "invalid"; - }; - equal(model.isValid(), true); - equal(model.set({valid: false}), false); - equal(model.isValid(), true); - ok(!model.set('valid', false, {silent: true})); - }); - test("save", 2, function() { doc.save({title : "Henry V"}); equal(this.syncArgs.method, 'update'); @@ -379,6 +401,7 @@ $(document).ready(function() { equal(_.size(this.syncArgs.options.attrs), 2); equal(this.syncArgs.options.attrs.d, 4); equal(this.syncArgs.options.attrs.a, undefined); + equal(this.ajaxSettings.data, "{\"b\":2,\"d\":4}"); }); test("save in positional style", 1, function() { @@ -570,9 +593,9 @@ $(document).ready(function() { ok(model.get('x') === a); }); - test("unset fires change for undefined attributes", 1, function() { + test("unset does not fire a change for undefined attributes", 0, function() { var model = new Backbone.Model({x: undefined}); - model.on('change:x', function(){ ok(true); }); + model.on('change:x', function(){ ok(false); }); model.unset('x'); }); @@ -784,12 +807,6 @@ $(document).ready(function() { model.set({a: true}); }); - test("#1179 - isValid returns true in the absence of validate.", 1, function() { - var model = new Backbone.Model(); - model.validate = null; - ok(model.isValid()); - }); - test("#1122 - clear does not alter options.", 1, function() { var model = new Backbone.Model(); var options = {}; diff --git a/vendor/backbone/test/router.js b/vendor/backbone/test/router.js index 923880abc8..50be7effb7 100644 --- a/vendor/backbone/test/router.js +++ b/vendor/backbone/test/router.js @@ -107,7 +107,7 @@ $(document).ready(function() { }, optionalItem: function(arg){ - this.arg = arg !== void 0 ? arg : null; + this.arg = arg != void 0 ? arg : null; }, splat : function(args) { @@ -207,7 +207,7 @@ $(document).ready(function() { test("routes (optional)", 2, function() { location.replace('http://example.com#optional'); Backbone.history.checkUrl(); - equal(router.arg, null); + ok(!router.arg); location.replace('http://example.com#optional/thing'); Backbone.history.checkUrl(); equal(router.arg, 'thing'); diff --git a/vendor/backbone/test/view.js b/vendor/backbone/test/view.js index 400c80eb6d..444d90b2c4 100644 --- a/vendor/backbone/test/view.js +++ b/vendor/backbone/test/view.js @@ -41,7 +41,7 @@ $(document).ready(function() { var div = view.make('div', {id: 'test-div'}, 0); equal($(div).text(), '0'); - var div = view.make('div', {id: 'test-div'}, ''); + div = view.make('div', {id: 'test-div'}, ''); equal($(div).text(), ''); }); @@ -171,7 +171,7 @@ $(document).ready(function() { return { title: 'title1', acceptText: 'confirm' - } + }; } }); @@ -310,14 +310,11 @@ $(document).ready(function() { ok(new View().$el.is('p')); }); - test("dispose", 0, function() { + test("views stopListening", 0, function() { var View = Backbone.View.extend({ - events: { - click: function() { ok(false); } - }, initialize: function() { - this.model.on('all x', function(){ ok(false); }, this); - this.collection.on('all x', function(){ ok(false); }, this); + this.listenTo(this.model, 'all x', function(){ ok(false); }, this); + this.listenTo(this.collection, 'all x', function(){ ok(false); }, this); } }); @@ -326,22 +323,9 @@ $(document).ready(function() { collection: new Backbone.Collection }); - view.dispose(); + view.stopListening(); view.model.trigger('x'); view.collection.trigger('x'); - view.$el.click(); - }); - - test("dispose with non Backbone objects", 0, function() { - var view = new Backbone.View({model: {}, collection: {}}); - view.dispose(); - }); - - test("view#remove calls dispose.", 1, function() { - var view = new Backbone.View(); - - view.dispose = function() { ok(true); }; - view.remove(); }); test("Provide function for el.", 1, function() { @@ -364,16 +348,16 @@ $(document).ready(function() { counter++; } }); - + var view = new View({events:{'click #test':'increment'}}); var view2 = new View({events:function(){ return {'click #test':'increment'}; }}); - + view.$('#test').trigger('click'); view2.$('#test').trigger('click'); equal(counter, 2); - + view.$('#test').trigger('click'); view2.$('#test').trigger('click'); equal(counter, 4); diff --git a/vendor/underscore/underscore-min.js b/vendor/underscore/underscore-min.js index eb4df1b941..f5e1155aed 100644 --- a/vendor/underscore/underscore-min.js +++ b/vendor/underscore/underscore-min.js @@ -1,5 +1 @@ -// Underscore.js 1.4.3 -// http://underscorejs.org -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore may be freely distributed under the MIT license. -(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0==t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=""+ ++N;return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){r=w.defaults({},r,w.templateSettings);var e=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,a,o){return i+=n.slice(u,o).replace(D,function(n){return"\\"+B[n]}),r&&(i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(i+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),a&&(i+="';\n"+a+"\n__p+='"),u=o+t.length,t}),i+="';\n",r.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var a=Function(r.variable||"obj","_",i)}catch(o){throw o.source=i,o}if(t)return a(t,w);var c=function(n){return a.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+i+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file +(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0===t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=""+ ++N;return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){var e;r=w.defaults({},r,w.templateSettings);var u=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,w);var c=function(n){return e.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); \ No newline at end of file diff --git a/vendor/underscore/underscore.js b/vendor/underscore/underscore.js index 4d83099fd9..ac28c6d8ad 100644 --- a/vendor/underscore/underscore.js +++ b/vendor/underscore/underscore.js @@ -594,7 +594,7 @@ // all callbacks defined on an object belong to it. _.bindAll = function(obj) { var funcs = slice.call(arguments, 1); - if (funcs.length == 0) funcs = _.functions(obj); + if (funcs.length === 0) funcs = _.functions(obj); each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); return obj; }; @@ -1075,7 +1075,7 @@ // Useful for temporary DOM ids. var idCounter = 0; _.uniqueId = function(prefix) { - var id = '' + ++idCounter; + var id = '' + (++idCounter); return prefix ? prefix + id : id; }; @@ -1110,6 +1110,7 @@ // Underscore templating handles arbitrary delimiters, preserves whitespace, // and correctly escapes quotes within interpolated code. _.template = function(text, data, settings) { + var render; settings = _.defaults({}, settings, _.templateSettings); // Combine delimiters into one regular expression via alternation. @@ -1148,7 +1149,7 @@ source + "return __p;\n"; try { - var render = new Function(settings.variable || 'obj', '_', source); + render = new Function(settings.variable || 'obj', '_', source); } catch (e) { e.source = source; throw e; From 99686fdd73fcdc9ee616d143b7b896b2409787ed Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 14 Dec 2012 00:41:56 -0800 Subject: [PATCH 29/45] Revert `@license` doc tag addition of #138. Former-commit-id: a66d22c952b3a0bb45e049a80ee80aa54c4e6a33 --- build.js | 4 ++-- build/post-compile.js | 3 +-- lodash.min.js | 1 - lodash.underscore.min.js | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/build.js b/build.js index fdb692ea96..340c0b93bb 100755 --- a/build.js +++ b/build.js @@ -417,7 +417,7 @@ * @returns {String} Returns the modified source. */ function addCommandsToHeader(source, commands) { - return source.replace(/(\/\*!\n)( \*)?( *@license[\s*]+)?( *Lo-Dash [\w.-]+)(.*)/, function() { + return source.replace(/(\/\*!\n)( \*)?( *Lo-Dash [\w.-]+)(.*)/, function() { // convert unmatched groups to empty strings var parts = _.map(slice.call(arguments, 1), function(part) { return part || ''; @@ -439,7 +439,7 @@ // add build commands to copyright/license header return ( parts[0] + - parts[1] + parts[2] + parts[3] + ' (Custom Build)' + parts[4] + '\n' + + parts[1] + parts[2] + ' (Custom Build)' + parts[3] + '\n' + parts[1] + ' Build: `lodash ' + commands.join(' ') + '`' ); }); diff --git a/build/post-compile.js b/build/post-compile.js index ac242eab2e..a77a458c1b 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -9,12 +9,11 @@ var licenseTemplate = { 'lodash': '/*!\n' + - ' @license\n' + ' Lo-Dash <%= VERSION %> lodash.com/license\n' + ' Underscore.js 1.4.3 underscorejs.org/LICENSE\n' + '*/', 'underscore': - '/*! @license Underscore.js <%= VERSION %> underscorejs.org/LICENSE */' + '/*! Underscore.js <%= VERSION %> underscorejs.org/LICENSE */' }; /*--------------------------------------------------------------------------*/ diff --git a/lodash.min.js b/lodash.min.js index a244e73206..bf4f058de0 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,5 +1,4 @@ /*! - @license Lo-Dash 1.0.0-rc.2 lodash.com/license Underscore.js 1.4.3 underscorejs.org/LICENSE */ diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index cc82ef03ee..9f59232403 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -1,5 +1,4 @@ /*! - @license Lo-Dash 1.0.0-rc.2 (Custom Build) lodash.com/license Build: `lodash underscore -m -o ./lodash.underscore.min.js` Underscore.js 1.4.3 underscorejs.org/LICENSE From 8bee3ebd65013cddc4c3b5652867da1d27216c92 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 14 Dec 2012 00:54:36 -0800 Subject: [PATCH 30/45] Update `backbone` method dependencies. Former-commit-id: 1b030f0a7b2f4065ec1dfc9ef911de77ebd7d842 --- build.js | 1 + test/backbone.html | 5 +++++ test/test-build.js | 1 + 3 files changed, 7 insertions(+) diff --git a/build.js b/build.js index 340c0b93bb..95944f97bc 100755 --- a/build.js +++ b/build.js @@ -220,6 +220,7 @@ 'max', 'min', 'mixin', + 'once', 'pick', 'reduce', 'reduceRight', diff --git a/test/backbone.html b/test/backbone.html index 6af89c5bcb..0392a66eb7 100644 --- a/test/backbone.html +++ b/test/backbone.html @@ -29,10 +29,15 @@

Test

); + From 3ffefdf6b57a057ba65ff70ca05931118a1269de Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 16 Dec 2012 01:39:11 -0800 Subject: [PATCH 38/45] Avoid `_.isArray` returning `true` for `arguments` objects in browsers that report `arguments.constructor` as `Array`. Former-commit-id: 9fccc5219e7cb6a007138f1f474d9e68504a0260 --- build.js | 49 +++++++++++++++++++++++++++++++------------- build/pre-compile.js | 2 +- lodash.js | 21 +++++++++++-------- 3 files changed, 48 insertions(+), 24 deletions(-) diff --git a/build.js b/build.js index 95944f97bc..4acaa309c2 100755 --- a/build.js +++ b/build.js @@ -174,7 +174,7 @@ 'hasDontEnumBug', 'isKeysFast', 'objectLoop', - 'noArgsEnum', + 'nonEnumArgs', 'noCharByIndex', 'shadowed', 'top', @@ -903,6 +903,29 @@ return source; } + /** + * Removes all `argsAreObjects` references from `source`. + * + * @private + * @param {String} source The source to process. + * @returns {String} Returns the modified source. + */ + function removeArgsAreObjects(source) { + source = removeVar(source, 'argsAreObjects'); + + // remove `argsAreObjects` from `_.isArray` + source = source.replace(matchFunction(source, 'isArray'), function(match) { + return match.replace(/\(argsAreObjects && *([^)]+)\)/g, '$1'); + }); + + // remove `argsAreObjects` from `_.isEqual` + source = source.replace(matchFunction(source, 'isEqual'), function(match) { + return match.replace(/!argsAreObjects[^:]+:\s*/g, ''); + }); + + return source; + } + /** * Removes all `noArgsClass` references from `source`. * @@ -918,11 +941,6 @@ return match.replace(/ *\|\| *\(noArgsClass *&&[^)]+?\)\)/g, ''); }); - // remove `noArgsClass` from `_.isEqual` - source = source.replace(matchFunction(source, 'isEqual'), function(match) { - return match.replace(/noArgsClass[^:]+:\s*/g, ''); - }); - return source; } @@ -1628,9 +1646,11 @@ ' }' ].join('\n')); - // remove `arguments` object check from `_.isEqual` + // remove `arguments` object and `argsAreObjects` check from `_.isEqual` source = source.replace(matchFunction(source, 'isEqual'), function(match) { - return match.replace(/^ *if *\(.+== argsClass[^}]+}\n/gm, '') + return match + .replace(/^ *if *\(.+== argsClass[^}]+}\n/gm, '') + .replace(/!argsAreObjects[^:]+:\s*/g, ''); }); // remove conditional `charCodeCallback` use from `_.max` and `_.min` @@ -1816,8 +1836,9 @@ }); } else { - source = removeIsArgumentsFallback(source); + source = removeArgsAreObjects(source); source = removeHasObjectSpliceBug(source); + source = removeIsArgumentsFallback(source); } // remove `thisArg` from unexposed `forIn` and `forOwn` @@ -1834,10 +1855,10 @@ } }); - // remove `hasDontEnumBug`, `iteratesOwnLast`, and `noArgsEnum` declarations and assignments + // remove `hasDontEnumBug`, `iteratesOwnLast`, and `nonEnumArgs` declarations and assignments source = source .replace(/^ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/m, '') - .replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var (?:hasDontEnumBug|iteratesOwnLast|noArgsEnum).+\n/g, ''); + .replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var (?:hasDontEnumBug|iteratesOwnLast|nonEnumArgs).+\n/g, ''); // remove `iteratesOwnLast` from `shimIsPlainObject` source = source.replace(matchFunction(source, 'shimIsPlainObject'), function(match) { @@ -2008,7 +2029,7 @@ } if ((source.match(/\bcreateIterator\b/g) || []).length < 2) { source = removeFunction(source, 'createIterator'); - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var noArgsEnum;|.+?noArgsEnum *=.+/g, ''); + source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var nonEnumArgs;|.+?nonEnumArgs *=.+/g, ''); } if (isRemoved(source, 'createIterator', 'bind', 'keys', 'template')) { source = removeVar(source, 'isBindFast'); @@ -2027,8 +2048,8 @@ source = removeVar(source, 'nativeKeys'); source = removeKeysOptimization(source); } - if (!source.match(/var (?:hasDontEnumBug|iteratesOwnLast|noArgsEnum)\b/g)) { - // remove `hasDontEnumBug`, `iteratesOwnLast`, and `noArgsEnum` assignments + if (!source.match(/var (?:hasDontEnumBug|iteratesOwnLast|nonEnumArgs)\b/g)) { + // remove `hasDontEnumBug`, `iteratesOwnLast`, and `nonEnumArgs` assignments source = source.replace(/ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/, ''); } } diff --git a/build/pre-compile.js b/build/pre-compile.js index 67f96e2764..6bcc7ea18f 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -41,7 +41,7 @@ 'hasDontEnumBug', 'isKeysFast', 'objectLoop', - 'noArgsEnum', + 'nonEnumArgs', 'noCharByIndex', 'shadowed', 'top', diff --git a/lodash.js b/lodash.js index 69550026b0..9d32fab230 100644 --- a/lodash.js +++ b/lodash.js @@ -150,20 +150,23 @@ arrayRef.splice.call(hasObjectSpliceBug, 0, 1), hasObjectSpliceBug[0]); /** Detect if an `arguments` object's indexes are non-enumerable (IE < 9) */ - var noArgsEnum = true; + var nonEnumArgs = true; (function() { var props = []; function ctor() { this.x = 1; } ctor.prototype = { 'valueOf': 1, 'y': 1 }; for (var prop in new ctor) { props.push(prop); } - for (prop in arguments) { noArgsEnum = !prop; } + for (prop in arguments) { nonEnumArgs = !prop; } hasDontEnumBug = !/valueOf/.test(props); iteratesOwnLast = props[0] != 'x'; }(1)); - /** Detect if an `arguments` object's [[Class]] is unresolvable (Firefox < 4, IE < 9) */ + /** Detect if `arguments` objects are `Object` objects (all but Opera < 10.5) */ + var argsAreObjects = arguments.constructor == Object; + + /** Detect if `arguments` objects [[Class]] is unresolvable (Firefox < 4, IE < 9) */ var noArgsClass = !isArguments(arguments); /** @@ -375,7 +378,7 @@ // object iteration: // add support for iterating over `arguments` objects if needed - ' <% } else if (noArgsEnum) { %>\n' + + ' <% } else if (nonEnumArgs) { %>\n' + ' var length = iteratee.length; index = -1;\n' + ' if (length && isArguments(iteratee)) {\n' + ' while (++index < length) {\n' + @@ -438,7 +441,7 @@ ' }' + ' <% } %>' + ' <% } %>' + - ' <% if (arrayLoop || noArgsEnum) { %>\n}<% } %>\n' + + ' <% if (arrayLoop || nonEnumArgs) { %>\n}<% } %>\n' + // add code to the bottom of the iteration function '<%= bottom %>;\n' + @@ -660,7 +663,7 @@ 'hasDontEnumBug': hasDontEnumBug, 'isKeysFast': isKeysFast, 'objectLoop': '', - 'noArgsEnum': noArgsEnum, + 'nonEnumArgs': nonEnumArgs, 'noCharByIndex': noCharByIndex, 'shadowed': shadowed, 'top': '', @@ -1202,7 +1205,7 @@ var isArray = nativeIsArray || function(value) { // `instanceof` may cause a memory leak in IE 7 if `value` is a host object // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak - return value instanceof Array || toString.call(value) == arrayClass; + return (argsAreObjects && value instanceof Array) || toString.call(value) == arrayClass; }; /** @@ -1373,8 +1376,8 @@ return false; } // in older versions of Opera, `arguments` objects have `Array` constructors - var ctorA = noArgsClass && isArguments(a) ? Object : a.constructor, - ctorB = noArgsClass && isArguments(b) ? Object : b.constructor; + var ctorA = !argsAreObjects && isArguments(a) ? Object : a.constructor, + ctorB = !argsAreObjects && isArguments(b) ? Object : b.constructor; // non `Object` object instances with different constructors are not equal if (ctorA != ctorB && !( From b847d672ab9bbbd4dbebbb333cd0b637dfe1ba14 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 16 Dec 2012 11:54:04 -0800 Subject: [PATCH 39/45] Bump to v1.0.0-rc.3. Former-commit-id: d00d4d948fc0e2597e4ee2f2d15a9bee2dc27440 --- README.md | 2 +- doc/README.md | 206 +++++++++++++++++++-------------------- lodash.min.js | 76 +++++++-------- lodash.underscore.js | 7 +- lodash.underscore.min.js | 48 ++++----- 5 files changed, 171 insertions(+), 168 deletions(-) diff --git a/README.md b/README.md index a1e5a09bda..11e00f040f 100644 --- a/README.md +++ b/README.md @@ -240,7 +240,7 @@ require({ #### Compatibility Warnings - * Made `_#join', '_#pop', and '_#shift' wrapper methods return unwrapped values + * Made `_#join`, `_#pop`, and `_#shift` wrapper methods return unwrapped values * Made *“Functionsâ€* methods wrapper counterparts return wrapped values * Removed `_.chain` and `_#chain` methods diff --git a/doc/README.md b/doc/README.md index 08f9da9a64..bd0b5bd93a 100644 --- a/doc/README.md +++ b/doc/README.md @@ -186,7 +186,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2714 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2717 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -210,7 +210,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2747 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -235,7 +235,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2779 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2782 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -263,7 +263,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2806 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2809 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -291,7 +291,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2851 "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, passing `true` for `fromIndex` will run a faster binary search. @@ -323,7 +323,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2883 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2886 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -348,7 +348,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2907 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2910 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -372,7 +372,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2960 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2963 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -397,7 +397,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2987 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2990 "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. @@ -426,7 +426,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3017 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3020 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -451,7 +451,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3062 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3065 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -489,7 +489,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3104 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -517,7 +517,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3148 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -561,7 +561,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3177 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3180 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -585,7 +585,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#L3211 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3214 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -624,7 +624,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3270 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3273 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -649,7 +649,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3301 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3304 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -680,7 +680,7 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L275 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L278 "View in source") [Ⓣ][1] Creates a `lodash` object, that wraps the given `value`, to enable method chaining. The chainable wrapper functions are: `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` The non-chainable wrapper functions are: `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values. @@ -698,7 +698,7 @@ Creates a `lodash` object, that wraps the given `value`, to enable method chaini ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4171 "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. @@ -728,7 +728,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4185 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4188 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -749,7 +749,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4202 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4205 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -780,7 +780,7 @@ _([1, 2, 3]).valueOf(); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1950 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1953 "View in source") [Ⓣ][1] Checks if a given `target` element 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. @@ -818,7 +818,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1997 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2000 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is the number of times the key was returned by `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to count by *(e.g. 'length')*. @@ -850,7 +850,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2027 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2030 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -879,7 +879,7 @@ _.every([true, 1, null, 'yes'], Boolean); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2066 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2069 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -908,7 +908,7 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }) ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2110 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2113 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first one the `callback` returns truthy for. The function returns as soon as it finds an acceptable element, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -937,7 +937,7 @@ var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2148 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -969,7 +969,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2190 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2193 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1001,7 +1001,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2223 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2226 "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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1030,7 +1030,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2255 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2258 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1062,7 +1062,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2297 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2300 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, 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)*. @@ -1094,7 +1094,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2343 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2346 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, 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)*. @@ -1120,7 +1120,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2392 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2395 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1151,7 +1151,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2416 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2419 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1181,7 +1181,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2458 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2461 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1212,7 +1212,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#L2496 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2499 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -1238,7 +1238,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2517 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2520 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1262,7 +1262,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2549 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2552 "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. @@ -1292,7 +1292,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2574 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2577 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds 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)*. @@ -1321,7 +1321,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2620 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2623 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1353,7 +1353,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2656 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1377,7 +1377,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2684 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2687 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1415,7 +1415,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3334 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3337 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1443,7 +1443,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3367 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3370 "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 passed to the bound function. @@ -1474,7 +1474,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3397 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3400 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1505,7 +1505,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3443 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3446 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. @@ -1546,7 +1546,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3469 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1573,7 +1573,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3499 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3502 "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. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1599,7 +1599,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3563 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3566 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1624,7 +1624,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3543 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3546 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1651,7 +1651,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3587 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3590 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1677,7 +1677,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3614 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3617 "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. @@ -1703,7 +1703,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3649 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3652 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1730,7 +1730,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3674 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1755,7 +1755,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3724 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3727 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -1791,7 +1791,7 @@ hello(); ### `_.assign(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L810 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L813 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -1819,7 +1819,7 @@ _.assign({ 'name': 'moe' }, { 'age': 40 }); ### `_.clone(value, deep)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1000 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1003 "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. @@ -1855,7 +1855,7 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1098 "View in source") [Ⓣ][1] Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. Note: This function is loosely based on the structured clone algorithm. See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. @@ -1886,7 +1886,7 @@ deep[0] === stooges[0]; ### `_.defaults(object [, default1, default2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1117 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1120 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the `destination` object for all `destination` properties that resolve to `null`/`undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -1912,7 +1912,7 @@ _.defaults(iceCream, { 'flavor': 'vanilla', 'sprinkles': 'rainbow' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L866 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L869 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, 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`. @@ -1948,7 +1948,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L890 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L893 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, 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`. @@ -1976,7 +1976,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1136 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1139 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2003,7 +2003,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1161 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1164 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2028,7 +2028,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1178 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1181 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2052,7 +2052,7 @@ _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L828 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L831 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2079,7 +2079,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1202 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1205 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2106,7 +2106,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1221 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1224 "View in source") [Ⓣ][1] Checks if `value` is a boolean *(`true` or `false`)* value. @@ -2130,7 +2130,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1238 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1241 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2154,7 +2154,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1255 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1258 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2178,7 +2178,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1280 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "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". @@ -2208,7 +2208,7 @@ _.isEmpty(''); ### `_.isEqual(a, b)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1322 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1325 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. @@ -2239,7 +2239,7 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1474 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1477 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. @@ -2275,7 +2275,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1491 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1494 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2299,7 +2299,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1554 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1557 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. @@ -2332,7 +2332,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1576 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1579 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2359,7 +2359,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1593 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1596 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2383,7 +2383,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1521 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1524 "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('')`)* @@ -2413,7 +2413,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1621 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1624 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2448,7 +2448,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1646 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1649 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2472,7 +2472,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1663 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1666 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2496,7 +2496,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1680 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1683 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2520,7 +2520,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1700 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2544,7 +2544,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1735 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1738 "View in source") [Ⓣ][1] Merges enumerable properties of the source object(s) into the `destination` object. Subsequent sources will overwrite propery assignments of previous sources. @@ -2579,7 +2579,7 @@ _.merge(stooges, ages); ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1809 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1812 "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 `callback` is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2610,7 +2610,7 @@ _.omit({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1843 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1846 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -2634,7 +2634,7 @@ _.pairs({ 'moe': 30, 'larry': 40, 'curly': 50 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1876 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1879 "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 `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -2665,7 +2665,7 @@ _.pick({ 'name': 'moe', '_hint': 'knucklehead', '_seed': '96c4eb' }, function(va ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1913 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1916 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -2696,7 +2696,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3748 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3751 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2720,7 +2720,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3766 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3769 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2745,7 +2745,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3795 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2775,7 +2775,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3818 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3821 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2795,7 +2795,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3841 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3844 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2823,7 +2823,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3882 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2858,7 +2858,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3964 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3967 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html @@ -2932,7 +2932,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4098 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -2964,7 +2964,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4121 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4124 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -2988,7 +2988,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4141 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4144 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3022,7 +3022,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4369 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3034,7 +3034,7 @@ _.uniqueId(); ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L296 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L299 "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. @@ -3046,7 +3046,7 @@ _.uniqueId(); ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L305 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L308 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3058,7 +3058,7 @@ _.uniqueId(); ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L317 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3070,7 +3070,7 @@ _.uniqueId(); ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L323 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L326 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3082,7 +3082,7 @@ _.uniqueId(); ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L332 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L335 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. diff --git a/lodash.min.js b/lodash.min.js index 4b33a77d7a..35546e9954 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -2,41 +2,41 @@ Lo-Dash 1.0.0-rc.3 lodash.com/license Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(e,t){function s(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof s))return new s(e);this.__wrapped__=e}function o(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||it);if(i)for(var s={},n=t-1;++nt||"undefined"==typeof e)return 1;if( -ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t",Function("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(l,Tt,y,L,sn -,_t,Ct)}function h(e){return"\\"+on[e]}function p(e){return dn[e]}function d(e){return"function"!=typeof e.toString&&"string"==typeof (e+"")}function v(){}function m(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Dt(0,s+n):n)||0;return"number"==typeof s?o=-1<(L(e)?e.indexOf(t,n):W(e,t,n)):ln(e,function(e){if(++r>=n)return!(o=e===t)}),o}function _(e,t,r){var i=n,t=l(t,r);if(gn(e))for(var r=-1,s=e.length;++rr&&(r=n,o=e)});else for(;++io&&(o=e[i]);return o}function F(e,t){return B(e,t+"")}function I(e,t,n,r){var s=3>arguments.length,t=l(t,r,rt);if(gn(e)){var o=-1,u=e.length;for(s&&(n=e[++o]);++oarguments.length;if("number"!=typeof o)var a=bn(e),o=a.length;else Zt&&L(e)&&(s=e.split(""));return t=l(t,r,rt),H(e,function(e,r,f){r=a?a[--o]:--o,n=u?(u=i,s[r]):t(n,s[r],r,f)}),n}function R(e,t,n){var r,t=l(t,n);if(gn(e))for(var n=-1,i=e.length;++nn?Dt(0,i+n):n||0)-1;else if(n)return r=V(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])W(a,h))(n||f)&&a.push(h),u.push(r)}return u}function J(e,t){return Vt||Lt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ut=/&(?:amp|lt|gt|quot|#x27);/g,at=/\b__p\+='';/g,ft=/\b(__p\+=)''\+/g,lt=/(__e\(.*?\)|\b__t\))\+'';/g,ct=/\w*$/,ht=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,pt=RegExp("^"+(tt.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g -,".+?")+"$"),dt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,vt=/<%=([\s\S]+?)%>/g,mt=/($^)/,gt=/[&<>"']/g,yt=/['\n\r\t\u2028\u2029\\]/g,bt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),wt=Math.ceil,Et=et.concat,St=Math.floor,xt=pt.test(xt=Object.getPrototypeOf)&&xt,Tt=tt.hasOwnProperty,Nt=et.push,Ct=tt.propertyIsEnumerable,kt=tt.toString,Lt=pt.test(Lt=m.bind)&&Lt,At=pt.test(At=Array.isArray)&&At,Ot=e.isFinite,Mt=e.isNaN,_t=pt.test(_t=Object.keys)&& -_t,Dt=Math.max,Pt=Math.min,Ht=Math.random,Bt="[object Arguments]",jt="[object Array]",Ft="[object Boolean]",It="[object Date]",qt="[object Number]",Rt="[object Object]",Ut="[object RegExp]",zt="[object String]",Wt=!!e.attachEvent,Xt=Lt&&!/\n|true/.test(Lt+Wt),Vt=Lt&&!Xt,$t=_t&&(Wt||Xt),Jt,Kt,Qt=(Qt={0:1,length:1},et.splice.call(Qt,0,1),Qt[0]),Gt=n;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Gt=!n;Jt=!/valueOf/.test(t),Kt="x"!= -t[0]})(1);var Yt=!y(arguments),Zt="xx"!="x"[0]+Object("x")[0];try{var en=("[object Object]",kt.call(document)==Rt)}catch(tn){}var nn={"[object Function]":i};nn[Bt]=nn[jt]=nn[Ft]=nn[It]=nn[qt]=nn[Rt]=nn[Ut]=nn[zt]=n;var rn={};rn[jt]=Array,rn[Ft]=Boolean,rn[It]=Date,rn[Rt]=Object,rn[qt]=Number,rn[Ut]=RegExp,rn[zt]=String;var sn={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},on={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape -:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:vt,variable:""};var un={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'" -},vn=x(dn),mn=c(un,{g:"if(t[i]==null)"+un.g}),gn=At||function(e){return e instanceof Array||kt.call(e)==jt};N(/x/)&&(N=function(e){return e instanceof Function||"[object Function]"==kt.call(e)});var yn=xt?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=xt(t))&&xt(n);return n?e==n||xt(e)==n&&!y(e):b(e)}:b,bn=_t?function(e){return"function"==typeof e&&Ct.call(e,"prototype")?w(e):C(e)?_t(e):[]}:w;s.after=function(e,t){return 1>e?t():function(){if(1>--e)return t -.apply(this,arguments)}},s.assign=cn,s.bind=J,s.bindAll=function(e){for(var t=arguments,n=1W(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(r[h]||(r[h]=o(t[h],0,100)))(l))continue e;a.push(l)}}return a},s.invert=x,s.invoke=function(e,t){var n=m(arguments,2),r="function"==typeof t,i=[];return H(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},s.keys=bn,s.map=B,s.max=j,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Tt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.merge= -A,s.min=function(e,t,n){var r=Infinity,i=-1,s=e?e.length:0,o=r;if(t||!gn(e))t=!t&&L(e)?u:l(t,n),ln(e,function(e,n,i){n=t(e,n,i),nW(s,n,1))i[n]=e}),i},s.once=function(e){var t,s=i;return function( -){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},s.pairs=function(e){var t=[];return pn(e,function(e,n){t.push([n,e])}),t},s.partial=function(e){return f(e,m(arguments,1))},s.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=Et.apply(et,arguments),o=s.length;++i=l?(clearTimeout(u),u=r,a=f,s=e.apply(o,i)):u||(u=setTimeout(n,l)),s}},s.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Dt(0,r+n):Pt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s. -mixin=Q,s.noConflict=function(){return e._=st,this},s.random=function(e,t){return e==r&&t==r&&(t=1),e=+e||0,t==r&&(t=e,e=0),e+St(Ht()*((+t||0)-e+1))},s.reduce=I,s.reduceRight=q,s.result=function(e,t){var n=e?e[t]:r;return N(n)?e[t]():n},s.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:bn(e).length},s.some=R,s.sortedIndex=V,s.template=function(e,t,n){e||(e=""),n||(n={});var r,i,o=s.templateSettings,u=0,a=n.interpolate||o.interpolate||mt,f="__p+='",l=n.variable||o.variable,c=l;e.replace -(RegExp((n.escape||o.escape||mt).source+"|"+a.source+"|"+(a===vt?dt:mt).source+"|"+(n.evaluate||o.evaluate||mt).source+"|$","g"),function(t,n,i,s,o,a){return i||(i=s),f+=e.slice(u,a).replace(yt,h),n&&(f+="'+__e("+n+")+'"),o&&(f+="';"+o+";__p+='"),i&&(f+="'+((__t=("+i+"))==null?'':__t)+'"),r||(r=o||ot.test(n||i)),u=a+t.length,t}),f+="';\n",c||(l="obj",r?f="with("+l+"){"+f+"}":(n=RegExp("(\\(\\s*)"+l+"\\."+l+"\\b","g"),f=f.replace(ht,"$&"+l+".").replace(n,"$1__d"))),f=(r?f.replace(at,""):f).replace -(ft,"$1").replace(lt,"$1;"),f="function("+l+"){"+(c?"":l+"||("+l+"={});")+"var __t,__p='',__e=_.escape"+(r?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(c?"":",__d="+l+"."+l+"||"+l)+";")+f+"return __p}";try{i=Function("_","return "+f)(s)}catch(p){throw p.source=f,p}return t?i(t):(i.source=f,i)},s.unescape=function(e){return e==r?"":(e+"").replace(ut,g)},s.uniqueId=function(e){return(e==r?"":e+"")+ ++nt},s.all=_,s.any=R,s.detect=P,s.foldl=I,s.foldr=q,s.include=M,s.inject= -I,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(){var t=[this.__wrapped__];return Nt.apply(t,arguments),e.apply(s,t)})}),s.first=U,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:m(e,Dt(0,i-t))}},s.take=U,s.head=U,pn(s,function(e,t){s.prototype[t]||(s.prototype[t]=function(t,n){var i=e(this.__wrapped__,t,n);return t==r||n?i:new s(i)})}),s.VERSION="1.0.0-rc.3",s.prototype.toString=function(){return this.__wrapped__+""},s.prototype.value=G,s.prototype.valueOf=G,ln(["join" -,"pop","shift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),ln(["push","reverse","sort","unshift"],function(e){var t=et[e];s.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),ln(["concat","slice","splice"],function(e){var t=et[e];s.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new s(e)}}),Qt&&ln(["shift","splice"],function(e){var t=s.prototype[e];s.prototype[e]=function(){var e=this.__wrapped__ -,n=t.apply(this,arguments);return 0===e.length&&delete e[0],n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):Y?"object"==typeof module&&module&&module.exports==Y?(module.exports=s)._=s:Y._=s:e._=s})(this); \ No newline at end of file +;(function(e,t){function n(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||tt);if(i)for(var s={},n=t-1;++nt||"undefined"==typeof e)return 1;if( +ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" +,n("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(u,Et,v,N,nn,At,xt)}function f(e){return"\\"+rn[e]}function l(e){return hn[e]}function c(e){return"function"!=typeof e.toString&&"string"==typeof (e+"")}function h(){}function p(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Ot(0,i+n):n)||0;return"number"==typeof i?s=-1<(N(e)?e.indexOf(t,n):R(e,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s}function A( +e,t,n){var r=!0,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments.length,t=u(t,r,et);if(vn(e)){var s=-1 +,o=e.length;for(i&&(n=e[++s]);++sarguments.length;if("number"!=typeof s)var a=gn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g +,lt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable,Tt=Y.toString,Nt=lt.test(Nt= +p.bind)&&Nt,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e(){this.x=1}var t=[];e.prototype= +{valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean":!1,"function":!0,object:!0, +number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},pn=w(hn),dn=a(sn,{g:"if(t[i]==null)"+sn.g}),vn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var mn=wt?function(e){if(!e||"object"!=typeof e)return!1;var t=e.valueOf,n="function"==typeof t&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e) +}:m,gn=At?function(e){return"function"==typeof e&&xt.call(e,"prototype")?g(e):x(e)?At(e):[]}:g;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r="function"==typeof t,i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=gn,n.map=D, +n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!vn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return cn(e,function(e,n){t.push([n,e])}),t},n.partial=function(e){return o(e,p(arguments,1))},n.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=yt.apply(G,arguments),o=s.length;++i=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof +t?t:gn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i||( +i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source=l,p +}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]||(n +.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice" +],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?"object"==typeof module&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 3c88d95f83..c060e43639 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -133,6 +133,9 @@ var hasObjectSpliceBug = (hasObjectSpliceBug = { '0': 1, 'length': 1 }, arrayRef.splice.call(hasObjectSpliceBug, 0, 1), hasObjectSpliceBug[0]); + /** Detect if `arguments` objects are `Object` objects (all but Opera < 10.5) */ + var argsAreObjects = arguments.constructor == Object; + /** * Detect lack of support for accessing string characters by index: * @@ -435,7 +438,7 @@ 'bottom': '', 'hasDontEnumBug': hasDontEnumBug, 'objectLoop': '', - 'noArgsEnum': noArgsEnum, + 'nonEnumArgs': nonEnumArgs, 'noCharByIndex': noCharByIndex, 'shadowed': shadowed, 'top': '', @@ -935,7 +938,7 @@ var isArray = nativeIsArray || function(value) { // `instanceof` may cause a memory leak in IE 7 if `value` is a host object // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak - return value instanceof Array || toString.call(value) == arrayClass; + return (argsAreObjects && value instanceof Array) || toString.call(value) == arrayClass; }; /** diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index f711b989d2..61c5f61898 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -4,30 +4,30 @@ Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(e,t){function n(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||"undefined"==typeof e)return 1;if(en?0:n);++rn?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,V);if(At(e)) -{var o=-1,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if("number"!=typeof i)var u=Ot(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(At(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])r&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,V);if(Ot(e)) +{var o=-1,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if("number"!=typeof i)var u=Mt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st=f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite -,at=e.isNaN,ft=K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},xt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings= -{escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Tt=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++n":">",'"':""","'":"'"},Lt=v(kt),At=ot||function(e){return e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Ot=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply -(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i} -,n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))continue e;s.push(o)}}return s},n.invert=v,n.invoke=function(e,t){var n=f -(arguments,2),r="function"==typeof t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Ot,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!At(e))t=s(t,n),Tt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return Ct(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e -._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Ot(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$" -,"g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null==e?"":(e+"").replace(J,l)},n.uniqueId= -function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Tt("pop push reverse shift sort splice unshift".split(" "),function(e){var t=W -[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Tt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?"object"==typeof module&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file +,at=e.isNaN,ft=K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028" +,"\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++n":">",'"':""","'":"'"},At=v(Lt),Ot=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Mt=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t) +{return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))continue e;s.push(o)}} +return s},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Mt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Ot(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return kt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if( +e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Mt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape|| +Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n. +unescape=function(e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift" +.split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?"object"==typeof module&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file From a45499cf0466f88525ba96f3c3dcb60fbbd3f76a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 16 Dec 2012 14:47:00 -0800 Subject: [PATCH 40/45] Cleanup build.js and README.md. Former-commit-id: abf5c3e3f1b0a04b8f9eeb132366f51c92c9a450 --- README.md | 2 +- build.js | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 11e00f040f..9d6c4893b8 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ For more information check out these screencasts over Lo-Dash: ## Features * AMD loader support ([RequireJS](http://requirejs.org/), [curl.js](https://github.com/cujojs/curl), etc.) - * [_(…)](http://lodash.com/docs#_) supports intuitive chaining without calling [_(…).chain](http://lodash.com/docs#prototype_chain) + * [_(…)](http://lodash.com/docs#_) supports intuitive chaining * [_.bindKey](http://lodash.com/docs#bindKey) for binding [*“lazyâ€* defined](http://michaux.ca/articles/lazy-function-definition-pattern) methods * [_.cloneDeep](http://lodash.com/docs#cloneDeep) for *“deepâ€* cloning arrays and objects * [_.contains](http://lodash.com/docs#contains) accepts a `fromIndex` argument diff --git a/build.js b/build.js index 4acaa309c2..899d190a8b 100755 --- a/build.js +++ b/build.js @@ -2013,6 +2013,7 @@ } if (isRemoved(source, 'isPlainObject')) { source = removeVar(source, 'getPrototypeOf'); + source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, ''); } if (isRemoved(source, 'keys')) { source = removeFunction(source, 'shimKeys'); @@ -2029,6 +2030,7 @@ } if ((source.match(/\bcreateIterator\b/g) || []).length < 2) { source = removeFunction(source, 'createIterator'); + source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasDontEnumBug;|.+?hasDontEnumBug *=.+/g, ''); source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var nonEnumArgs;|.+?nonEnumArgs *=.+/g, ''); } if (isRemoved(source, 'createIterator', 'bind', 'keys', 'template')) { @@ -2038,12 +2040,6 @@ if (isRemoved(source, 'createIterator', 'bind', 'isArray', 'isPlainObject', 'keys', 'template')) { source = removeVar(source, 'reNative'); } - if (isRemoved(source, 'createIterator', 'isEqual')) { - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var hasDontEnumBug;|.+?hasDontEnumBug *=.+/g, ''); - } - if (isRemoved(source, 'createIterator', 'isPlainObject')) { - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var iteratesOwnLast;|.+?iteratesOwnLast *=.+/g, ''); - } if (isRemoved(source, 'createIterator', 'keys')) { source = removeVar(source, 'nativeKeys'); source = removeKeysOptimization(source); From 04a568ac9b9a7194d78d8498fe487bbe2238749f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 16 Dec 2012 21:40:29 -0800 Subject: [PATCH 41/45] Update vendors and docs. [ci skip] Former-commit-id: 9ca377423f4714fdf0e3fa428711e8dfe75e2e44 --- doc/README.md | 28 +++++++++++++++++++++++----- vendor/benchmark.js/benchmark.js | 3 +++ vendor/docdown/src/DocDown/Entry.php | 5 ++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/doc/README.md b/doc/README.md index bd0b5bd93a..e0d688be84 100644 --- a/doc/README.md +++ b/doc/README.md @@ -682,7 +682,15 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); ### `_(value)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L278 "View in source") [Ⓣ][1] -Creates a `lodash` object, that wraps the given `value`, to enable method chaining. The chainable wrapper functions are: `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` The non-chainable wrapper functions are: `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values. +Creates a `lodash` object, that wraps the given `value`, to enable method chaining. + +The chainable wrapper functions are:
+`after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` + +The non-chainable wrapper functions are:
+`clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, and `uniqueId` + +The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values. #### Arguments 1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. @@ -1857,7 +1865,9 @@ deep[0] === stooges[0]; ### `_.cloneDeep(value)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1098 "View in source") [Ⓣ][1] -Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. Note: This function is loosely based on the structured clone algorithm. See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. +Creates a deep clone of `value`. Functions and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and objects created by constructors other than `Object` are cloned to plain `Object` objects. + +Note: This function is loosely based on the structured clone algorithm. See http://www.w3.org/TR/html5/common-dom-interfaces.html#internal-structured-cloning-algorithm. #### Arguments 1. `value` *(Mixed)*: The value to deep clone. @@ -2241,7 +2251,9 @@ _.isEqual(moe, clone); ### `_.isFinite(value)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1477 "View in source") [Ⓣ][1] -Checks if `value` is, or can be coerced to, a finite number. Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. +Checks if `value` is, or can be coerced to, a finite number. + +Note: This is not the same as native `isFinite`, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5. #### Arguments 1. `value` *(Mixed)*: The value to check. @@ -2301,7 +2313,9 @@ _.isFunction(_); ### `_.isNaN(value)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1557 "View in source") [Ⓣ][1] -Checks if `value` is `NaN`. Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. +Checks if `value` is `NaN`. + +Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.com/#x15.1.2.4. #### Arguments 1. `value` *(Mixed)*: The value to check. @@ -2860,7 +2874,11 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3967 "View in source") [Ⓣ][1] -A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html +A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. + +Note: In the development build `_.template` utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl + +Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp` build and avoiding `_.template` use, or loading Lo-Dash in a sandboxed page. See http://developer.chrome.com/trunk/extensions/sandboxingEval.html #### Arguments 1. `text` *(String)*: The template text. diff --git a/vendor/benchmark.js/benchmark.js b/vendor/benchmark.js/benchmark.js index 5b63f8baa0..fe5ff3db06 100644 --- a/vendor/benchmark.js/benchmark.js +++ b/vendor/benchmark.js/benchmark.js @@ -25,6 +25,9 @@ /** Detect free variable `require` */ var freeRequire = typeof require == 'function' && require; + /** Used to store the `Object` built-in in case it's overwritten later */ + var Object = window.Object; + /** Used to crawl all properties regardless of enumerability */ var getAllKeys = Object.getOwnPropertyNames; diff --git a/vendor/docdown/src/DocDown/Entry.php b/vendor/docdown/src/DocDown/Entry.php index 933bf4005d..e545d33607 100644 --- a/vendor/docdown/src/DocDown/Entry.php +++ b/vendor/docdown/src/DocDown/Entry.php @@ -187,7 +187,10 @@ public function getDesc() { preg_match('#/\*\*(?:\s*\*)?([\s\S]*?)(?=\*\s\@[a-z]|\*/)#', $this->entry, $result); if (count($result)) { $type = $this->getType(); - $result = trim(preg_replace('/(?:^|\n)\s*\* ?/', ' ', $result[1])); + $result = preg_replace('/:\n *\* */', ":
\n", $result[1]); + $result = preg_replace('/(?:^|\n) *\*\n *\* */', "\n\n", $result); + $result = preg_replace('/(?:^|\n) *\* ?/', ' ', $result); + $result = trim($result); $result = ($type == 'Function' ? '' : '(' . str_replace('|', ', ', trim($type, '{}')) . '): ') . $result; } $this->_desc = $result; From 73d95de122e1276c037178b5360a31bc11b3970d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 17 Dec 2012 00:06:59 -0800 Subject: [PATCH 42/45] Reduce `_.forEach` and optimize the minified builds for Safari. Former-commit-id: d4366f1a3c5fd0751558f714384600c3bcf0f49b --- build.js | 6 ++ doc/README.md | 118 +++++++++++++++++++-------------------- lodash.js | 5 +- lodash.min.js | 58 +++++++++---------- lodash.underscore.js | 5 +- lodash.underscore.min.js | 44 +++++++-------- 6 files changed, 118 insertions(+), 118 deletions(-) diff --git a/build.js b/build.js index 899d190a8b..7a1d49fdcc 100755 --- a/build.js +++ b/build.js @@ -2088,6 +2088,12 @@ 'isTemplate': isTemplate, 'outputPath': outputPath, 'onComplete': function(source) { + // replace `!1` with `false` and `!0` with `true` to help + // optimize Safari when used in a loop + source = source + .replace(/!1([!=]==?[a-z])/g, 'false$1') + .replace(/!0([!=]==?[a-z])/g, 'true$1') + // inject "use strict" directive if (isStrict) { source = source.replace(/^([\s\S]*?function[^{]+{)([^"'])/, '$1"use strict";$2'); diff --git a/doc/README.md b/doc/README.md index e0d688be84..1341019713 100644 --- a/doc/README.md +++ b/doc/README.md @@ -186,7 +186,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2717 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2714 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -210,7 +210,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2747 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2744 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -235,7 +235,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2782 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2779 "View in source") [Ⓣ][1] Gets the first element of the `array`. Pass `n` to return the first `n` elements of the `array`. @@ -263,7 +263,7 @@ _.first([5, 4, 3, 2, 1]); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2809 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2806 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -291,7 +291,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2851 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2848 "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, passing `true` for `fromIndex` will run a faster binary search. @@ -323,7 +323,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2886 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2883 "View in source") [Ⓣ][1] Gets all but the last element of `array`. Pass `n` to exclude the last `n` elements from the result. @@ -348,7 +348,7 @@ _.initial([3, 2, 1]); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2910 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2907 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -372,7 +372,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, n])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2963 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2960 "View in source") [Ⓣ][1] Gets the last element of the `array`. Pass `n` to return the last `n` elements of the `array`. @@ -397,7 +397,7 @@ _.last([3, 2, 1]); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2990 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2987 "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. @@ -426,7 +426,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3020 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3017 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -451,7 +451,7 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3065 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3062 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `stop`. This method is a port of Python's `range()` function. See http://docs.python.org/library/functions.html#range. @@ -489,7 +489,7 @@ _.range(0); ### `_.rest(array [, n=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3104 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3101 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. Pass `n` to exclude the first `n` values from the result. @@ -517,7 +517,7 @@ _.rest([3, 2, 1]); ### `_.sortedIndex(array, value [, callback=identity|property, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3148 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3145 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. The `callback` argument may also be the name of a property to order by. @@ -561,7 +561,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3180 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3177 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -585,7 +585,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#L3214 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3211 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -624,7 +624,7 @@ _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3273 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3270 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -649,7 +649,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3304 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3301 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -706,7 +706,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4171 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4168 "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. @@ -736,7 +736,7 @@ _.chain([1, 2, 3, 200]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4188 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4185 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -757,7 +757,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4205 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4202 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -977,7 +977,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2193 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2190 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of `collection` through a `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to group by *(e.g. 'length')*. @@ -1009,7 +1009,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2226 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2223 "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 passed to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1038,7 +1038,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2255 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1070,7 +1070,7 @@ _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); ### `_.max(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2300 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2297 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, 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)*. @@ -1102,7 +1102,7 @@ _.max(stooges, function(stooge) { return stooge.age; }); ### `_.min(collection [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2346 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2343 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, 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)*. @@ -1128,7 +1128,7 @@ _.min([10, 5, 100, 2, 1000]); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2395 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2392 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1159,7 +1159,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2419 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2416 "View in source") [Ⓣ][1] Boils down a `collection` to a single value. The initial state of the reduction is `accumulator` and each successive step of it should be returned by the `callback`. The `callback` is bound to `thisArg` and invoked with `4` arguments; for arrays they are *(accumulator, value, index|key, collection)*. @@ -1189,7 +1189,7 @@ var sum = _.reduce([1, 2, 3], function(memo, num) { return memo + num; }); ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2461 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2458 "View in source") [Ⓣ][1] The right-associative version of `_.reduce`. @@ -1220,7 +1220,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#L2499 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2496 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the values of a `collection` that `callback` does **not** return truthy for. @@ -1246,7 +1246,7 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2520 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2517 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1270,7 +1270,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2552 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2549 "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. @@ -1300,7 +1300,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2577 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2574 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds 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)*. @@ -1329,7 +1329,7 @@ _.some([null, 0, 'yes', false], Boolean); ### `_.sortBy(collection, callback|property [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2623 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2620 "View in source") [Ⓣ][1] Creates an array, stable sorted in ascending order by the results of running each element of `collection` through a `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. The `callback` argument may also be the name of a property to sort by *(e.g. 'length')*. @@ -1361,7 +1361,7 @@ _.sortBy(['larry', 'brendan', 'moe'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2656 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2653 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1385,7 +1385,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2687 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2684 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that contain the given `properties`. @@ -1423,7 +1423,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3337 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3334 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1451,7 +1451,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3370 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3367 "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 passed to the bound function. @@ -1482,7 +1482,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3400 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3397 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. If no method names are provided, all the function properties of `object` will be bound. @@ -1513,7 +1513,7 @@ jQuery('#lodash_button').on('click', buttonView.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3446 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3443 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed 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. @@ -1554,7 +1554,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3469 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3466 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1581,7 +1581,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3502 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3499 "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. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1607,7 +1607,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3566 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3563 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1632,7 +1632,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3546 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3543 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1659,7 +1659,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3590 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3587 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -1685,7 +1685,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3617 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3614 "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. @@ -1711,7 +1711,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3652 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3649 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `bind`, except it does **not** alter the `this` binding. @@ -1738,7 +1738,7 @@ hi('moe'); ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3674 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3671 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -1763,7 +1763,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3727 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3724 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2710,7 +2710,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3751 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3748 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -2734,7 +2734,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3769 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3766 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -2759,7 +2759,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3795 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3792 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -2789,7 +2789,7 @@ _('curly').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3821 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3818 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -2809,7 +2809,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3844 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3841 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -2837,7 +2837,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3882 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3879 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -2872,7 +2872,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3967 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3964 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -2950,7 +2950,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4098 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4095 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -2982,7 +2982,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4124 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4121 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3006,7 +3006,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4144 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4141 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3040,7 +3040,7 @@ _.uniqueId(); ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4369 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4366 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 9d32fab230..f4a8bb12db 100644 --- a/lodash.js +++ b/lodash.js @@ -2146,13 +2146,10 @@ * // => alerts each number value (order is not guaranteed) */ function forEach(collection, callback, thisArg) { - if (isArray(collection)) { + if (callback && typeof thisArg == 'undefined' && isArray(collection)) { var index = -1, length = collection.length; - if (!callback || typeof thisArg != 'undefined') { - callback = createCallback(callback, thisArg); - } while (++index < length) { if (callback(collection[index], index, collection) === false) { break; diff --git a/lodash.min.js b/lodash.min.js index 35546e9954..f8444b5e4a 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -7,36 +7,36 @@ ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" ,n("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(u,Et,v,N,nn,At,xt)}function f(e){return"\\"+rn[e]}function l(e){return hn[e]}function c(e){return"function"!=typeof e.toString&&"string"==typeof (e+"")}function h(){}function p(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?Ot(0,i+n):n)||0;return"number"==typeof i?s=-1<(N(e)?e.indexOf(t,n):R(e,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s}function A( -e,t,n){var r=!0,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments.length,t=u(t,r,et);if(vn(e)){var s=-1 -,o=e.length;for(i&&(n=e[++s]);++sarguments.length;if("number"!=typeof s)var a=gn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g -,lt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable,Tt=Y.toString,Nt=lt.test(Nt= -p.bind)&&Nt,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e(){this.x=1}var t=[];e.prototype= -{valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean":!1,"function":!0,object:!0, -number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},pn=w(hn),dn=a(sn,{g:"if(t[i]==null)"+sn.g}),vn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var mn=wt?function(e){if(!e||"object"!=typeof e)return!1;var t=e.valueOf,n="function"==typeof t&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e) -}:m,gn=At?function(e){return"function"==typeof e&&xt.call(e,"prototype")?g(e):x(e)?At(e):[]}:g;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r="function"==typeof t,i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=gn,n.map=D, -n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!vn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return cn(e,function(e,n){t.push([n,e])}),t},n.partial=function(e){return o(e,p(arguments,1))},n.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=yt.apply(G,arguments),o=s.length;++i=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof -t?t:gn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i||( -i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source=l,p -}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]||(n -.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice" -],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?"object"==typeof module&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this); \ No newline at end of file +e,t,n){var r=!0,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments.length,t=u(t,r,et);if(vn(e)){var s=-1,o=e.length;for(i&& +(n=e[++s]);++sarguments.length;if("number"!=typeof s)var a=gn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,lt=RegExp +("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable,Tt=Y.toString,Nt=lt.test(Nt=p.bind)&&Nt +,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1 +,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean":!1,"function":!0,object:!0,number:!1, +string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},pn=w(hn),dn=a(sn,{g:"if(t[i]==null)"+sn.g}),vn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var mn=wt?function(e){if(!e||"object"!=typeof e)return!1;var t=e.valueOf,n="function"==typeof t&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e)}:m,gn=At? +function(e){return"function"==typeof e&&xt.call(e,"prototype")?g(e):x(e)?At(e):[]}:g;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r="function"==typeof t,i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=gn,n.map=D,n.max=P,n.memoize= +function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!vn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return cn(e,function(e,n){t.push([n,e])}),t},n.partial=function(e){return o(e,p(arguments,1))},n.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=yt.apply(G,arguments),o=s.length;++i=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:gn( +e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i||(i=o||rt +.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source=l,p}return t? +s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]||(n.prototype +[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice"],function( +e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?"object"==typeof module&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index c060e43639..a68dd807b9 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -1725,13 +1725,10 @@ * // => alerts each number value (order is not guaranteed) */ function forEach(collection, callback, thisArg) { - if (isArray(collection)) { + if (callback && typeof thisArg == 'undefined' && isArray(collection)) { var index = -1, length = collection.length; - if (!callback || typeof thisArg != 'undefined') { - callback = createCallback(callback, thisArg); - } while (++index < length) { if (callback(collection[index], index, collection) === indicatorObject) { break; diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 61c5f61898..b349c9d041 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -8,26 +8,26 @@ for(var i in r)e[i]=r[i]}return e}function h(e){var t=[];return kt(e,function(e,n){t.push(n)}),t}function p(e){if(!e)return e;for(var t=1,n=arguments.length;tr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,V);if(Ot(e)) -{var o=-1,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if("number"!=typeof i)var u=Mt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st=f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite -,at=e.isNaN,ft=K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028" -,"\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++n":">",'"':""","'":"'"},At=v(Lt),Ot=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Mt=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t) -{return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))continue e;s.push(o)}} -return s},n.invert=v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Mt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Ot(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return kt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if( -e[r]===t)return r;return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Mt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape|| -Q).source+"|"+(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n. -unescape=function(e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift" +{return(n=e===t)&&V}),n}function x(e,t,n){var r=!0,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++nr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,V);if(Ot(e)){var o=-1 +,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if("number"!=typeof i)var u=Mt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st=f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite,at=e.isNaN,ft= +K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029" +:"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++n":">",'"':""","'":"'"},At=v(Lt),Ot=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Mt=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t){return 1> +e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))continue e;s.push(o)}}return s},n.invert= +v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Mt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Ot(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return kt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1 +},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Mt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate|| +Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null== +e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift" .split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?"object"==typeof module&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file From 3ef51d7faeb5f6b4a5dfae51ab18bb6bf21c6c37 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 17 Dec 2012 00:38:49 -0800 Subject: [PATCH 43/45] Refactor previous commit. Former-commit-id: ad5408ad8a9e5b2caa9667994fe6748760b40fbe --- build.js | 6 ---- build/post-compile.js | 10 ++++-- lodash.min.js | 68 ++++++++++++++++++++-------------------- lodash.underscore.min.js | 36 ++++++++++----------- 4 files changed, 59 insertions(+), 61 deletions(-) diff --git a/build.js b/build.js index 7a1d49fdcc..899d190a8b 100755 --- a/build.js +++ b/build.js @@ -2088,12 +2088,6 @@ 'isTemplate': isTemplate, 'outputPath': outputPath, 'onComplete': function(source) { - // replace `!1` with `false` and `!0` with `true` to help - // optimize Safari when used in a loop - source = source - .replace(/!1([!=]==?[a-z])/g, 'false$1') - .replace(/!0([!=]==?[a-z])/g, 'true$1') - // inject "use strict" directive if (isStrict) { source = source.replace(/^([\s\S]*?function[^{]+{)([^"'])/, '$1"use strict";$2'); diff --git a/build/post-compile.js b/build/post-compile.js index a77a458c1b..ebd80869dc 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -32,13 +32,17 @@ // correct overly aggressive Closure Compiler advanced optimizations source = source.replace(/prototype\s*=\s*{\s*valueOf\s*:\s*1\s*}/, 'prototype={valueOf:1,y:1}'); - // unescape properties (i.e. foo["bar"] => foo.bar) + // unescape properties (e.g. foo["bar"] => foo.bar) source = source.replace(/(\w)\["([^."]+)"\]/g, function(match, left, right) { return /\W/.test(right) ? match : (left + '.' + right); }); - // correct AMD module definition for AMD build optimizers - source = source.replace(/("function")\s*==\s*(typeof define)\s*&&\s*\(?\s*("object")\s*==\s*(typeof define\.amd)\s*&&\s*(define\.amd)\s*\)?/, '$2==$1&&$4==$3&&$5'); + // flip `typeof` expressions to help optimize Safari and + // correct the AMD module definition for AMD build optimizers + // (e.g. from `"number" == typeof x` to `typeof x == "number") + source = source.replace(/(return)?\s*("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[\w.]+))/g, function(match, ret, type, equality, expression) { + return (ret ? ret + ' ' : '') + expression + equality + type; + }); // add trailing semicolon if (source) { diff --git a/lodash.min.js b/lodash.min.js index f8444b5e4a..40126c4a5d 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -2,41 +2,41 @@ Lo-Dash 1.0.0-rc.3 lodash.com/license Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(e,t){function n(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||tt);if(i)for(var s={},n=t-1;++nt||"undefined"==typeof e)return 1;if( -e=(n||tt);if(i)for(var s={},n=t-1;++nt||typeof e=="undefined")return 1;if( +ei;i++)r+="i='"+e.j[i]+"';if(","constructor"==e.j[i]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+e.g+"}"}if(e.b||e.h)r+="}";return r+=e.c+";return t" -,n("e,h,j,k,p,n,s","return function("+t+"){"+r+"}")(u,Et,v,N,nn,At,xt)}function f(e){return"\\"+rn[e]}function l(e){return hn[e]}function c(e){return"function"!=typeof e.toString&&"string"==typeof (e+"")}function h(){}function p(e,t,n){t||(t=0),"undefined"==typeof n&&(n=e?e.length:0);for(var r=-1,n=n-t||0,i=Array(0>n?0:n);++rn?0:n);++rn?Ot(0,i+n):n)||0;return"number"==typeof i?s=-1<(N(e)?e.indexOf(t,n):R(e,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s}function A( -e,t,n){var r=!0,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments.length,t=u(t,r,et);if(vn(e)){var s=-1,o=e.length;for(i&& -(n=e[++s]);++sarguments.length;if("number"!=typeof s)var a=gn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,lt=RegExp -("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable,Tt=Y.toString,Nt=lt.test(Nt=p.bind)&&Nt -,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e(){this.x=1}var t=[];e.prototype={valueOf:1 -,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean":!1,"function":!0,object:!0,number:!1, -string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},pn=w(hn),dn=a(sn,{g:"if(t[i]==null)"+sn.g}),vn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var mn=wt?function(e){if(!e||"object"!=typeof e)return!1;var t=e.valueOf,n="function"==typeof t&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e)}:m,gn=At? -function(e){return"function"==typeof e&&xt.call(e,"prototype")?g(e):x(e)?At(e):[]}:g;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r="function"==typeof t,i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=gn,n.map=D,n.max=P,n.memoize= -function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!vn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return cn(e,function(e,n){t.push([n,e])}),t},n.partial=function(e){return o(e,p(arguments,1))},n.pick=function(e,t,n){var r={};if("function"!=typeof t)for(var i=0,s=yt.apply(G,arguments),o=s.length;++i=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:gn( -e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i||(i=o||rt -.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source=l,p}return t? -s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]||(n.prototype -[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice"],function( -e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?"object"==typeof module&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this); \ No newline at end of file +t);if(s){a=e.length;if(u=a==t.length)for(;a--&&(u=E(e[a],t[a],n,r)););return u}return ln(e,function(e,i,s){if(Et.call(s,i))return a++,u=Et.call(t,i)&&E(e,t[i],n,r)}),u&&ln(t,function(e,t,n){if(Et.call(n,t))return u=-1<--a}),u}function S(e){return typeof e=="function"}function x(e){return e?nn[typeof e]:!1}function T(e){return typeof e=="number"||Tt.call(e)==jt}function N(e){return typeof e=="string"||Tt.call(e)==qt}function C(e,t,n){var r=arguments,i=0,s=2,o=r[3],u=r[4];n!==et&&(o=[],u=[],typeof +n!="number"&&(s=r.length));for(;++in?Ot(0,i+n):n)||0;return typeof i=="number"?s=-1<(N(e)?e.indexOf(t,n):R(e,t,n)):an(e,function(e){if(++r>=n)return!(s=e===t)}),s} +function A(e,t,n){var r=!0,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nr&&(r=n,a=e)});else for(;++sa&&(a=e[s]);return a}function H(e,t){return D(e,t+"")}function B(e,t,n,r){var i=3>arguments.length,t=u(t,r,et);if(vn(e)){var s=-1,o= +e.length;for(i&&(n=e[++s]);++sarguments.length;if(typeof s!="number")var a=gn(e),s=a.length;else Gt&&N(e)&&(i=e.split(""));return t=u(t,r,et),_(e,function(e,r,u){r=a?a[--s]:--s,n=o?(o=!1,i[r]):t(n,i[r],r,u)}),n}function F(e,t,n){var r,t=u(t,n);if(vn(e))for(var n=-1,i=e.length;++nn?Ot(0,i+n):n||0)-1;else if(n)return r=z(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])R(a,c))(n||f)&&a.push(c),o.push(r)}return o}function X(e,t){return zt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,it=/&(?:amp|lt|gt|quot|#x27);/g,st=/\b__p\+='';/g,ot=/\b(__p\+=)''\+/g,ut=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ft=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g +,lt=RegExp("^"+(Y.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ct=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,ht=/<%=([\s\S]+?)%>/g,pt=/($^)/,dt=/[&<>"']/g,vt=/['\n\r\t\u2028\u2029\\]/g,mt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),gt=Math.ceil,yt=G.concat,bt=Math.floor,wt=lt.test(wt=Object.getPrototypeOf)&&wt,Et=Y.hasOwnProperty,St=G.push,xt=Y.propertyIsEnumerable,Tt=Y.toString,Nt=lt.test(Nt= +p.bind)&&Nt,Ct=lt.test(Ct=Array.isArray)&&Ct,kt=e.isFinite,Lt=e.isNaN,At=lt.test(At=Object.keys)&&At,Ot=Math.max,Mt=Math.min,_t=Math.random,Dt="[object Arguments]",Pt="[object Array]",Ht="[object Boolean]",Bt="[object Date]",jt="[object Number]",Ft="[object Object]",It="[object RegExp]",qt="[object String]",Rt=!!e.attachEvent,Ut=Nt&&!/\n|true/.test(Nt+Rt),zt=Nt&&!Ut,Wt=At&&(Rt||Ut),Xt,Vt,$t=($t={0:1,length:1},G.splice.call($t,0,1),$t[0]),Jt=!0;(function(){function e(){this.x=1}var t=[];e.prototype= +{valueOf:1,y:1};for(var n in new e)t.push(n);for(n in arguments)Jt=!n;Xt=!/valueOf/.test(t),Vt="x"!=t[0]})(1);var Kt=arguments.constructor==Object,Qt=!v(arguments),Gt="xx"!="x"[0]+Object("x")[0];try{var Yt=("[object Object]",Tt.call(document)==Ft)}catch(Zt){}var en={"[object Function]":!1};en[Dt]=en[Pt]=en[Ht]=en[Bt]=en[jt]=en[Ft]=en[It]=en[qt]=!0;var tn={};tn[Pt]=Array,tn[Ht]=Boolean,tn[Bt]=Date,tn[Ft]=Object,tn[jt]=Number,tn[It]=RegExp,tn[qt]=String;var nn={"boolean":!1,"function":!0,object:!0, +number:!1,string:!1,"undefined":!1},rn={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:ht,variable:""};var sn={a:"o,v,g",k:"for(var a=1,b=typeof g=='number'?2:arguments.length;a":">",'"':""","'":"'"},pn=w(hn),dn=a(sn,{g:"if(t[i]==null)"+sn.g}),vn=Ct||function(e){return Kt&&e instanceof Array||Tt.call(e)==Pt};S(/x/)&&(S=function(e){return e instanceof Function||"[object Function]"==Tt.call(e)});var mn=wt?function(e){if(!e||typeof e!="object")return!1;var t=e.valueOf,n=typeof t=="function"&&(n=wt(t))&&wt(n);return n?e==n||wt(e)==n&&!v(e):m(e) +}:m,gn=At?function(e){return typeof e=="function"&&xt.call(e,"prototype")?g(e):x(e)?At(e):[]}:g;n.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.assign=fn,n.bind=X,n.bindAll=function(e){for(var t=arguments,n=1R(f,l)){u&&f.push(l);for(var h=n;--h;)if(!(i[h]||(i[h]=r(t[h],0,100)))(l))continue e;a.push(l)}}return a},n.invert=w,n.invoke=function(e,t){var n=p(arguments,2),r=typeof t=="function",i=[];return _(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=gn,n.map=D, +n.max=P,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Et.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.merge=C,n.min=function(e,t,n){var r=Infinity,s=-1,o=e?e.length:0,a=r;if(t||!vn(e))t=!t&&N(e)?i:u(t,n),an(e,function(e,n,i){n=t(e,n,i),nR(s,n,1))i[n]=e}),i},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return cn(e,function(e,n){t.push([n,e])}),t},n.partial=function(e){return o(e,p(arguments,1))},n.pick=function(e,t,n){var r={};if(typeof t!="function")for(var i=0,s=yt.apply(G,arguments),o=s.length;++i=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rn?Ot(0,r+n):Mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},n.mixin=$,n.noConflict=function(){return e._=nt,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+bt(_t()*((+t||0)-e+1))},n.reduce=B,n.reduceRight=j,n.result=function(e,t){var n=e?e[t]:null;return S(n)?e[t]():n},n.size=function(e){var t=e?e.length:0; +return typeof t=="number"?t:gn(e).length},n.some=F,n.sortedIndex=z,n.template=function(e,t,r){e||(e=""),r||(r={});var i,s,o=n.templateSettings,u=0,a=r.interpolate||o.interpolate||pt,l="__p+='",c=r.variable||o.variable,h=c;e.replace(RegExp((r.escape||o.escape||pt).source+"|"+a.source+"|"+(a===ht?ct:pt).source+"|"+(r.evaluate||o.evaluate||pt).source+"|$","g"),function(t,n,r,s,o,a){return r||(r=s),l+=e.slice(u,a).replace(vt,f),n&&(l+="'+__e("+n+")+'"),o&&(l+="';"+o+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'" +),i||(i=o||rt.test(n||r)),u=a+t.length,t}),l+="';\n",h||(c="obj",i?l="with("+c+"){"+l+"}":(r=RegExp("(\\(\\s*)"+c+"\\."+c+"\\b","g"),l=l.replace(ft,"$&"+c+".").replace(r,"$1__d"))),l=(i?l.replace(st,""):l).replace(ot,"$1").replace(ut,"$1;"),l="function("+c+"){"+(h?"":c+"||("+c+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(h?"":",__d="+c+"."+c+"||"+c)+";")+l+"return __p}";try{s=Function("_","return "+l)(n)}catch(p){throw p.source= +l,p}return t?s(t):(s.source=l,s)},n.unescape=function(e){return null==e?"":(e+"").replace(it,d)},n.uniqueId=function(e){return(null==e?"":e+"")+ ++Z},n.all=A,n.any=F,n.detect=M,n.foldl=B,n.foldr=j,n.include=L,n.inject=B,cn(n,function(e,t){n.prototype[t]||(n.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),e.apply(n,t)})}),n.first=I,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:p(e,Ot(0,r-t))}},n.take=I,n.head=I,cn(n,function(e,t){n.prototype[t]|| +(n.prototype[t]=function(t,r){var i=e(this.__wrapped__,t,r);return null==t||r?i:new n(i)})}),n.VERSION="1.0.0-rc.3",n.prototype.toString=function(){return this.__wrapped__+""},n.prototype.value=J,n.prototype.valueOf=J,an(["join","pop","shift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments)}}),an(["push","reverse","sort","unshift"],function(e){var t=G[e];n.prototype[e]=function(){return t.apply(this.__wrapped__,arguments),this}}),an(["concat","slice","splice" +],function(e){var t=G[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return new n(e)}}),$t&&an(["pop","shift","splice"],function(e){var t=G[e],r="splice"==e;n.prototype[e]=function(){var e=this.__wrapped__,i=t.apply(e,arguments);return 0===e.length&&delete e[0],r?new n(i):i}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=n,define(function(){return n})):K?typeof module=="object"&&module&&module.exports==K?(module.exports=n)._=n:K._=n:e._=n})(this); \ No newline at end of file diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index b349c9d041..daba5025c4 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -3,31 +3,31 @@ Build: `lodash underscore -m -o ./lodash.underscore.min.js` Underscore.js 1.4.3 underscorejs.org/LICENSE */ -;(function(e,t){function n(e){if(e&&"object"==typeof e&&e.__wrapped__)return e;if(!(this instanceof n))return new n(e);this.__wrapped__=e}function r(e,t){var n=e.b,r=t.b,e=e.a,t=t.a;if(e!==t){if(e>t||"undefined"==typeof e)return 1;if(en?0:n);++rt||typeof e=="undefined")return 1;if(en?0:n);++rr&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,V);if(Ot(e)){var o=-1 -,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if("number"!=typeof i)var u=Mt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st=f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite,at=e.isNaN,ft= +}return Ct(e,function(e,i,s){if(nt.call(s,i))return a++,!(u=nt.call(t,i)&&m(e,t[i],n,r))&&V}),u&&Ct(t,function(e,t,n){if(nt.call(n,t))return!(u=-1<--a)&&V}),u}function g(e){return typeof e=="function"}function y(e){return e?xt[typeof e]:!1}function b(e){return typeof e=="number"||it.call(e)==mt}function w(e){return typeof e=="string"||it.call(e)==bt}function E(e){var t=[];return kt(e,function(e){t.push(e)}),t}function S(e,t){var n=!1;return typeof (e?e.length:0)=="number"?n=-1r&&(r=n,u=e)});else for(;++iu&&(u=e[i]);return u}function A(e,t){return k(e,t+"")}function O(e,t,n,r){var i=3>arguments.length,t=s(t,r,V);if(Ot(e)){var o=-1 +,u=e.length;for(i&&(n=e[++o]);++oarguments.length;if(typeof i!="number")var u=Mt(e),i=u.length;return t=s(t,r,V),C(e,function(r,s,a){s=u?u[--i]:--i,n=o?(o=!1,e[s]):t(n,e[s],s,a)}),n}function _(e,t,n){var r,t=s(t,n);if(Ot(e))for(var n=-1,i=e.length;++nn?lt(0,i+n):n||0)-1;else if(n)return r=j(e,t),e[r]===t?r:-1;for(;++r>>1,n(e[r])H(a,f))n&&a.push(f),u.push(r)}return u}function I(e,t){return wt||st&&2"']/g,Y=/['\n\r\t\u2028\u2029\\]/g,Z=Math.ceil,et=W.concat,tt=Math.floor,nt=z.hasOwnProperty,rt=W.push,it=z.toString,st=K.test(st=f.bind)&&st,ot=K.test(ot=Array.isArray)&&ot,ut=e.isFinite,at=e.isNaN,ft= K.test(ft=Object.keys)&&ft,lt=Math.max,ct=Math.min,ht=Math.random,pt="[object Array]",dt="[object Boolean]",vt="[object Date]",mt="[object Number]",gt="[object Object]",yt="[object RegExp]",bt="[object String]",z=!!e.attachEvent,z=st&&!/\n|true/.test(st+z),wt=st&&!z,Et=(Et={0:1,length:1},W.splice.call(Et,0,1),Et[0]),St=arguments.constructor==Object,xt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,"undefined":!1},Tt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029" -:"u2029"};n.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&"undefined"==typeof n?t:s(t,n),r=e.length,n=-1;if("number"==typeof r){for(;++n/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""};var Nt=function(e,t,n){if(!e)return e;var t=t&&typeof n=="undefined"?t:s(t,n),r=e.length,n=-1;if(typeof r=="number"){for(;++n":">",'"':""","'":"'"},At=v(Lt),Ot=ot||function(e){return St&&e instanceof Array||it.call(e)==pt};g(/x/)&&(g=function(e){return e instanceof Function||"[object Function]"==it.call(e)});var Mt=ft?function(e){return y(e)?ft(e):[]}:h;n.after=function(e,t){return 1> e?t():function(){if(1>--e)return t.apply(this,arguments)}},n.bind=I,n.bindAll=function(e){for(var t=arguments,n=1H(r,s,n)&&i.push(s)}return i},n.filter=T,n.flatten=P,n.forEach=C,n.functions=d,n.groupBy=function(e,t,n){var r={},t=s(t,n);return C(e,function(e,n,i){n=t(e,n,i),(nt.call(r,n)?r[n]:r[n]=[]).push(e)}),r},n.initial=function(e,t,n){if(!e)return[];var r=e.length;return f(e,0,ct(lt(0,r-(null==t||n?1:t||0)),r))},n.intersection=function(e){var t=arguments,n=t.length,r=-1,i=e?e.length:0,s=[];e:for(;++rH(s,o)){for(var u=n;--u;)if(0>H(t[u],o))continue e;s.push(o)}}return s},n.invert= -v,n.invoke=function(e,t){var n=f(arguments,2),r="function"==typeof t,i=[];return C(e,function(e){i.push((r?t:e[t]).apply(e,n))}),i},n.keys=Mt,n.map=k,n.max=L,n.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return nt.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},n.min=function(e,t,n){var r=Infinity,i=-1,o=e?e.length:0,u=r;if(t||!Ot(e))t=s(t,n),Nt(e,function(e,n,i){n=t(e,n,i),nH(t,r,1)&&(n[r]=e)}),n},n.once=function(e){var t,n=!1;return function(){return n?t:(n=!0,t=e.apply(this,arguments),e=null,t)}},n.pairs=function(e){var t=[];return kt(e,function(e,n){t.push([n,e])}),t},n.pick=function(e){for(var t=0,n=et.apply(W,arguments),r=n.length,i={};++t=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++r=f?(clearTimeout(o),o=null,u=a,i=e.apply(s,r)):o||(o=setTimeout(n,f)),i}},n.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(arguments,i,1)&&r.push(i)}return r},n.wrap=function(e,t){return function(){var n=[e];return rt.apply(n,arguments),t.apply(this,n)}},n.zip=function(e){for(var t=-1,n=e?L(A(arguments,"length")):0,r=Array(n);++tn?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r;return-1 -},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return"number"==typeof t?t:Mt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+(r.interpolate|| -Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function(e){return null== -e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift" -.split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?"object"==typeof module&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file +B,n.unique=F,n.clone=function(e){return e&&xt[typeof e]?Ot(e)?f(e):c({},e):e},n.contains=S,n.escape=function(e){return null==e?"":(e+"").replace(G,u)},n.every=x,n.find=N,n.has=function(e,t){return e?nt.call(e,t):!1},n.identity=q,n.indexOf=H,n.isArray=Ot,n.isBoolean=function(e){return!0===e||!1===e||it.call(e)==dt},n.isDate=function(e){return e instanceof Date||it.call(e)==vt},n.isElement=function(e){return e?1===e.nodeType:!1},n.isEmpty=function(e){if(!e)return!0;if(Ot(e)||w(e))return!e.length;for( +var t in e)if(nt.call(e,t))return!1;return!0},n.isEqual=m,n.isFinite=function(e){return ut(e)&&!at(parseFloat(e))},n.isFunction=g,n.isNaN=function(e){return b(e)&&e!=+e},n.isNull=function(e){return null===e},n.isNumber=b,n.isObject=y,n.isRegExp=function(e){return e instanceof RegExp||it.call(e)==yt},n.isString=w,n.isUndefined=function(e){return typeof e=="undefined"},n.lastIndexOf=function(e,t,n){var r=e?e.length:0;for(typeof n=="number"&&(r=(0>n?lt(0,r+n):ct(n,r-1))+1);r--;)if(e[r]===t)return r; +return-1},n.mixin=R,n.noConflict=function(){return e._=$,this},n.random=function(e,t){return null==e&&null==t&&(t=1),e=+e||0,null==t&&(t=e,e=0),e+tt(ht()*((+t||0)-e+1))},n.reduce=O,n.reduceRight=M,n.result=function(e,t){var n=e?e[t]:null;return g(n)?e[t]():n},n.size=function(e){var t=e?e.length:0;return typeof t=="number"?t:Mt(e).length},n.some=_,n.sortedIndex=j,n.template=function(e,t,r){e||(e="");var r=p({},r,n.templateSettings),i=0,s="__p+='",u=r.variable;e.replace(RegExp((r.escape||Q).source+"|"+ +(r.interpolate||Q).source+"|"+(r.evaluate||Q).source+"|$","g"),function(t,n,r,u,a){s+=e.slice(i,a).replace(Y,o),s+=n?"'+_['escape']("+n+")+'":u?"';"+u+";__p+='":r?"'+((__t=("+r+"))==null?'':__t)+'":"",i=a+t.length}),s+="';\n",u||(u="obj",s="with("+u+"||{}){"+s+"}"),s="function("+u+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+s+"return __p}";try{var a=Function("_","return "+s)(n)}catch(f){throw f.source=s,f}return t?a(t):(a.source=s,a)},n.unescape=function( +e){return null==e?"":(e+"").replace(J,l)},n.uniqueId=function(e){var t=++X+"";return e?e+t:t},n.all=x,n.any=_,n.detect=N,n.foldl=O,n.foldr=M,n.include=S,n.inject=O,n.first=D,n.last=function(e,t,n){if(e){var r=e.length;return null==t||n?e[r-1]:f(e,lt(0,r-t))}},n.take=D,n.head=D,n.chain=function(e){return e=new n(e),e.__chain__=!0,e},n.VERSION="1.0.0-rc.3",R(n),n.prototype.chain=function(){return this.__chain__=!0,this},n.prototype.value=function(){return this.__wrapped__},Nt("pop push reverse shift sort splice unshift" +.split(" "),function(e){var t=W[e];n.prototype[e]=function(){var e=this.__wrapped__;return t.apply(e,arguments),Et&&e.length===0&&delete e[0],this}}),Nt(["concat","join","slice"],function(e){var t=W[e];n.prototype[e]=function(){var e=t.apply(this.__wrapped__,arguments);return this.__chain__&&(e=new n(e),e.__chain__=!0),e}}),U?typeof module=="object"&&module&&module.exports==U?(module.exports=n)._=n:U._=n:e._=n})(this); \ No newline at end of file From 692c884ca203a6fcd214f95a8b2591ec68a78760 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 17 Dec 2012 08:21:13 -0800 Subject: [PATCH 44/45] Ensure test count is the same for dev and prod builds. Former-commit-id: 00e24fdd70d52bc6be4ae53fed43933fcf2c35da --- test/test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test.js b/test/test.js index e34fb7886f..c1b12c4707 100644 --- a/test/test.js +++ b/test/test.js @@ -2161,6 +2161,7 @@ var funcs = _.without.apply(_, [_.functions(_)].concat([ '_', + '_each', '_iteratorTemplate', 'after', 'bind', From 9c52ecc19b35660d8c694917ddb2c1ecb4ca9327 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 17 Dec 2012 08:36:02 -0800 Subject: [PATCH 45/45] Tweak regexp in post-compile.js. Former-commit-id: 8c6933944703a17582696fb10b45f12926fe1030 --- build/post-compile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/post-compile.js b/build/post-compile.js index ebd80869dc..6ea6cda9f2 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -40,7 +40,7 @@ // flip `typeof` expressions to help optimize Safari and // correct the AMD module definition for AMD build optimizers // (e.g. from `"number" == typeof x` to `typeof x == "number") - source = source.replace(/(return)?\s*("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[\w.]+))/g, function(match, ret, type, equality, expression) { + source = source.replace(/(return)?("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[\w.]+))/g, function(match, ret, type, equality, expression) { return (ret ? ret + ' ' : '') + expression + equality + type; });