1 line
3.6 KiB
JSON
1 line
3.6 KiB
JSON
{"ast":null,"code":"'use strict';\n\nvar keysShim;\n\nif (!Object.keys) {\n // modified from https://github.com/es-shims/es5-shim\n var has = Object.prototype.hasOwnProperty;\n var toStr = Object.prototype.toString;\n\n var isArgs = require('./isArguments'); // eslint-disable-line global-require\n\n\n var isEnumerable = Object.prototype.propertyIsEnumerable;\n var hasDontEnumBug = !isEnumerable.call({\n toString: null\n }, 'toString');\n var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');\n var dontEnums = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor'];\n\n var equalsConstructorPrototype = function equalsConstructorPrototype(o) {\n var ctor = o.constructor;\n return ctor && ctor.prototype === o;\n };\n\n var excludedKeys = {\n $applicationCache: true,\n $console: true,\n $external: true,\n $frame: true,\n $frameElement: true,\n $frames: true,\n $innerHeight: true,\n $innerWidth: true,\n $onmozfullscreenchange: true,\n $onmozfullscreenerror: true,\n $outerHeight: true,\n $outerWidth: true,\n $pageXOffset: true,\n $pageYOffset: true,\n $parent: true,\n $scrollLeft: true,\n $scrollTop: true,\n $scrollX: true,\n $scrollY: true,\n $self: true,\n $webkitIndexedDB: true,\n $webkitStorageInfo: true,\n $window: true\n };\n\n var hasAutomationEqualityBug = function () {\n /* global window */\n if (typeof window === 'undefined') {\n return false;\n }\n\n for (var k in window) {\n try {\n if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {\n try {\n equalsConstructorPrototype(window[k]);\n } catch (e) {\n return true;\n }\n }\n } catch (e) {\n return true;\n }\n }\n\n return false;\n }();\n\n var equalsConstructorPrototypeIfNotBuggy = function equalsConstructorPrototypeIfNotBuggy(o) {\n /* global window */\n if (typeof window === 'undefined' || !hasAutomationEqualityBug) {\n return equalsConstructorPrototype(o);\n }\n\n try {\n return equalsConstructorPrototype(o);\n } catch (e) {\n return false;\n }\n };\n\n keysShim = function keys(object) {\n var isObject = object !== null && typeof object === 'object';\n var isFunction = toStr.call(object) === '[object Function]';\n var isArguments = isArgs(object);\n var isString = isObject && toStr.call(object) === '[object String]';\n var theKeys = [];\n\n if (!isObject && !isFunction && !isArguments) {\n throw new TypeError('Object.keys called on a non-object');\n }\n\n var skipProto = hasProtoEnumBug && isFunction;\n\n if (isString && object.length > 0 && !has.call(object, 0)) {\n for (var i = 0; i < object.length; ++i) {\n theKeys.push(String(i));\n }\n }\n\n if (isArguments && object.length > 0) {\n for (var j = 0; j < object.length; ++j) {\n theKeys.push(String(j));\n }\n } else {\n for (var name in object) {\n if (!(skipProto && name === 'prototype') && has.call(object, name)) {\n theKeys.push(String(name));\n }\n }\n }\n\n if (hasDontEnumBug) {\n var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);\n\n for (var k = 0; k < dontEnums.length; ++k) {\n if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {\n theKeys.push(dontEnums[k]);\n }\n }\n }\n\n return theKeys;\n };\n}\n\nmodule.exports = keysShim;","map":null,"metadata":{},"sourceType":"script"} |