mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Use native filter instead of custom one where possible (#4116)
This commit is contained in:
committed by
John-David Dalton
parent
aa1d7d870d
commit
238e763aa1
@@ -1,5 +1,3 @@
|
|||||||
import filter from '../filter.js'
|
|
||||||
|
|
||||||
/** Built-in value references. */
|
/** Built-in value references. */
|
||||||
const propertyIsEnumerable = Object.prototype.propertyIsEnumerable
|
const propertyIsEnumerable = Object.prototype.propertyIsEnumerable
|
||||||
|
|
||||||
@@ -18,7 +16,7 @@ function getSymbols (object) {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
object = Object(object)
|
object = Object(object)
|
||||||
return filter(nativeGetSymbols(object), (symbol) => propertyIsEnumerable.call(object, symbol))
|
return nativeGetSymbols(object).filter((symbol) => propertyIsEnumerable.call(object, symbol))
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getSymbols
|
export default getSymbols
|
||||||
|
|||||||
3
xor.js
3
xor.js
@@ -1,4 +1,3 @@
|
|||||||
import filter from './filter.js'
|
|
||||||
import baseXor from './.internal/baseXor.js'
|
import baseXor from './.internal/baseXor.js'
|
||||||
import isArrayLikeObject from './isArrayLikeObject.js'
|
import isArrayLikeObject from './isArrayLikeObject.js'
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ import isArrayLikeObject from './isArrayLikeObject.js'
|
|||||||
* // => [1, 3]
|
* // => [1, 3]
|
||||||
*/
|
*/
|
||||||
function xor(...arrays) {
|
function xor(...arrays) {
|
||||||
return baseXor(filter(arrays, isArrayLikeObject))
|
return baseXor(arrays.filter(isArrayLikeObject))
|
||||||
}
|
}
|
||||||
|
|
||||||
export default xor
|
export default xor
|
||||||
|
|||||||
3
xorBy.js
3
xorBy.js
@@ -1,4 +1,3 @@
|
|||||||
import filter from './filter.js'
|
|
||||||
import baseXor from './.internal/baseXor.js'
|
import baseXor from './.internal/baseXor.js'
|
||||||
import isArrayLikeObject from './isArrayLikeObject.js'
|
import isArrayLikeObject from './isArrayLikeObject.js'
|
||||||
import last from './last.js'
|
import last from './last.js'
|
||||||
@@ -26,7 +25,7 @@ function xorBy(...arrays) {
|
|||||||
if (isArrayLikeObject(iteratee)) {
|
if (isArrayLikeObject(iteratee)) {
|
||||||
iteratee = undefined
|
iteratee = undefined
|
||||||
}
|
}
|
||||||
return baseXor(filter(arrays, isArrayLikeObject), iteratee)
|
return baseXor(arrays.filter(isArrayLikeObject), iteratee)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default xorBy
|
export default xorBy
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import filter from './filter.js'
|
|
||||||
import baseXor from './.internal/baseXor.js'
|
import baseXor from './.internal/baseXor.js'
|
||||||
import isArrayLikeObject from './isArrayLikeObject.js'
|
import isArrayLikeObject from './isArrayLikeObject.js'
|
||||||
import last from './last.js'
|
import last from './last.js'
|
||||||
@@ -26,7 +25,7 @@ import last from './last.js'
|
|||||||
function xorWith(...arrays) {
|
function xorWith(...arrays) {
|
||||||
let comparator = last(arrays)
|
let comparator = last(arrays)
|
||||||
comparator = typeof comparator == 'function' ? comparator : undefined
|
comparator = typeof comparator == 'function' ? comparator : undefined
|
||||||
return baseXor(filter(arrays, isArrayLikeObject), undefined, comparator)
|
return baseXor(arrays.filter(isArrayLikeObject), undefined, comparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default xorWith
|
export default xorWith
|
||||||
|
|||||||
Reference in New Issue
Block a user