mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Add getPrototype helper.
This commit is contained in:
23
lodash.js
23
lodash.js
@@ -1364,7 +1364,6 @@
|
||||
Uint8Array = context.Uint8Array,
|
||||
clearTimeout = context.clearTimeout,
|
||||
enumerate = Reflect ? Reflect.enumerate : undefined,
|
||||
getPrototypeOf = Object.getPrototypeOf,
|
||||
getOwnPropertySymbols = Object.getOwnPropertySymbols,
|
||||
iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
|
||||
objectCreate = Object.create,
|
||||
@@ -1375,6 +1374,7 @@
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeCeil = Math.ceil,
|
||||
nativeFloor = Math.floor,
|
||||
nativeGetPrototype = Object.getPrototypeOf,
|
||||
nativeIsFinite = context.isFinite,
|
||||
nativeJoin = arrayProto.join,
|
||||
nativeKeys = Object.keys,
|
||||
@@ -2774,7 +2774,7 @@
|
||||
// that are composed entirely of index properties, return `false` for
|
||||
// `hasOwnProperty` checks of them.
|
||||
return hasOwnProperty.call(object, key) ||
|
||||
(typeof object == 'object' && key in object && getPrototypeOf(object) === null);
|
||||
(typeof object == 'object' && key in object && getPrototype(object) === null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5068,6 +5068,17 @@
|
||||
return object.placeholder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the `[[Prototype]]` of `value`.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to query.
|
||||
* @returns {null|Object} Returns the `[[Prototype]]`.
|
||||
*/
|
||||
function getPrototype(value) {
|
||||
return nativeGetPrototype(Object(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of the own enumerable symbol properties of `object`.
|
||||
*
|
||||
@@ -5100,7 +5111,7 @@
|
||||
var result = [];
|
||||
while (object) {
|
||||
arrayPush(result, getSymbols(object));
|
||||
object = getPrototypeOf(object);
|
||||
object = getPrototype(object);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
@@ -5227,7 +5238,7 @@
|
||||
*/
|
||||
function initCloneObject(object) {
|
||||
return (typeof object.constructor == 'function' && !isPrototype(object))
|
||||
? baseCreate(getPrototypeOf(object))
|
||||
? baseCreate(getPrototype(object))
|
||||
: {};
|
||||
}
|
||||
|
||||
@@ -10636,7 +10647,7 @@
|
||||
objectToString.call(value) != objectTag || isHostObject(value)) {
|
||||
return false;
|
||||
}
|
||||
var proto = getPrototypeOf(value);
|
||||
var proto = getPrototype(value);
|
||||
if (proto === null) {
|
||||
return true;
|
||||
}
|
||||
@@ -12344,7 +12355,7 @@
|
||||
if (isArr) {
|
||||
accumulator = isArray(object) ? new Ctor : [];
|
||||
} else {
|
||||
accumulator = isFunction(Ctor) ? baseCreate(getPrototypeOf(object)) : {};
|
||||
accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
|
||||
}
|
||||
} else {
|
||||
accumulator = {};
|
||||
|
||||
Reference in New Issue
Block a user