mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1608d89174 | ||
|
|
3b2df88eab |
@@ -1,4 +1,4 @@
|
|||||||
# lodash v3.0.0
|
# lodash v3.1.0
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ define(['../internal/LodashWrapper', '../internal/arrayCopy', '../lang/isArray',
|
|||||||
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
|
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
|
||||||
* `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`,
|
* `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`,
|
||||||
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`,
|
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`,
|
||||||
* `isFunction`, `isMatch` , `isNative`, `isNaN`, `isNull`, `isNumber`,
|
* `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
|
||||||
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
|
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
|
||||||
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
|
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
|
||||||
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
|
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
|
||||||
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
|
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
|
||||||
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
|
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
|
||||||
* `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`,
|
* `startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`,
|
||||||
* `unescape`, `uniqueId`, `value`, and `words`
|
* `trunc`, `unescape`, `uniqueId`, `value`, and `words`
|
||||||
*
|
*
|
||||||
* The wrapper function `sample` will return a wrapped value when `n` is provided,
|
* The wrapper function `sample` will return a wrapped value when `n` is provided,
|
||||||
* otherwise an unwrapped value is returned.
|
* otherwise an unwrapped value is returned.
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./find', '../utility/matches'], function(find, matches) {
|
define(['../internal/baseMatches', './find'], function(baseMatches, find) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a deep comparison between each element in `collection` and the
|
* Performs a deep comparison between each element in `collection` and the
|
||||||
@@ -25,7 +25,7 @@ define(['./find', '../utility/matches'], function(find, matches) {
|
|||||||
* // => 'fred'
|
* // => 'fred'
|
||||||
*/
|
*/
|
||||||
function findWhere(collection, source) {
|
function findWhere(collection, source) {
|
||||||
return find(collection, matches(source));
|
return find(collection, baseMatches(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
return findWhere;
|
return findWhere;
|
||||||
|
|||||||
@@ -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); });
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./map', '../utility/property'], function(map, property) {
|
define(['../internal/baseProperty', './map'], function(baseProperty, map) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of `key` from all elements in `collection`.
|
* Gets the value of `key` from all elements in `collection`.
|
||||||
@@ -24,7 +24,7 @@ define(['./map', '../utility/property'], function(map, property) {
|
|||||||
* // => [36, 40] (iteration order is not guaranteed)
|
* // => [36, 40] (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function pluck(collection, key) {
|
function pluck(collection, key) {
|
||||||
return map(collection, property(key));
|
return map(collection, baseProperty(key + ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
return pluck;
|
return pluck;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./filter', '../utility/matches'], function(filter, matches) {
|
define(['../internal/baseMatches', './filter'], function(baseMatches, filter) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a deep comparison between each element in `collection` and the
|
* Performs a deep comparison between each element in `collection` and the
|
||||||
@@ -28,7 +28,7 @@ define(['./filter', '../utility/matches'], function(filter, matches) {
|
|||||||
* // => ['barney', 'fred']
|
* // => ['barney', 'fred']
|
||||||
*/
|
*/
|
||||||
function where(collection, source) {
|
function where(collection, source) {
|
||||||
return filter(collection, matches(source));
|
return filter(collection, baseMatches(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
return where;
|
return where;
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -22,8 +22,8 @@ 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)
|
||||||
: baseProperty(argCount ? baseToString(func) : func);
|
: baseProperty(func + '');
|
||||||
}
|
}
|
||||||
|
|
||||||
return baseCallback;
|
return baseCallback;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./baseClone', './baseIsMatch', './isStrictComparable', '../object/keys'], function(baseClone, baseIsMatch, isStrictComparable, keys) {
|
define(['./baseIsMatch', './isStrictComparable', '../object/keys'], function(baseIsMatch, isStrictComparable, keys) {
|
||||||
|
|
||||||
/** Used for native method references. */
|
/** Used for native method references. */
|
||||||
var objectProto = Object.prototype;
|
var objectProto = Object.prototype;
|
||||||
@@ -12,10 +12,9 @@ define(['./baseClone', './baseIsMatch', './isStrictComparable', '../object/keys'
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} source The object of property values to match.
|
* @param {Object} source The object of property values to match.
|
||||||
* @param {boolean} [isCloned] Specify cloning the source object.
|
|
||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
*/
|
*/
|
||||||
function baseMatches(source, isCloned) {
|
function baseMatches(source) {
|
||||||
var props = keys(source),
|
var props = keys(source),
|
||||||
length = props.length;
|
length = props.length;
|
||||||
|
|
||||||
@@ -29,9 +28,6 @@ define(['./baseClone', './baseIsMatch', './isStrictComparable', '../object/keys'
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isCloned) {
|
|
||||||
source = baseClone(source, true);
|
|
||||||
}
|
|
||||||
var values = Array(length),
|
var values = Array(length),
|
||||||
strictCompareFlags = Array(length);
|
strictCompareFlags = Array(length);
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used as the maximum length of an array-like value.
|
* Used as the maximum length of an array-like value.
|
||||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
|
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
|
||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ define(['./isIndex', './isLength', '../lang/isObject'], function(isIndex, isLeng
|
|||||||
var length = object.length,
|
var length = object.length,
|
||||||
prereq = isLength(length) && isIndex(index, length);
|
prereq = isLength(length) && isIndex(index, length);
|
||||||
} else {
|
} else {
|
||||||
prereq = type == 'string' && index in value;
|
prereq = type == 'string' && index in object;
|
||||||
}
|
}
|
||||||
return prereq && object[index] === value;
|
return prereq && object[index] === value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ define([], function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used as the maximum length of an array-like value.
|
* Used as the maximum length of an array-like value.
|
||||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
|
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
|
||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
||||||
@@ -10,6 +10,10 @@ define([], function() {
|
|||||||
/**
|
/**
|
||||||
* Checks if `value` is a valid array-like length.
|
* Checks if `value` is a valid array-like length.
|
||||||
*
|
*
|
||||||
|
* **Note:** This function is based on ES `ToLength`. See the
|
||||||
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
* @returns {boolean} Returns `true` if `value` is a valid length, else `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;
|
||||||
|
|||||||
129
main.js
129
main.js
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @license
|
* @license
|
||||||
* lodash 3.0.0 (Custom Build) <https://lodash.com/>
|
* lodash 3.1.0 (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.1.0';
|
||||||
|
|
||||||
/** Used to compose bitmasks for wrapper metadata. */
|
/** Used to compose bitmasks for wrapper metadata. */
|
||||||
var BIND_FLAG = 1,
|
var BIND_FLAG = 1,
|
||||||
@@ -766,7 +766,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used as the maximum length of an array-like value.
|
* Used as the maximum length of an array-like value.
|
||||||
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
|
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
|
||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;
|
||||||
@@ -824,14 +824,14 @@
|
|||||||
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
|
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
|
||||||
* `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`,
|
* `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`,
|
||||||
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`,
|
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`,
|
||||||
* `isFunction`, `isMatch` , `isNative`, `isNaN`, `isNull`, `isNumber`,
|
* `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
|
||||||
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
|
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
|
||||||
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
|
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
|
||||||
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
|
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
|
||||||
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
|
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
|
||||||
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
|
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
|
||||||
* `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`,
|
* `startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`,
|
||||||
* `unescape`, `uniqueId`, `value`, and `words`
|
* `trunc`, `unescape`, `uniqueId`, `value`, and `words`
|
||||||
*
|
*
|
||||||
* The wrapper function `sample` will return a wrapped value when `n` is provided,
|
* The wrapper function `sample` will return a wrapped value when `n` is provided,
|
||||||
* otherwise an unwrapped value is returned.
|
* otherwise an unwrapped value is returned.
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
@@ -1641,8 +1644,8 @@
|
|||||||
}
|
}
|
||||||
// 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)
|
||||||
: baseProperty(argCount ? baseToString(func) : func);
|
: baseProperty(func + '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2262,10 +2265,9 @@
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} source The object of property values to match.
|
* @param {Object} source The object of property values to match.
|
||||||
* @param {boolean} [isCloned] Specify cloning the source object.
|
|
||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
*/
|
*/
|
||||||
function baseMatches(source, isCloned) {
|
function baseMatches(source) {
|
||||||
var props = keys(source),
|
var props = keys(source),
|
||||||
length = props.length;
|
length = props.length;
|
||||||
|
|
||||||
@@ -2279,9 +2281,6 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isCloned) {
|
|
||||||
source = baseClone(source, true);
|
|
||||||
}
|
|
||||||
var values = Array(length),
|
var values = Array(length),
|
||||||
strictCompareFlags = Array(length);
|
strictCompareFlags = Array(length);
|
||||||
|
|
||||||
@@ -2372,6 +2371,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 +2495,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 +3103,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 +3296,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;
|
||||||
}
|
}
|
||||||
@@ -3588,7 +3591,7 @@
|
|||||||
var length = object.length,
|
var length = object.length,
|
||||||
prereq = isLength(length) && isIndex(index, length);
|
prereq = isLength(length) && isIndex(index, length);
|
||||||
} else {
|
} else {
|
||||||
prereq = type == 'string' && index in value;
|
prereq = type == 'string' && index in object;
|
||||||
}
|
}
|
||||||
return prereq && object[index] === value;
|
return prereq && object[index] === value;
|
||||||
}
|
}
|
||||||
@@ -3596,6 +3599,10 @@
|
|||||||
/**
|
/**
|
||||||
* Checks if `value` is a valid array-like length.
|
* Checks if `value` is a valid array-like length.
|
||||||
*
|
*
|
||||||
|
* **Note:** This function is based on ES `ToLength`. See the
|
||||||
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {*} value The value to check.
|
* @param {*} value The value to check.
|
||||||
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
* @returns {boolean} Returns `true` if `value` is a valid length, else `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) {
|
||||||
@@ -5663,7 +5673,7 @@
|
|||||||
* // => 'fred'
|
* // => 'fred'
|
||||||
*/
|
*/
|
||||||
function findWhere(collection, source) {
|
function findWhere(collection, source) {
|
||||||
return find(collection, matches(source));
|
return find(collection, baseMatches(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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); });
|
||||||
@@ -6040,7 +6050,7 @@
|
|||||||
* // => [36, 40] (iteration order is not guaranteed)
|
* // => [36, 40] (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function pluck(collection, key) {
|
function pluck(collection, key) {
|
||||||
return map(collection, property(key));
|
return map(collection, baseProperty(key + ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6411,7 +6421,7 @@
|
|||||||
* // => ['barney', 'fred']
|
* // => ['barney', 'fred']
|
||||||
*/
|
*/
|
||||||
function where(collection, source) {
|
function where(collection, source) {
|
||||||
return filter(collection, matches(source));
|
return filter(collection, baseMatches(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
@@ -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'
|
||||||
*
|
*
|
||||||
@@ -9056,7 +9066,7 @@
|
|||||||
*/
|
*/
|
||||||
var camelCase = createCompounder(function(result, word, index) {
|
var camelCase = createCompounder(function(result, word, index) {
|
||||||
word = word.toLowerCase();
|
word = word.toLowerCase();
|
||||||
return index ? (result + word.charAt(0).toUpperCase() + word.slice(1)) : word;
|
return result + (index ? (word.charAt(0).toUpperCase() + word.slice(1)) : word);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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
|
||||||
@@ -9407,16 +9417,41 @@
|
|||||||
* _.snakeCase('Foo Bar');
|
* _.snakeCase('Foo Bar');
|
||||||
* // => 'foo_bar'
|
* // => 'foo_bar'
|
||||||
*
|
*
|
||||||
* _.snakeCase('--foo-bar');
|
* _.snakeCase('fooBar');
|
||||||
* // => 'foo_bar'
|
* // => 'foo_bar'
|
||||||
*
|
*
|
||||||
* _.snakeCase('fooBar');
|
* _.snakeCase('--foo-bar');
|
||||||
* // => 'foo_bar'
|
* // => 'foo_bar'
|
||||||
*/
|
*/
|
||||||
var snakeCase = createCompounder(function(result, word, index) {
|
var snakeCase = createCompounder(function(result, word, index) {
|
||||||
return result + (index ? '_' : '') + word.toLowerCase();
|
return result + (index ? '_' : '') + word.toLowerCase();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts `string` to start case.
|
||||||
|
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage)
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @category String
|
||||||
|
* @param {string} [string=''] The string to convert.
|
||||||
|
* @returns {string} Returns the start cased string.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* _.startCase('--foo-bar');
|
||||||
|
* // => 'Foo Bar'
|
||||||
|
*
|
||||||
|
* _.startCase('fooBar');
|
||||||
|
* // => 'Foo Bar'
|
||||||
|
*
|
||||||
|
* _.startCase('__foo_bar__');
|
||||||
|
* // => 'Foo Bar'
|
||||||
|
*/
|
||||||
|
var startCase = createCompounder(function(result, word, index) {
|
||||||
|
return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1));
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `string` starts with the given target string.
|
* Checks if `string` starts with the given target string.
|
||||||
*
|
*
|
||||||
@@ -9676,7 +9711,7 @@
|
|||||||
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
||||||
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
|
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
|
||||||
}
|
}
|
||||||
chars = baseToString(chars);
|
chars = (chars + '');
|
||||||
return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
|
return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9707,7 +9742,7 @@
|
|||||||
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
||||||
return string.slice(trimmedLeftIndex(string))
|
return string.slice(trimmedLeftIndex(string))
|
||||||
}
|
}
|
||||||
return string.slice(charsLeftIndex(string, baseToString(chars)));
|
return string.slice(charsLeftIndex(string, (chars + '')));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9737,7 +9772,7 @@
|
|||||||
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
||||||
return string.slice(0, trimmedRightIndex(string) + 1)
|
return string.slice(0, trimmedRightIndex(string) + 1)
|
||||||
}
|
}
|
||||||
return string.slice(0, charsRightIndex(string, baseToString(chars)) + 1);
|
return string.slice(0, charsRightIndex(string, (chars + '')) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9944,7 +9979,9 @@
|
|||||||
if (guard && isIterateeCall(func, thisArg, guard)) {
|
if (guard && isIterateeCall(func, thisArg, guard)) {
|
||||||
thisArg = null;
|
thisArg = null;
|
||||||
}
|
}
|
||||||
return baseCallback(func, thisArg);
|
return isObjectLike(func)
|
||||||
|
? matches(func)
|
||||||
|
: baseCallback(func, thisArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10012,7 +10049,7 @@
|
|||||||
* // => { 'user': 'barney', 'age': 36 }
|
* // => { 'user': 'barney', 'age': 36 }
|
||||||
*/
|
*/
|
||||||
function matches(source) {
|
function matches(source) {
|
||||||
return baseMatches(source, true);
|
return baseMatches(baseClone(source, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10509,6 +10546,7 @@
|
|||||||
lodash.some = some;
|
lodash.some = some;
|
||||||
lodash.sortedIndex = sortedIndex;
|
lodash.sortedIndex = sortedIndex;
|
||||||
lodash.sortedLastIndex = sortedLastIndex;
|
lodash.sortedLastIndex = sortedLastIndex;
|
||||||
|
lodash.startCase = startCase;
|
||||||
lodash.startsWith = startsWith;
|
lodash.startsWith = startsWith;
|
||||||
lodash.template = template;
|
lodash.template = template;
|
||||||
lodash.trim = trim;
|
lodash.trim = trim;
|
||||||
@@ -10634,10 +10672,10 @@
|
|||||||
// Add `LazyWrapper` methods for `_.pluck` and `_.where`.
|
// Add `LazyWrapper` methods for `_.pluck` and `_.where`.
|
||||||
arrayEach(['pluck', 'where'], function(methodName, index) {
|
arrayEach(['pluck', 'where'], function(methodName, index) {
|
||||||
var operationName = index ? 'filter' : 'map',
|
var operationName = index ? 'filter' : 'map',
|
||||||
createCallback = index ? matches : property;
|
createCallback = index ? baseMatches : baseProperty;
|
||||||
|
|
||||||
LazyWrapper.prototype[methodName] = function(value) {
|
LazyWrapper.prototype[methodName] = function(value) {
|
||||||
return this[operationName](createCallback(value));
|
return this[operationName](createCallback(index ? value : (value + '')));
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -10674,7 +10712,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 +10726,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.1.0",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
"volo": {
|
"volo": {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['./string/camelCase', './string/capitalize', './string/deburr', './string/endsWith', './string/escape', './string/escapeRegExp', './string/kebabCase', './string/pad', './string/padLeft', './string/padRight', './string/parseInt', './string/repeat', './string/snakeCase', './string/startsWith', './string/template', './string/templateSettings', './string/trim', './string/trimLeft', './string/trimRight', './string/trunc', './string/unescape', './string/words'], function(camelCase, capitalize, deburr, endsWith, escape, escapeRegExp, kebabCase, pad, padLeft, padRight, parseInt, repeat, snakeCase, startsWith, template, templateSettings, trim, trimLeft, trimRight, trunc, unescape, words) {
|
define(['./string/camelCase', './string/capitalize', './string/deburr', './string/endsWith', './string/escape', './string/escapeRegExp', './string/kebabCase', './string/pad', './string/padLeft', './string/padRight', './string/parseInt', './string/repeat', './string/snakeCase', './string/startCase', './string/startsWith', './string/template', './string/templateSettings', './string/trim', './string/trimLeft', './string/trimRight', './string/trunc', './string/unescape', './string/words'], function(camelCase, capitalize, deburr, endsWith, escape, escapeRegExp, kebabCase, pad, padLeft, padRight, parseInt, repeat, snakeCase, startCase, startsWith, template, templateSettings, trim, trimLeft, trimRight, trunc, unescape, words) {
|
||||||
return {
|
return {
|
||||||
'camelCase': camelCase,
|
'camelCase': camelCase,
|
||||||
'capitalize': capitalize,
|
'capitalize': capitalize,
|
||||||
@@ -13,6 +13,7 @@ define(['./string/camelCase', './string/capitalize', './string/deburr', './strin
|
|||||||
'parseInt': parseInt,
|
'parseInt': parseInt,
|
||||||
'repeat': repeat,
|
'repeat': repeat,
|
||||||
'snakeCase': snakeCase,
|
'snakeCase': snakeCase,
|
||||||
|
'startCase': startCase,
|
||||||
'startsWith': startsWith,
|
'startsWith': startsWith,
|
||||||
'template': template,
|
'template': template,
|
||||||
'templateSettings': templateSettings,
|
'templateSettings': templateSettings,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ define(['../internal/createCompounder'], function(createCompounder) {
|
|||||||
*/
|
*/
|
||||||
var camelCase = createCompounder(function(result, word, index) {
|
var camelCase = createCompounder(function(result, word, index) {
|
||||||
word = word.toLowerCase();
|
word = word.toLowerCase();
|
||||||
return index ? (result + word.charAt(0).toUpperCase() + word.slice(1)) : word;
|
return result + (index ? (word.charAt(0).toUpperCase() + word.slice(1)) : word);
|
||||||
});
|
});
|
||||||
|
|
||||||
return camelCase;
|
return camelCase;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ define(['../internal/createCompounder'], function(createCompounder) {
|
|||||||
* _.snakeCase('Foo Bar');
|
* _.snakeCase('Foo Bar');
|
||||||
* // => 'foo_bar'
|
* // => 'foo_bar'
|
||||||
*
|
*
|
||||||
* _.snakeCase('--foo-bar');
|
* _.snakeCase('fooBar');
|
||||||
* // => 'foo_bar'
|
* // => 'foo_bar'
|
||||||
*
|
*
|
||||||
* _.snakeCase('fooBar');
|
* _.snakeCase('--foo-bar');
|
||||||
* // => 'foo_bar'
|
* // => 'foo_bar'
|
||||||
*/
|
*/
|
||||||
var snakeCase = createCompounder(function(result, word, index) {
|
var snakeCase = createCompounder(function(result, word, index) {
|
||||||
|
|||||||
29
string/startCase.js
Normal file
29
string/startCase.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
define(['../internal/createCompounder'], function(createCompounder) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts `string` to start case.
|
||||||
|
* See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage)
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @memberOf _
|
||||||
|
* @category String
|
||||||
|
* @param {string} [string=''] The string to convert.
|
||||||
|
* @returns {string} Returns the start cased string.
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* _.startCase('--foo-bar');
|
||||||
|
* // => 'Foo Bar'
|
||||||
|
*
|
||||||
|
* _.startCase('fooBar');
|
||||||
|
* // => 'Foo Bar'
|
||||||
|
*
|
||||||
|
* _.startCase('__foo_bar__');
|
||||||
|
* // => 'Foo Bar'
|
||||||
|
*/
|
||||||
|
var startCase = createCompounder(function(result, word, index) {
|
||||||
|
return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1));
|
||||||
|
});
|
||||||
|
|
||||||
|
return startCase;
|
||||||
|
});
|
||||||
@@ -30,7 +30,7 @@ define(['../internal/baseToString', '../internal/charsLeftIndex', '../internal/c
|
|||||||
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
||||||
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
|
return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);
|
||||||
}
|
}
|
||||||
chars = baseToString(chars);
|
chars = (chars + '');
|
||||||
return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
|
return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ define(['../internal/baseToString', '../internal/charsLeftIndex', '../internal/i
|
|||||||
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
||||||
return string.slice(trimmedLeftIndex(string))
|
return string.slice(trimmedLeftIndex(string))
|
||||||
}
|
}
|
||||||
return string.slice(charsLeftIndex(string, baseToString(chars)));
|
return string.slice(charsLeftIndex(string, (chars + '')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return trimLeft;
|
return trimLeft;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ define(['../internal/baseToString', '../internal/charsRightIndex', '../internal/
|
|||||||
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
|
||||||
return string.slice(0, trimmedRightIndex(string) + 1)
|
return string.slice(0, trimmedRightIndex(string) + 1)
|
||||||
}
|
}
|
||||||
return string.slice(0, charsRightIndex(string, baseToString(chars)) + 1);
|
return string.slice(0, charsRightIndex(string, (chars + '')) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return trimRight;
|
return trimRight;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseCallback', '../internal/isIterateeCall'], function(baseCallback, isIterateeCall) {
|
define(['../internal/baseCallback', '../internal/isIterateeCall', '../internal/isObjectLike', './matches'], function(baseCallback, isIterateeCall, isObjectLike, matches) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function bound to an optional `thisArg`. If `func` is a property
|
* Creates a function bound to an optional `thisArg`. If `func` is a property
|
||||||
@@ -39,7 +39,9 @@ define(['../internal/baseCallback', '../internal/isIterateeCall'], function(base
|
|||||||
if (guard && isIterateeCall(func, thisArg, guard)) {
|
if (guard && isIterateeCall(func, thisArg, guard)) {
|
||||||
thisArg = null;
|
thisArg = null;
|
||||||
}
|
}
|
||||||
return baseCallback(func, thisArg);
|
return isObjectLike(func)
|
||||||
|
? matches(func)
|
||||||
|
: baseCallback(func, thisArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return callback;
|
return callback;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
define(['../internal/baseMatches'], function(baseMatches) {
|
define(['../internal/baseClone', '../internal/baseMatches'], function(baseClone, baseMatches) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function which performs a deep comparison between a given object
|
* Creates a function which performs a deep comparison between a given object
|
||||||
@@ -26,7 +26,7 @@ define(['../internal/baseMatches'], function(baseMatches) {
|
|||||||
* // => { 'user': 'barney', 'age': 36 }
|
* // => { 'user': 'barney', 'age': 36 }
|
||||||
*/
|
*/
|
||||||
function matches(source) {
|
function matches(source) {
|
||||||
return baseMatches(source, true);
|
return baseMatches(baseClone(source, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
|
|||||||
Reference in New Issue
Block a user