/
githubmirror
/
immutable-js
Обзор
Документация
Войти
/
githubmirror
/
immutable-js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v4.3.3
src/utils/isPlainObj.js
26 строк
754 B
Julien Deniau
Merge remote-tracking branch 'immutable/main' into immutable-oss-integration
28 июн 2021, 15:44
28 июн 2021, 15:44
bb28fa6
Код
Авторство
О чём код?
const toString = Object.prototype.toString; export default function isPlainObject(value) { // The base prototype's toString deals with Argument objects and native namespaces like Math if ( !value || typeof value !== 'object' || toString.call(value) !== '[object Object]' ) { return false; } const proto = Object.getPrototypeOf(value); if (proto === null) { return true; } // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) let parentProto = proto; let nextProto = Object.getPrototypeOf(proto); while (nextProto !== null) { parentProto = nextProto; nextProto = Object.getPrototypeOf(parentProto); } return parentProto === proto; }