UNPKG

moltres-utils

Version:
90 lines (67 loc) 2.31 kB
"use strict"; require("core-js/modules/es6.object.define-property"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("core-js/modules/web.dom.iterable"); require("core-js/modules/es6.array.iterator"); require("core-js/modules/es6.object.keys"); var _constants = require("../constants"); var _isArguments = _interopRequireDefault(require("./isArguments")); var _objectHasOwnProperty = _interopRequireDefault(require("./objectHasOwnProperty")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; var contains = function contains(list, item) { var idx = 0; while (idx < list.length) { if (list[idx] === item) { return true; } idx += 1; } return false; }; /** * Returns a list containing the names of all the enumerable own properties of the supplied object. * Note that the order of the output array is not guaranteed to be consistent across different JS platforms. * * @function * @since v0.0.11 * @category lang * @param {Object} obj The object to extract properties from * @returns {Array} An array of the object's own properties. * @example * * objectKeys({a: 1, b: 2, c: 3}) //=> ['a', 'b', 'c'] */ var objectKeys = typeof Object.keys === 'function' && !_constants.HAS_ARGS_ENUM_BUG ? function (obj) { return Object(obj) !== obj ? [] : Object.keys(obj); } : function (obj) { if (Object(obj) !== obj) { return []; } var prop; var nIdx; var ks = []; var checkArgsLength = _constants.HAS_ARGS_ENUM_BUG && (0, _isArguments.default)(obj); for (prop in obj) { if ((0, _objectHasOwnProperty.default)(obj, prop) && (!checkArgsLength || prop !== 'length')) { ks[ks.length] = prop; } } if (_constants.HAS_OBJECT_ENUM_BUG) { nIdx = nonEnumerableProps.length - 1; while (nIdx >= 0) { prop = nonEnumerableProps[nIdx]; if ((0, _objectHasOwnProperty.default)(obj, prop) && !contains(ks, prop)) { ks[ks.length] = prop; } nIdx -= 1; } } return ks; }; var _default = objectKeys; exports.default = _default; //# sourceMappingURL=objectKeys.js.map