mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Remove guard params.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* The base implementation of `slice` without an iteratee call guard.
|
* The base implementation of `slice`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array} array The array to slice.
|
* @param {Array} array The array to slice.
|
||||||
|
|||||||
4
ary.js
4
ary.js
@@ -11,15 +11,13 @@ const WRAP_ARY_FLAG = 128
|
|||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to cap arguments for.
|
* @param {Function} func The function to cap arguments for.
|
||||||
* @param {number} [n=func.length] The arity cap.
|
* @param {number} [n=func.length] The arity cap.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {Function} Returns the new capped function.
|
* @returns {Function} Returns the new capped function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* map(['6', '8', '10'], ary(parseInt, 1))
|
* map(['6', '8', '10'], ary(parseInt, 1))
|
||||||
* // => [6, 8, 10]
|
* // => [6, 8, 10]
|
||||||
*/
|
*/
|
||||||
function ary(func, n, guard) {
|
function ary(func, n) {
|
||||||
n = guard ? undefined : n
|
|
||||||
n = (func && n == null) ? func.length : n
|
n = (func && n == null) ? func.length : n
|
||||||
return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n)
|
return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n)
|
||||||
}
|
}
|
||||||
|
|||||||
4
curry.js
4
curry.js
@@ -19,7 +19,6 @@ const WRAP_CURRY_FLAG = 8
|
|||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to curry.
|
* @param {Function} func The function to curry.
|
||||||
* @param {number} [arity=func.length] The arity of `func`.
|
* @param {number} [arity=func.length] The arity of `func`.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {Function} Returns the new curried function.
|
* @returns {Function} Returns the new curried function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -42,8 +41,7 @@ const WRAP_CURRY_FLAG = 8
|
|||||||
* curried(1)(_, 3)(2)
|
* curried(1)(_, 3)(2)
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*/
|
*/
|
||||||
function curry(func, arity, guard) {
|
function curry(func, arity) {
|
||||||
arity = guard ? undefined : arity
|
|
||||||
const result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity)
|
const result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity)
|
||||||
result.placeholder = curry.placeholder
|
result.placeholder = curry.placeholder
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ const WRAP_CURRY_RIGHT_FLAG = 16
|
|||||||
* @category Function
|
* @category Function
|
||||||
* @param {Function} func The function to curry.
|
* @param {Function} func The function to curry.
|
||||||
* @param {number} [arity=func.length] The arity of `func`.
|
* @param {number} [arity=func.length] The arity of `func`.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {Function} Returns the new curried function.
|
* @returns {Function} Returns the new curried function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -39,8 +38,7 @@ const WRAP_CURRY_RIGHT_FLAG = 16
|
|||||||
* curried(3)(1, _)(2)
|
* curried(3)(1, _)(2)
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*/
|
*/
|
||||||
function curryRight(func, arity, guard) {
|
function curryRight(func, arity) {
|
||||||
arity = guard ? undefined : arity
|
|
||||||
const result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity)
|
const result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity)
|
||||||
result.placeholder = curryRight.placeholder
|
result.placeholder = curryRight.placeholder
|
||||||
return result
|
return result
|
||||||
|
|||||||
5
drop.js
5
drop.js
@@ -8,7 +8,6 @@ import toInteger from './toInteger.js'
|
|||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to query.
|
||||||
* @param {number} [n=1] The number of elements to drop.
|
* @param {number} [n=1] The number of elements to drop.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
* @returns {Array} Returns the slice of `array`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -24,12 +23,12 @@ import toInteger from './toInteger.js'
|
|||||||
* drop([1, 2, 3], 0)
|
* drop([1, 2, 3], 0)
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*/
|
*/
|
||||||
function drop(array, n, guard) {
|
function drop(array, n=1) {
|
||||||
const length = array == null ? 0 : array.length
|
const length = array == null ? 0 : array.length
|
||||||
if (!length) {
|
if (!length) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
n = (guard || n === undefined) ? 1 : toInteger(n)
|
n = toInteger(n)
|
||||||
return baseSlice(array, n < 0 ? 0 : n, length)
|
return baseSlice(array, n < 0 ? 0 : n, length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import toInteger from './toInteger.js'
|
|||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to query.
|
||||||
* @param {number} [n=1] The number of elements to drop.
|
* @param {number} [n=1] The number of elements to drop.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
* @returns {Array} Returns the slice of `array`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -24,12 +23,12 @@ import toInteger from './toInteger.js'
|
|||||||
* dropRight([1, 2, 3], 0)
|
* dropRight([1, 2, 3], 0)
|
||||||
* // => [1, 2, 3]
|
* // => [1, 2, 3]
|
||||||
*/
|
*/
|
||||||
function dropRight(array, n, guard) {
|
function dropRight(array, n=1) {
|
||||||
const length = array == null ? 0 : array.length
|
const length = array == null ? 0 : array.length
|
||||||
if (!length) {
|
if (!length) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
n = (guard || n === undefined) ? 1 : toInteger(n)
|
n = toInteger(n)
|
||||||
n = length - n
|
n = length - n
|
||||||
return baseSlice(array, 0, n < 0 ? 0 : n)
|
return baseSlice(array, 0, n < 0 ? 0 : n)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import baseOrderBy from './.internal/baseOrderBy.js'
|
|||||||
* @param {Array[]|Function[]|Object[]|string[]} [iteratees=[identity]]
|
* @param {Array[]|Function[]|Object[]|string[]} [iteratees=[identity]]
|
||||||
* The iteratees to sort by.
|
* The iteratees to sort by.
|
||||||
* @param {string[]} [orders] The sort orders of `iteratees`.
|
* @param {string[]} [orders] The sort orders of `iteratees`.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `reduce`.
|
|
||||||
* @returns {Array} Returns the new sorted array.
|
* @returns {Array} Returns the new sorted array.
|
||||||
* @see reverse
|
* @see reverse
|
||||||
* @example
|
* @example
|
||||||
@@ -28,14 +27,13 @@ import baseOrderBy from './.internal/baseOrderBy.js'
|
|||||||
* orderBy(users, ['user', 'age'], ['asc', 'desc'])
|
* orderBy(users, ['user', 'age'], ['asc', 'desc'])
|
||||||
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
|
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
|
||||||
*/
|
*/
|
||||||
function orderBy(collection, iteratees, orders, guard) {
|
function orderBy(collection, iteratees, orders) {
|
||||||
if (collection == null) {
|
if (collection == null) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
if (!Array.isArray(iteratees)) {
|
if (!Array.isArray(iteratees)) {
|
||||||
iteratees = iteratees == null ? [] : [iteratees]
|
iteratees = iteratees == null ? [] : [iteratees]
|
||||||
}
|
}
|
||||||
orders = guard ? undefined : orders
|
|
||||||
if (!Array.isArray(orders)) {
|
if (!Array.isArray(orders)) {
|
||||||
orders = orders == null ? [] : [orders]
|
orders = orders == null ? [] : [orders]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ const nativeParseInt = root.parseInt
|
|||||||
* @category String
|
* @category String
|
||||||
* @param {string} string The string to convert.
|
* @param {string} string The string to convert.
|
||||||
* @param {number} [radix=10] The radix to interpret `value` by.
|
* @param {number} [radix=10] The radix to interpret `value` by.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {number} Returns the converted integer.
|
* @returns {number} Returns the converted integer.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -29,8 +28,8 @@ const nativeParseInt = root.parseInt
|
|||||||
* map(['6', '08', '10'], parseInt)
|
* map(['6', '08', '10'], parseInt)
|
||||||
* // => [6, 8, 10]
|
* // => [6, 8, 10]
|
||||||
*/
|
*/
|
||||||
function parseInt(string, radix, guard) {
|
function parseInt(string, radix) {
|
||||||
if (guard || radix == null) {
|
if (radix == null) {
|
||||||
radix = 0
|
radix = 0
|
||||||
} else if (radix) {
|
} else if (radix) {
|
||||||
radix = +radix
|
radix = +radix
|
||||||
|
|||||||
5
take.js
5
take.js
@@ -8,7 +8,6 @@ import toInteger from './toInteger.js'
|
|||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to query.
|
||||||
* @param {number} [n=1] The number of elements to take.
|
* @param {number} [n=1] The number of elements to take.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
* @returns {Array} Returns the slice of `array`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -24,11 +23,11 @@ import toInteger from './toInteger.js'
|
|||||||
* take([1, 2, 3], 0)
|
* take([1, 2, 3], 0)
|
||||||
* // => []
|
* // => []
|
||||||
*/
|
*/
|
||||||
function take(array, n, guard) {
|
function take(array, n=1) {
|
||||||
if (!(array != null && array.length)) {
|
if (!(array != null && array.length)) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
n = (guard || n === undefined) ? 1 : toInteger(n)
|
n = toInteger(n)
|
||||||
return baseSlice(array, 0, n < 0 ? 0 : n)
|
return baseSlice(array, 0, n < 0 ? 0 : n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import toInteger from './toInteger.js'
|
|||||||
* @category Array
|
* @category Array
|
||||||
* @param {Array} array The array to query.
|
* @param {Array} array The array to query.
|
||||||
* @param {number} [n=1] The number of elements to take.
|
* @param {number} [n=1] The number of elements to take.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {Array} Returns the slice of `array`.
|
* @returns {Array} Returns the slice of `array`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -24,12 +23,12 @@ import toInteger from './toInteger.js'
|
|||||||
* takeRight([1, 2, 3], 0)
|
* takeRight([1, 2, 3], 0)
|
||||||
* // => []
|
* // => []
|
||||||
*/
|
*/
|
||||||
function takeRight(array, n, guard) {
|
function takeRight(array, n=1) {
|
||||||
const length = array == null ? 0 : array.length
|
const length = array == null ? 0 : array.length
|
||||||
if (!length) {
|
if (!length) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
n = (guard || n === undefined) ? 1 : toInteger(n)
|
n = toInteger(n)
|
||||||
n = length - n
|
n = length - n
|
||||||
return baseSlice(array, n < 0 ? 0 : n, length)
|
return baseSlice(array, n < 0 ? 0 : n, length)
|
||||||
}
|
}
|
||||||
|
|||||||
5
trim.js
5
trim.js
@@ -12,7 +12,6 @@ import toString from './toString.js'
|
|||||||
* @category String
|
* @category String
|
||||||
* @param {string} [string=''] The string to trim.
|
* @param {string} [string=''] The string to trim.
|
||||||
* @param {string} [chars=whitespace] The characters to trim.
|
* @param {string} [chars=whitespace] The characters to trim.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {string} Returns the trimmed string.
|
* @returns {string} Returns the trimmed string.
|
||||||
* @see trimEnd, trimStart
|
* @see trimEnd, trimStart
|
||||||
* @example
|
* @example
|
||||||
@@ -26,9 +25,9 @@ import toString from './toString.js'
|
|||||||
* map([' foo ', ' bar '], trim)
|
* map([' foo ', ' bar '], trim)
|
||||||
* // => ['foo', 'bar']
|
* // => ['foo', 'bar']
|
||||||
*/
|
*/
|
||||||
function trim(string, chars, guard) {
|
function trim(string, chars) {
|
||||||
string = toString(string)
|
string = toString(string)
|
||||||
if (string && (guard || chars === undefined)) {
|
if (string && chars === undefined) {
|
||||||
return string.trim()
|
return string.trim()
|
||||||
}
|
}
|
||||||
if (!string || !(chars = baseToString(chars))) {
|
if (!string || !(chars = baseToString(chars))) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ const methodName = ''.trimRight ? 'trimRight': 'trimEnd'
|
|||||||
* @category String
|
* @category String
|
||||||
* @param {string} [string=''] The string to trim.
|
* @param {string} [string=''] The string to trim.
|
||||||
* @param {string} [chars=whitespace] The characters to trim.
|
* @param {string} [chars=whitespace] The characters to trim.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {string} Returns the trimmed string.
|
* @returns {string} Returns the trimmed string.
|
||||||
* @see trim, trimStart
|
* @see trim, trimStart
|
||||||
* @example
|
* @example
|
||||||
@@ -24,9 +23,9 @@ const methodName = ''.trimRight ? 'trimRight': 'trimEnd'
|
|||||||
* trimEnd('-_-abc-_-', '_-')
|
* trimEnd('-_-abc-_-', '_-')
|
||||||
* // => '-_-abc'
|
* // => '-_-abc'
|
||||||
*/
|
*/
|
||||||
function trimEnd(string, chars, guard) {
|
function trimEnd(string, chars) {
|
||||||
string = toString(string)
|
string = toString(string)
|
||||||
if (string && (guard || chars === undefined)) {
|
if (string && chars === undefined) {
|
||||||
return string[methodName]()
|
return string[methodName]()
|
||||||
}
|
}
|
||||||
if (!string || !(chars = baseToString(chars))) {
|
if (!string || !(chars = baseToString(chars))) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ const methodName = ''.trimLeft ? 'trimLeft' : 'trimStart'
|
|||||||
* @category String
|
* @category String
|
||||||
* @param {string} [string=''] The string to trim.
|
* @param {string} [string=''] The string to trim.
|
||||||
* @param {string} [chars=whitespace] The characters to trim.
|
* @param {string} [chars=whitespace] The characters to trim.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {string} Returns the trimmed string.
|
* @returns {string} Returns the trimmed string.
|
||||||
* @see trim, trimEnd
|
* @see trim, trimEnd
|
||||||
* @example
|
* @example
|
||||||
@@ -24,9 +23,9 @@ const methodName = ''.trimLeft ? 'trimLeft' : 'trimStart'
|
|||||||
* trimStart('-_-abc-_-', '_-')
|
* trimStart('-_-abc-_-', '_-')
|
||||||
* // => 'abc-_-'
|
* // => 'abc-_-'
|
||||||
*/
|
*/
|
||||||
function trimStart(string, chars, guard) {
|
function trimStart(string, chars) {
|
||||||
string = toString(string)
|
string = toString(string)
|
||||||
if (string && (guard || chars === undefined)) {
|
if (string && chars === undefined) {
|
||||||
return string[methodName]()
|
return string[methodName]()
|
||||||
}
|
}
|
||||||
if (!string || !(chars = baseToString(chars))) {
|
if (!string || !(chars = baseToString(chars))) {
|
||||||
|
|||||||
5
words.js
5
words.js
@@ -10,7 +10,6 @@ import unicodeWords from './.internal/unicodeWords.js'
|
|||||||
* @category String
|
* @category String
|
||||||
* @param {string} [string=''] The string to inspect.
|
* @param {string} [string=''] The string to inspect.
|
||||||
* @param {RegExp|string} [pattern] The pattern to match words.
|
* @param {RegExp|string} [pattern] The pattern to match words.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for methods like `map`.
|
|
||||||
* @returns {Array} Returns the words of `string`.
|
* @returns {Array} Returns the words of `string`.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
@@ -20,10 +19,8 @@ import unicodeWords from './.internal/unicodeWords.js'
|
|||||||
* words('fred, barney, & pebbles', /[^, ]+/g)
|
* words('fred, barney, & pebbles', /[^, ]+/g)
|
||||||
* // => ['fred', 'barney', '&', 'pebbles']
|
* // => ['fred', 'barney', '&', 'pebbles']
|
||||||
*/
|
*/
|
||||||
function words(string, pattern, guard) {
|
function words(string, pattern) {
|
||||||
string = toString(string)
|
string = toString(string)
|
||||||
pattern = guard ? undefined : pattern
|
|
||||||
|
|
||||||
if (pattern === undefined) {
|
if (pattern === undefined) {
|
||||||
return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string)
|
return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user