Remove nativeKeys and nativeKeysIn.

This commit is contained in:
John-David Dalton
2017-03-21 22:23:03 -07:00
parent f3e0cbe5bf
commit f7a6cddc9e
4 changed files with 9 additions and 40 deletions

View File

@@ -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)) {

View File

@@ -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)

View File

@@ -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

View File

@@ -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