UNPKG

mana-common

Version:

Common utils for mana

32 lines (25 loc) 895 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPropertyDescriptor = getPropertyDescriptor; exports.isPlainObject = isPlainObject; function getPropertyDescriptor(o, propertyName) { let proto = o; let descriptor = undefined; while (proto && !descriptor) { descriptor = Object.getOwnPropertyDescriptor(proto, propertyName); proto = Object.getPrototypeOf(proto); } return descriptor; } function isPlainObject(obj) { if (typeof obj !== 'object' || obj === null || // window/navigator/Global Object.prototype.toString.call(obj) !== '[object Object]') return false; const proto = Object.getPrototypeOf(obj); if (proto === null) { return true; } const ctor = proto.hasOwnProperty('constructor') && proto.constructor; return typeof ctor == 'function' && ctor instanceof ctor && ctor.toString() === Object.toString(); }