mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Remove nativeKeys and nativeKeysIn.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import isPrototype from './isPrototype.js'
|
||||
import nativeKeys from './nativeKeys.js'
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
@@ -13,7 +12,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
*/
|
||||
function baseKeys(object) {
|
||||
if (!isPrototype(object)) {
|
||||
return nativeKeys(object)
|
||||
return Object.keys(Object(object))
|
||||
}
|
||||
const result = []
|
||||
for (const key in Object(object)) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import isObject from '../isObject.js'
|
||||
import isPrototype from './isPrototype.js'
|
||||
import nativeKeysIn from './nativeKeysIn.js'
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
@@ -13,12 +12,17 @@ const hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
function baseKeysIn(object) {
|
||||
const result = []
|
||||
if (object == null) {
|
||||
return result
|
||||
}
|
||||
if (!isObject(object)) {
|
||||
return nativeKeysIn(object)
|
||||
for (const key in Object(object)) {
|
||||
result.push(key)
|
||||
}
|
||||
return result
|
||||
}
|
||||
const isProto = isPrototype(object)
|
||||
const result = []
|
||||
|
||||
for (const key in object) {
|
||||
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
|
||||
result.push(key)
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/**
|
||||
* This function is a thin wrapper around
|
||||
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
||||
* which ensures non-object values are coerced to objects beforehand.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
function nativeKeys(object) {
|
||||
return Object.keys(Object(object))
|
||||
}
|
||||
|
||||
export default nativeKeys
|
||||
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* This function is like
|
||||
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
||||
* except that it includes inherited enumerable properties.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @returns {Array} Returns the array of property names.
|
||||
*/
|
||||
function nativeKeysIn(object) {
|
||||
const result = []
|
||||
if (object != null) {
|
||||
for (const key in Object(object)) {
|
||||
result.push(key)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export default nativeKeysIn
|
||||
Reference in New Issue
Block a user