Remove guard params.

This commit is contained in:
John-David Dalton
2017-03-05 02:37:18 -08:00
parent 89829331f0
commit bda6d56c60
14 changed files with 22 additions and 41 deletions

View File

@@ -1,5 +1,5 @@
/**
* The base implementation of `slice` without an iteratee call guard.
* The base implementation of `slice`.
*
* @private
* @param {Array} array The array to slice.

4
ary.js
View File

@@ -11,15 +11,13 @@ const WRAP_ARY_FLAG = 128
* @category Function
* @param {Function} func The function to cap arguments for.
* @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.
* @example
*
* map(['6', '8', '10'], ary(parseInt, 1))
* // => [6, 8, 10]
*/
function ary(func, n, guard) {
n = guard ? undefined : n
function ary(func, n) {
n = (func && n == null) ? func.length : n
return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n)
}

View File

@@ -19,7 +19,6 @@ const WRAP_CURRY_FLAG = 8
* @category Function
* @param {Function} func The function to curry.
* @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.
* @example
*
@@ -42,8 +41,7 @@ const WRAP_CURRY_FLAG = 8
* curried(1)(_, 3)(2)
* // => [1, 2, 3]
*/
function curry(func, arity, guard) {
arity = guard ? undefined : arity
function curry(func, arity) {
const result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity)
result.placeholder = curry.placeholder
return result

View File

@@ -16,7 +16,6 @@ const WRAP_CURRY_RIGHT_FLAG = 16
* @category Function
* @param {Function} func The function to curry.
* @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.
* @example
*
@@ -39,8 +38,7 @@ const WRAP_CURRY_RIGHT_FLAG = 16
* curried(3)(1, _)(2)
* // => [1, 2, 3]
*/
function curryRight(func, arity, guard) {
arity = guard ? undefined : arity
function curryRight(func, arity) {
const result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity)
result.placeholder = curryRight.placeholder
return result

View File

@@ -8,7 +8,6 @@ import toInteger from './toInteger.js'
* @category Array
* @param {Array} array The array to query.
* @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`.
* @example
*
@@ -24,12 +23,12 @@ import toInteger from './toInteger.js'
* drop([1, 2, 3], 0)
* // => [1, 2, 3]
*/
function drop(array, n, guard) {
function drop(array, n=1) {
const length = array == null ? 0 : array.length
if (!length) {
return []
}
n = (guard || n === undefined) ? 1 : toInteger(n)
n = toInteger(n)
return baseSlice(array, n < 0 ? 0 : n, length)
}

View File

@@ -8,7 +8,6 @@ import toInteger from './toInteger.js'
* @category Array
* @param {Array} array The array to query.
* @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`.
* @example
*
@@ -24,12 +23,12 @@ import toInteger from './toInteger.js'
* dropRight([1, 2, 3], 0)
* // => [1, 2, 3]
*/
function dropRight(array, n, guard) {
function dropRight(array, n=1) {
const length = array == null ? 0 : array.length
if (!length) {
return []
}
n = (guard || n === undefined) ? 1 : toInteger(n)
n = toInteger(n)
n = length - n
return baseSlice(array, 0, n < 0 ? 0 : n)
}

View File

@@ -12,7 +12,6 @@ import baseOrderBy from './.internal/baseOrderBy.js'
* @param {Array[]|Function[]|Object[]|string[]} [iteratees=[identity]]
* The iteratees to sort by.
* @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.
* @see reverse
* @example
@@ -28,14 +27,13 @@ import baseOrderBy from './.internal/baseOrderBy.js'
* orderBy(users, ['user', 'age'], ['asc', 'desc'])
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
*/
function orderBy(collection, iteratees, orders, guard) {
function orderBy(collection, iteratees, orders) {
if (collection == null) {
return []
}
if (!Array.isArray(iteratees)) {
iteratees = iteratees == null ? [] : [iteratees]
}
orders = guard ? undefined : orders
if (!Array.isArray(orders)) {
orders = orders == null ? [] : [orders]
}

View File

@@ -19,7 +19,6 @@ const nativeParseInt = root.parseInt
* @category String
* @param {string} string The string to convert.
* @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.
* @example
*
@@ -29,8 +28,8 @@ const nativeParseInt = root.parseInt
* map(['6', '08', '10'], parseInt)
* // => [6, 8, 10]
*/
function parseInt(string, radix, guard) {
if (guard || radix == null) {
function parseInt(string, radix) {
if (radix == null) {
radix = 0
} else if (radix) {
radix = +radix

View File

@@ -8,7 +8,6 @@ import toInteger from './toInteger.js'
* @category Array
* @param {Array} array The array to query.
* @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`.
* @example
*
@@ -24,11 +23,11 @@ import toInteger from './toInteger.js'
* take([1, 2, 3], 0)
* // => []
*/
function take(array, n, guard) {
function take(array, n=1) {
if (!(array != null && array.length)) {
return []
}
n = (guard || n === undefined) ? 1 : toInteger(n)
n = toInteger(n)
return baseSlice(array, 0, n < 0 ? 0 : n)
}

View File

@@ -8,7 +8,6 @@ import toInteger from './toInteger.js'
* @category Array
* @param {Array} array The array to query.
* @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`.
* @example
*
@@ -24,12 +23,12 @@ import toInteger from './toInteger.js'
* takeRight([1, 2, 3], 0)
* // => []
*/
function takeRight(array, n, guard) {
function takeRight(array, n=1) {
const length = array == null ? 0 : array.length
if (!length) {
return []
}
n = (guard || n === undefined) ? 1 : toInteger(n)
n = toInteger(n)
n = length - n
return baseSlice(array, n < 0 ? 0 : n, length)
}

View File

@@ -12,7 +12,6 @@ import toString from './toString.js'
* @category String
* @param {string} [string=''] The string 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.
* @see trimEnd, trimStart
* @example
@@ -26,9 +25,9 @@ import toString from './toString.js'
* map([' foo ', ' bar '], trim)
* // => ['foo', 'bar']
*/
function trim(string, chars, guard) {
function trim(string, chars) {
string = toString(string)
if (string && (guard || chars === undefined)) {
if (string && chars === undefined) {
return string.trim()
}
if (!string || !(chars = baseToString(chars))) {

View File

@@ -13,7 +13,6 @@ const methodName = ''.trimRight ? 'trimRight': 'trimEnd'
* @category String
* @param {string} [string=''] The string 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.
* @see trim, trimStart
* @example
@@ -24,9 +23,9 @@ const methodName = ''.trimRight ? 'trimRight': 'trimEnd'
* trimEnd('-_-abc-_-', '_-')
* // => '-_-abc'
*/
function trimEnd(string, chars, guard) {
function trimEnd(string, chars) {
string = toString(string)
if (string && (guard || chars === undefined)) {
if (string && chars === undefined) {
return string[methodName]()
}
if (!string || !(chars = baseToString(chars))) {

View File

@@ -13,7 +13,6 @@ const methodName = ''.trimLeft ? 'trimLeft' : 'trimStart'
* @category String
* @param {string} [string=''] The string 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.
* @see trim, trimEnd
* @example
@@ -24,9 +23,9 @@ const methodName = ''.trimLeft ? 'trimLeft' : 'trimStart'
* trimStart('-_-abc-_-', '_-')
* // => 'abc-_-'
*/
function trimStart(string, chars, guard) {
function trimStart(string, chars) {
string = toString(string)
if (string && (guard || chars === undefined)) {
if (string && chars === undefined) {
return string[methodName]()
}
if (!string || !(chars = baseToString(chars))) {

View File

@@ -10,7 +10,6 @@ import unicodeWords from './.internal/unicodeWords.js'
* @category String
* @param {string} [string=''] The string to inspect.
* @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`.
* @example
*
@@ -20,10 +19,8 @@ import unicodeWords from './.internal/unicodeWords.js'
* words('fred, barney, & pebbles', /[^, ]+/g)
* // => ['fred', 'barney', '&', 'pebbles']
*/
function words(string, pattern, guard) {
function words(string, pattern) {
string = toString(string)
pattern = guard ? undefined : pattern
if (pattern === undefined) {
return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string)
}