mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b2df88eab |
@@ -1,4 +1,4 @@
|
|||||||
# lodash v3.0.0
|
# lodash v3.0.1
|
||||||
|
|
||||||
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', './thru'], funct
|
|||||||
function wrapperReverse() {
|
function wrapperReverse() {
|
||||||
var value = this.__wrapped__;
|
var value = this.__wrapped__;
|
||||||
if (value instanceof LazyWrapper) {
|
if (value instanceof LazyWrapper) {
|
||||||
|
if (this.__actions__.length) {
|
||||||
|
value = new LazyWrapper(this);
|
||||||
|
}
|
||||||
return new LodashWrapper(value.reverse());
|
return new LodashWrapper(value.reverse());
|
||||||
}
|
}
|
||||||
return this.thru(function(value) {
|
return this.thru(function(value) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ define(['../internal/arrayEach', '../internal/baseEach', '../internal/bindCallba
|
|||||||
* @returns {Array|Object|string} Returns `collection`.
|
* @returns {Array|Object|string} Returns `collection`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _([1, 2, 3]).forEach(function(n) { console.log(n); });
|
* _([1, 2, 3]).forEach(function(n) { console.log(n); }).value();
|
||||||
* // => logs each value from left to right and returns the array
|
* // => logs each value from left to right and returns the array
|
||||||
*
|
*
|
||||||
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); });
|
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); });
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ define(['../internal/MapCache', '../lang/isFunction'], function(MapCache, isFunc
|
|||||||
* // => 'FRED'
|
* // => 'FRED'
|
||||||
*
|
*
|
||||||
* // modifying the result cache
|
* // modifying the result cache
|
||||||
* upperCase.cache.set('fred, 'BARNEY');
|
* upperCase.cache.set('fred', 'BARNEY');
|
||||||
* upperCase('fred');
|
* upperCase('fred');
|
||||||
* // => 'BARNEY'
|
* // => 'BARNEY'
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseMatches', './baseProperty', './baseToString', './bindCallback', '../utility/identity', './isBindable'], function(baseMatches, baseProperty, baseToString, bindCallback, identity, isBindable) {
|
define(['./baseMatches', './baseProperty', './bindCallback', '../utility/identity', './isBindable'], function(baseMatches, baseProperty, bindCallback, identity, isBindable) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.callback` which supports specifying the
|
* The base implementation of `_.callback` which supports specifying the
|
||||||
@@ -23,7 +23,7 @@ define(['./baseMatches', './baseProperty', './baseToString', './bindCallback', '
|
|||||||
// Handle "_.property" and "_.matches" style callback shorthands.
|
// Handle "_.property" and "_.matches" style callback shorthands.
|
||||||
return type == 'object'
|
return type == 'object'
|
||||||
? baseMatches(func, !argCount)
|
? baseMatches(func, !argCount)
|
||||||
: baseProperty(argCount ? baseToString(func) : func);
|
: baseProperty(func + '');
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseCallback;
|
return baseCallback;
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ define(['./arrayCopy', '../lang/isArguments', '../lang/isArray', './isLength', '
|
|||||||
? toPlainObject(value)
|
? toPlainObject(value)
|
||||||
: (isPlainObject(value) ? value : {});
|
: (isPlainObject(value) ? value : {});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
isCommon = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Add the source value to the stack of traversed objects and associate
|
// Add the source value to the stack of traversed objects and associate
|
||||||
// it with its merged value.
|
// it with its merged value.
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ define([], function() {
|
|||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
end += length;
|
end += length;
|
||||||
}
|
}
|
||||||
length = start > end ? 0 : (end - start);
|
length = start > end ? 0 : (end - start) >>> 0;
|
||||||
|
start >>>= 0;
|
||||||
|
|
||||||
var result = Array(length);
|
var result = Array(length);
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseToString', '../string/repeat', './root'], function(baseToString, repeat, root) {
|
define(['../string/repeat', './root'], function(repeat, root) {
|
||||||
|
|
||||||
/** Native method references. */
|
/** Native method references. */
|
||||||
var ceil = Math.ceil;
|
var ceil = Math.ceil;
|
||||||
@@ -25,7 +25,7 @@ define(['./baseToString', '../string/repeat', './root'], function(baseToString,
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
var padLength = length - strLength;
|
var padLength = length - strLength;
|
||||||
chars = chars == null ? ' ' : baseToString(chars);
|
chars = chars == null ? ' ' : (chars + '');
|
||||||
return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength);
|
return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseToString'], function(baseToString) {
|
define([], function() {
|
||||||
|
|
||||||
/** `Object#toString` result references. */
|
/** `Object#toString` result references. */
|
||||||
var boolTag = '[object Boolean]',
|
var boolTag = '[object Boolean]',
|
||||||
@@ -43,7 +43,7 @@ define(['./baseToString'], function(baseToString) {
|
|||||||
case stringTag:
|
case stringTag:
|
||||||
// Coerce regexes to strings and treat strings primitives and string
|
// Coerce regexes to strings and treat strings primitives and string
|
||||||
// objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
|
// objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
|
||||||
return object == baseToString(other);
|
return object == (other + '');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,14 @@ define(['./LazyWrapper'], function(LazyWrapper) {
|
|||||||
* @returns {Object} Returns the new reversed `LazyWrapper` object.
|
* @returns {Object} Returns the new reversed `LazyWrapper` object.
|
||||||
*/
|
*/
|
||||||
function lazyReverse() {
|
function lazyReverse() {
|
||||||
var filtered = this.filtered,
|
if (this.filtered) {
|
||||||
result = filtered ? new LazyWrapper(this) : this.clone();
|
var result = new LazyWrapper(this);
|
||||||
|
result.dir = -1;
|
||||||
result.dir = this.dir * -1;
|
result.filtered = true;
|
||||||
result.filtered = filtered;
|
} else {
|
||||||
|
result = this.clone();
|
||||||
|
result.dir *= -1;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ define(['./baseWrapperValue', './getView', '../lang/isArray'], function(baseWrap
|
|||||||
}
|
}
|
||||||
var dir = this.dir,
|
var dir = this.dir,
|
||||||
isRight = dir < 0,
|
isRight = dir < 0,
|
||||||
length = array.length,
|
view = getView(0, array.length, this.views),
|
||||||
view = getView(0, length, this.views),
|
|
||||||
start = view.start,
|
start = view.start,
|
||||||
end = view.end,
|
end = view.end,
|
||||||
|
length = end - start,
|
||||||
dropCount = this.dropCount,
|
dropCount = this.dropCount,
|
||||||
takeCount = nativeMin(end - start, this.takeCount - dropCount),
|
takeCount = nativeMin(length, this.takeCount - dropCount),
|
||||||
index = isRight ? end : start - 1,
|
index = isRight ? end : start - 1,
|
||||||
iteratees = this.iteratees,
|
iteratees = this.iteratees,
|
||||||
iterLength = iteratees ? iteratees.length : 0,
|
iterLength = iteratees ? iteratees.length : 0,
|
||||||
@@ -63,7 +63,7 @@ define(['./baseWrapperValue', './getView', '../lang/isArray'], function(baseWrap
|
|||||||
result[resIndex++] = value;
|
result[resIndex++] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isRight ? result.reverse() : result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return lazyValue;
|
return lazyValue;
|
||||||
|
|||||||
53
main.js
53
main.js
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
* lodash 3.0.0 (Custom Build) <https://lodash.com/>
|
* lodash 3.0.1 (Custom Build) <https://lodash.com/>
|
||||||
* Build: `lodash modern exports="amd" -d -o ./main.js`
|
* Build: `lodash modern exports="amd" -d -o ./main.js`
|
||||||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
|
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
var undefined;
|
var undefined;
|
||||||
|
|
||||||
/** Used as the semantic version number. */
|
/** Used as the semantic version number. */
|
||||||
var VERSION = '3.0.0';
|
var VERSION = '3.0.1';
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1,
|
var BIND_FLAG = 1,
|
||||||
@@ -1057,11 +1057,14 @@
|
|||||||
* @returns {Object} Returns the new reversed `LazyWrapper` object.
|
* @returns {Object} Returns the new reversed `LazyWrapper` object.
|
||||||
*/
|
*/
|
||||||
function lazyReverse() {
|
function lazyReverse() {
|
||||||
var filtered = this.filtered,
|
if (this.filtered) {
|
||||||
result = filtered ? new LazyWrapper(this) : this.clone();
|
var result = new LazyWrapper(this);
|
||||||
|
result.dir = -1;
|
||||||
result.dir = this.dir * -1;
|
result.filtered = true;
|
||||||
result.filtered = filtered;
|
} else {
|
||||||
|
result = this.clone();
|
||||||
|
result.dir *= -1;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,12 +1083,12 @@
|
|||||||
}
|
}
|
||||||
var dir = this.dir,
|
var dir = this.dir,
|
||||||
isRight = dir < 0,
|
isRight = dir < 0,
|
||||||
length = array.length,
|
view = getView(0, array.length, this.views),
|
||||||
view = getView(0, length, this.views),
|
|
||||||
start = view.start,
|
start = view.start,
|
||||||
end = view.end,
|
end = view.end,
|
||||||
|
length = end - start,
|
||||||
dropCount = this.dropCount,
|
dropCount = this.dropCount,
|
||||||
takeCount = nativeMin(end - start, this.takeCount - dropCount),
|
takeCount = nativeMin(length, this.takeCount - dropCount),
|
||||||
index = isRight ? end : start - 1,
|
index = isRight ? end : start - 1,
|
||||||
iteratees = this.iteratees,
|
iteratees = this.iteratees,
|
||||||
iterLength = iteratees ? iteratees.length : 0,
|
iterLength = iteratees ? iteratees.length : 0,
|
||||||
@@ -1121,7 +1124,7 @@
|
|||||||
result[resIndex++] = value;
|
result[resIndex++] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isRight ? result.reverse() : result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
@@ -1642,7 +1645,7 @@
|
|||||||
// Handle "_.property" and "_.matches" style callback shorthands.
|
// Handle "_.property" and "_.matches" style callback shorthands.
|
||||||
return type == 'object'
|
return type == 'object'
|
||||||
? baseMatches(func, !argCount)
|
? baseMatches(func, !argCount)
|
||||||
: baseProperty(argCount ? baseToString(func) : func);
|
: baseProperty(func + '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2372,6 +2375,9 @@
|
|||||||
? toPlainObject(value)
|
? toPlainObject(value)
|
||||||
: (isPlainObject(value) ? value : {});
|
: (isPlainObject(value) ? value : {});
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
isCommon = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Add the source value to the stack of traversed objects and associate
|
// Add the source value to the stack of traversed objects and associate
|
||||||
// it with its merged value.
|
// it with its merged value.
|
||||||
@@ -2493,7 +2499,8 @@
|
|||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
end += length;
|
end += length;
|
||||||
}
|
}
|
||||||
length = start > end ? 0 : (end - start);
|
length = start > end ? 0 : (end - start) >>> 0;
|
||||||
|
start >>>= 0;
|
||||||
|
|
||||||
var result = Array(length);
|
var result = Array(length);
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
@@ -3100,7 +3107,7 @@
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
var padLength = length - strLength;
|
var padLength = length - strLength;
|
||||||
chars = chars == null ? ' ' : baseToString(chars);
|
chars = chars == null ? ' ' : (chars + '');
|
||||||
return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength);
|
return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3293,7 +3300,7 @@
|
|||||||
case stringTag:
|
case stringTag:
|
||||||
// Coerce regexes to strings and treat strings primitives and string
|
// Coerce regexes to strings and treat strings primitives and string
|
||||||
// objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
|
// objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
|
||||||
return object == baseToString(other);
|
return object == (other + '');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -5311,6 +5318,9 @@
|
|||||||
function wrapperReverse() {
|
function wrapperReverse() {
|
||||||
var value = this.__wrapped__;
|
var value = this.__wrapped__;
|
||||||
if (value instanceof LazyWrapper) {
|
if (value instanceof LazyWrapper) {
|
||||||
|
if (this.__actions__.length) {
|
||||||
|
value = new LazyWrapper(this);
|
||||||
|
}
|
||||||
return new LodashWrapper(value.reverse());
|
return new LodashWrapper(value.reverse());
|
||||||
}
|
}
|
||||||
return this.thru(function(value) {
|
return this.thru(function(value) {
|
||||||
@@ -5686,7 +5696,7 @@
|
|||||||
* @returns {Array|Object|string} Returns `collection`.
|
* @returns {Array|Object|string} Returns `collection`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* _([1, 2, 3]).forEach(function(n) { console.log(n); });
|
* _([1, 2, 3]).forEach(function(n) { console.log(n); }).value();
|
||||||
* // => logs each value from left to right and returns the array
|
* // => logs each value from left to right and returns the array
|
||||||
*
|
*
|
||||||
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); });
|
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); });
|
||||||
@@ -7102,7 +7112,7 @@
|
|||||||
* // => 'FRED'
|
* // => 'FRED'
|
||||||
*
|
*
|
||||||
* // modifying the result cache
|
* // modifying the result cache
|
||||||
* upperCase.cache.set('fred, 'BARNEY');
|
* upperCase.cache.set('fred', 'BARNEY');
|
||||||
* upperCase('fred');
|
* upperCase('fred');
|
||||||
* // => 'BARNEY'
|
* // => 'BARNEY'
|
||||||
*
|
*
|
||||||
@@ -9190,7 +9200,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `string` to kebab case (a.k.a. spinal case).
|
* Converts `string` to kebab case (a.k.a. spinal case).
|
||||||
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Computers) for
|
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for
|
||||||
* more details.
|
* more details.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
@@ -10674,7 +10684,8 @@
|
|||||||
|
|
||||||
// Add `LazyWrapper` methods to `lodash.prototype`.
|
// Add `LazyWrapper` methods to `lodash.prototype`.
|
||||||
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
|
||||||
var retUnwrapped = /^(?:first|last)$/.test(methodName);
|
var lodashFunc = lodash[methodName],
|
||||||
|
retUnwrapped = /^(?:first|last)$/.test(methodName);
|
||||||
|
|
||||||
lodash.prototype[methodName] = function() {
|
lodash.prototype[methodName] = function() {
|
||||||
var value = this.__wrapped__,
|
var value = this.__wrapped__,
|
||||||
@@ -10687,12 +10698,12 @@
|
|||||||
if (retUnwrapped && !chainAll) {
|
if (retUnwrapped && !chainAll) {
|
||||||
return onlyLazy
|
return onlyLazy
|
||||||
? func.call(value)
|
? func.call(value)
|
||||||
: lodash[methodName](this.value());
|
: lodashFunc.call(lodash, this.value());
|
||||||
}
|
}
|
||||||
var interceptor = function(value) {
|
var interceptor = function(value) {
|
||||||
var otherArgs = [value];
|
var otherArgs = [value];
|
||||||
push.apply(otherArgs, args);
|
push.apply(otherArgs, args);
|
||||||
return lodash[methodName].apply(lodash, otherArgs);
|
return lodashFunc.apply(lodash, otherArgs);
|
||||||
};
|
};
|
||||||
if (isLazy || isArray(value)) {
|
if (isLazy || isArray(value)) {
|
||||||
var wrapper = onlyLazy ? value : new LazyWrapper(this),
|
var wrapper = onlyLazy ? value : new LazyWrapper(this),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lodash",
|
"name": "lodash",
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
"volo": {
|
"volo": {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define(['../internal/createCompounder'], function(createCompounder) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `string` to kebab case (a.k.a. spinal case).
|
* Converts `string` to kebab case (a.k.a. spinal case).
|
||||||
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Computers) for
|
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for
|
||||||
* more details.
|
* more details.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
|
|||||||
Reference in New Issue
Block a user