mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
Bump to v3.2.0.
This commit is contained in:
@@ -10,14 +10,14 @@ define([], function() {
|
||||
* @param {*} value The value to wrap.
|
||||
*/
|
||||
function LazyWrapper(value) {
|
||||
this.actions = null;
|
||||
this.dir = 1;
|
||||
this.dropCount = 0;
|
||||
this.filtered = false;
|
||||
this.iteratees = null;
|
||||
this.takeCount = POSITIVE_INFINITY;
|
||||
this.views = null;
|
||||
this.wrapped = value;
|
||||
this.__wrapped__ = value;
|
||||
this.__actions__ = null;
|
||||
this.__dir__ = 1;
|
||||
this.__dropCount__ = 0;
|
||||
this.__filtered__ = false;
|
||||
this.__iteratees__ = null;
|
||||
this.__takeCount__ = POSITIVE_INFINITY;
|
||||
this.__views__ = null;
|
||||
}
|
||||
|
||||
return LazyWrapper;
|
||||
|
||||
@@ -9,9 +9,9 @@ define([], function() {
|
||||
* @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value.
|
||||
*/
|
||||
function LodashWrapper(value, chainAll, actions) {
|
||||
this.__wrapped__ = value;
|
||||
this.__actions__ = actions || [];
|
||||
this.__chain__ = !!chainAll;
|
||||
this.__wrapped__ = value;
|
||||
}
|
||||
|
||||
return LodashWrapper;
|
||||
|
||||
@@ -16,7 +16,7 @@ define(['./baseCopy', '../object/keys'], function(baseCopy, keys) {
|
||||
return baseCopy(source, object, props);
|
||||
}
|
||||
var index = -1,
|
||||
length = props.length
|
||||
length = props.length;
|
||||
|
||||
while (++index < length) {
|
||||
var key = props[index],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./baseMatches', './baseProperty', './bindCallback', '../utility/identity', './isBindable'], function(baseMatches, baseProperty, bindCallback, identity, isBindable) {
|
||||
define(['./baseMatches', './baseMatchesProperty', './baseProperty', './bindCallback', '../utility/identity', './isBindable'], function(baseMatches, baseMatchesProperty, baseProperty, bindCallback, identity, isBindable) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.callback` which supports specifying the
|
||||
@@ -20,10 +20,12 @@ define(['./baseMatches', './baseProperty', './bindCallback', '../utility/identit
|
||||
if (func == null) {
|
||||
return identity;
|
||||
}
|
||||
// Handle "_.property" and "_.matches" style callback shorthands.
|
||||
return type == 'object'
|
||||
? baseMatches(func)
|
||||
: baseProperty(func + '');
|
||||
if (type == 'object') {
|
||||
return baseMatches(func);
|
||||
}
|
||||
return typeof thisArg == 'undefined'
|
||||
? baseProperty(func + '')
|
||||
: baseMatchesProperty(func + '', thisArg);
|
||||
}
|
||||
|
||||
return baseCallback;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define(['./baseSlice', '../lang/isFunction'], function(baseSlice, isFunction) {
|
||||
define(['./baseSlice'], function(baseSlice) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
@@ -17,7 +17,7 @@ define(['./baseSlice', '../lang/isFunction'], function(baseSlice, isFunction) {
|
||||
* @returns {number} Returns the timer id.
|
||||
*/
|
||||
function baseDelay(func, wait, args, fromIndex) {
|
||||
if (!isFunction(func)) {
|
||||
if (typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
return setTimeout(function() { func.apply(undefined, baseSlice(args, fromIndex)); }, wait);
|
||||
|
||||
34
internal/baseFill.js
Normal file
34
internal/baseFill.js
Normal file
@@ -0,0 +1,34 @@
|
||||
define([], function() {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.fill` without an iteratee call guard.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to fill.
|
||||
* @param {*} value The value to fill `array` with.
|
||||
* @param {number} [start=0] The start position.
|
||||
* @param {number} [end=array.length] The end position.
|
||||
* @returns {Array} Returns `array`.
|
||||
*/
|
||||
function baseFill(array, value, start, end) {
|
||||
var length = array.length;
|
||||
|
||||
start = start == null ? 0 : (+start || 0);
|
||||
if (start < 0) {
|
||||
start = -start > length ? 0 : (length + start);
|
||||
}
|
||||
end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
|
||||
if (end < 0) {
|
||||
end += length;
|
||||
}
|
||||
length = start > end ? 0 : end >>> 0;
|
||||
start >>>= 0;
|
||||
|
||||
while (start < length) {
|
||||
array[start++] = value;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
return baseFill;
|
||||
});
|
||||
@@ -14,7 +14,7 @@ define(['./baseIsEqual'], function(baseIsEqual) {
|
||||
* shorthands or `this` binding.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} source The object to inspect.
|
||||
* @param {Object} object The object to inspect.
|
||||
* @param {Array} props The source property names to match.
|
||||
* @param {Array} values The source values to match.
|
||||
* @param {Array} strictCompareFlags Strict comparison flags for source values.
|
||||
|
||||
@@ -7,8 +7,7 @@ define(['./baseIsMatch', './isStrictComparable', '../object/keys'], function(bas
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.matches` which supports specifying whether
|
||||
* `source` should be cloned.
|
||||
* The base implementation of `_.matches` which does not clone `source`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} source The object of property values to match.
|
||||
@@ -24,7 +23,7 @@ define(['./baseIsMatch', './isStrictComparable', '../object/keys'], function(bas
|
||||
|
||||
if (isStrictComparable(value)) {
|
||||
return function(object) {
|
||||
return object != null && value === object[key] && hasOwnProperty.call(object, key);
|
||||
return object != null && object[key] === value && hasOwnProperty.call(object, key);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
24
internal/baseMatchesProperty.js
Normal file
24
internal/baseMatchesProperty.js
Normal file
@@ -0,0 +1,24 @@
|
||||
define(['./baseIsEqual', './isStrictComparable'], function(baseIsEqual, isStrictComparable) {
|
||||
|
||||
/**
|
||||
* The base implementation of `_.matchesProperty` which does not coerce `key`
|
||||
* to a string.
|
||||
*
|
||||
* @private
|
||||
* @param {string} key The key of the property to get.
|
||||
* @param {*} value The value to compare.
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function baseMatchesProperty(key, value) {
|
||||
if (isStrictComparable(value)) {
|
||||
return function(object) {
|
||||
return object != null && object[key] === value;
|
||||
};
|
||||
}
|
||||
return function(object) {
|
||||
return object != null && baseIsEqual(value, object[key], null, true);
|
||||
};
|
||||
}
|
||||
|
||||
return baseMatchesProperty;
|
||||
});
|
||||
@@ -18,7 +18,7 @@ define([], function() {
|
||||
eachFunc(collection, function(value, index, collection) {
|
||||
accumulator = initFromCollection
|
||||
? (initFromCollection = false, value)
|
||||
: iteratee(accumulator, value, index, collection)
|
||||
: iteratee(accumulator, value, index, collection);
|
||||
});
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ define(['./baseCallback', './baseEach', '../lang/isArray'], function(baseCallbac
|
||||
/**
|
||||
* Creates a function that aggregates a collection, creating an accumulator
|
||||
* object composed from the results of running each element in the collection
|
||||
* through an iteratee. The `setter` sets the keys and values of the accumulator
|
||||
* object. If `initializer` is provided initializes the accumulator object.
|
||||
* through an iteratee.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} setter The function to set keys and values of the accumulator object.
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
define(['./baseSetData', './createBindWrapper', './createHybridWrapper', './createPartialWrapper', './getData', '../lang/isFunction', './mergeData', './setData'], function(baseSetData, createBindWrapper, createHybridWrapper, createPartialWrapper, getData, isFunction, mergeData, setData) {
|
||||
define(['./baseSetData', './createBindWrapper', './createHybridWrapper', './createPartialWrapper', './getData', './mergeData', './setData'], function(baseSetData, createBindWrapper, createHybridWrapper, createPartialWrapper, getData, mergeData, setData) {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
|
||||
var undefined;
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1,
|
||||
@@ -39,7 +42,7 @@ define(['./baseSetData', './createBindWrapper', './createHybridWrapper', './crea
|
||||
*/
|
||||
function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
|
||||
var isBindKey = bitmask & BIND_KEY_FLAG;
|
||||
if (!isBindKey && !isFunction(func)) {
|
||||
if (!isBindKey && typeof func != 'function') {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
var length = partials ? partials.length : 0;
|
||||
@@ -69,9 +72,9 @@ define(['./baseSetData', './createBindWrapper', './createHybridWrapper', './crea
|
||||
if (bitmask == BIND_FLAG) {
|
||||
var result = createBindWrapper(newData[0], newData[2]);
|
||||
} else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {
|
||||
result = createPartialWrapper.apply(null, newData);
|
||||
result = createPartialWrapper.apply(undefined, newData);
|
||||
} else {
|
||||
result = createHybridWrapper.apply(null, newData);
|
||||
result = createHybridWrapper.apply(undefined, newData);
|
||||
}
|
||||
var setter = data ? baseSetData : setData;
|
||||
return setter(result, newData);
|
||||
|
||||
@@ -9,18 +9,18 @@ define(['./LazyWrapper', './arrayCopy'], function(LazyWrapper, arrayCopy) {
|
||||
* @returns {Object} Returns the cloned `LazyWrapper` object.
|
||||
*/
|
||||
function lazyClone() {
|
||||
var actions = this.actions,
|
||||
iteratees = this.iteratees,
|
||||
views = this.views,
|
||||
result = new LazyWrapper(this.wrapped);
|
||||
var actions = this.__actions__,
|
||||
iteratees = this.__iteratees__,
|
||||
views = this.__views__,
|
||||
result = new LazyWrapper(this.__wrapped__);
|
||||
|
||||
result.actions = actions ? arrayCopy(actions) : null;
|
||||
result.dir = this.dir;
|
||||
result.dropCount = this.dropCount;
|
||||
result.filtered = this.filtered;
|
||||
result.iteratees = iteratees ? arrayCopy(iteratees) : null;
|
||||
result.takeCount = this.takeCount;
|
||||
result.views = views ? arrayCopy(views) : null;
|
||||
result.__actions__ = actions ? arrayCopy(actions) : null;
|
||||
result.__dir__ = this.__dir__;
|
||||
result.__dropCount__ = this.__dropCount__;
|
||||
result.__filtered__ = this.__filtered__;
|
||||
result.__iteratees__ = iteratees ? arrayCopy(iteratees) : null;
|
||||
result.__takeCount__ = this.__takeCount__;
|
||||
result.__views__ = views ? arrayCopy(views) : null;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ define(['./LazyWrapper'], function(LazyWrapper) {
|
||||
* @returns {Object} Returns the new reversed `LazyWrapper` object.
|
||||
*/
|
||||
function lazyReverse() {
|
||||
if (this.filtered) {
|
||||
if (this.__filtered__) {
|
||||
var result = new LazyWrapper(this);
|
||||
result.dir = -1;
|
||||
result.filtered = true;
|
||||
result.__dir__ = -1;
|
||||
result.__filtered__ = true;
|
||||
} else {
|
||||
result = this.clone();
|
||||
result.dir *= -1;
|
||||
result.__dir__ *= -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -16,20 +16,20 @@ define(['./baseWrapperValue', './getView', '../lang/isArray'], function(baseWrap
|
||||
* @returns {*} Returns the unwrapped value.
|
||||
*/
|
||||
function lazyValue() {
|
||||
var array = this.wrapped.value();
|
||||
var array = this.__wrapped__.value();
|
||||
if (!isArray(array)) {
|
||||
return baseWrapperValue(array, this.actions);
|
||||
return baseWrapperValue(array, this.__actions__);
|
||||
}
|
||||
var dir = this.dir,
|
||||
var dir = this.__dir__,
|
||||
isRight = dir < 0,
|
||||
view = getView(0, array.length, this.views),
|
||||
view = getView(0, array.length, this.__views__),
|
||||
start = view.start,
|
||||
end = view.end,
|
||||
length = end - start,
|
||||
dropCount = this.dropCount,
|
||||
takeCount = nativeMin(length, this.takeCount - dropCount),
|
||||
dropCount = this.__dropCount__,
|
||||
takeCount = nativeMin(length, this.__takeCount__),
|
||||
index = isRight ? end : start - 1,
|
||||
iteratees = this.iteratees,
|
||||
iteratees = this.__iteratees__,
|
||||
iterLength = iteratees ? iteratees.length : 0,
|
||||
resIndex = 0,
|
||||
result = [];
|
||||
|
||||
17
internal/wrapperClone.js
Normal file
17
internal/wrapperClone.js
Normal file
@@ -0,0 +1,17 @@
|
||||
define(['./LazyWrapper', './LodashWrapper', './arrayCopy'], function(LazyWrapper, LodashWrapper, arrayCopy) {
|
||||
|
||||
/**
|
||||
* Creates a clone of `wrapper`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} wrapper The wrapper to clone.
|
||||
* @returns {Object} Returns the cloned wrapper.
|
||||
*/
|
||||
function wrapperClone(wrapper) {
|
||||
return wrapper instanceof LazyWrapper
|
||||
? wrapper.clone()
|
||||
: new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__));
|
||||
}
|
||||
|
||||
return wrapperClone;
|
||||
});
|
||||
Reference in New Issue
Block a user