mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Remove baseKeys and baseKeysIn.
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import isPrototype from './isPrototype.js'
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
/**
|
||||
* The base implementation of `keys` which doesn't treat sparse arrays as dense.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
function baseKeys(object) {
|
||||
object = Object(object)
|
||||
if (!isPrototype(object)) {
|
||||
return Object.keys(object)
|
||||
}
|
||||
const result = []
|
||||
for (const key in object) {
|
||||
if (hasOwnProperty.call(object, key) && key != 'constructor') {
|
||||
result.push(key)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export default baseKeys
|
||||
@@ -1,34 +0,0 @@
|
||||
import isObject from '../isObject.js'
|
||||
import isPrototype from './isPrototype.js'
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
/**
|
||||
* The base implementation of `keysIn` which doesn't treat sparse arrays as dense.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
function baseKeysIn(object) {
|
||||
const result = []
|
||||
if (object == null) {
|
||||
return result
|
||||
}
|
||||
if (!isObject(object)) {
|
||||
for (const key in Object(object)) {
|
||||
result.push(key)
|
||||
}
|
||||
return result
|
||||
}
|
||||
const isProto = isPrototype(object)
|
||||
for (const key in object) {
|
||||
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
|
||||
result.push(key)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export default baseKeysIn
|
||||
@@ -1,5 +1,4 @@
|
||||
import getSymbolsIn from './getSymbolsIn.js'
|
||||
import baseKeysIn from './baseKeysIn.js'
|
||||
|
||||
/**
|
||||
* Creates an array of own and inherited enumerable property names and symbols of `object`.
|
||||
@@ -9,7 +8,10 @@ import baseKeysIn from './baseKeysIn.js'
|
||||
* @returns {Array} Returns the array of property names and symbols.
|
||||
*/
|
||||
function getAllKeysIn(object) {
|
||||
const result = baseKeysIn(object)
|
||||
const result = []
|
||||
for (const key in object) {
|
||||
result.push(key)
|
||||
}
|
||||
if (!Array.isArray(object)) {
|
||||
result.push(...getSymbolsIn(object))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user