pax_global_header00006660000000000000000000000064134522602350014514gustar00rootroot0000000000000052 comment=ba2c1989270c7de969aa8498fc3b7c8e677806f3 object-keys-1.1.1/000077500000000000000000000000001345226023500137335ustar00rootroot00000000000000object-keys-1.1.1/.editorconfig000066400000000000000000000004241345226023500164100ustar00rootroot00000000000000root = true [*] indent_style = tab; insert_final_newline = true; quote_type = auto; space_after_anonymous_functions = true; space_after_control_statements = true; spaces_around_operators = true; trim_trailing_whitespace = true; spaces_in_brackets = false; end_of_line = lf; object-keys-1.1.1/.eslintrc000066400000000000000000000006521345226023500155620ustar00rootroot00000000000000{ "root": true, "extends": "@ljharb", "rules": { "complexity": [2, 23], "id-length": [2, { "min": 1, "max": 40 }], "max-params": [2, 3], "max-statements": [2, 23], "max-statements-per-line": [2, { "max": 2 }], "no-extra-parens": [1], "no-invalid-this": [1], "no-restricted-syntax": [2, "BreakStatement", "ContinueStatement", "LabeledStatement", "WithStatement"], "operator-linebreak": [2, "after"] } } object-keys-1.1.1/.gitignore000066400000000000000000000001551345226023500157240ustar00rootroot00000000000000# gitignore node_modules # Only apps should have lockfiles npm-shrinkwrap.json yarn.lock package-lock.json object-keys-1.1.1/.npmignore000066400000000000000000000000101345226023500157210ustar00rootroot00000000000000test/* object-keys-1.1.1/.npmrc000066400000000000000000000000441345226023500150510ustar00rootroot00000000000000package-lock=false audit-level=high object-keys-1.1.1/.travis.yml000066400000000000000000000202121345226023500160410ustar00rootroot00000000000000language: node_js os: - linux node_js: - "11.8" - "10.15" - "9.11" - "8.15" - "7.10" - "6.16" - "5.12" - "4.9" - "iojs-v3.3" - "iojs-v2.5" - "iojs-v1.8" - "0.12" - "0.10" - "0.8" before_install: - 'case "${TRAVIS_NODE_VERSION}" in 0.*) export NPM_CONFIG_STRICT_SSL=false ;; esac' - 'nvm install-latest-npm' install: - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi' - 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi' - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi' - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi' sudo: false env: - TEST=true matrix: fast_finish: true include: - node_js: "lts/*" env: PRETEST=true - node_js: "lts/*" env: POSTTEST=true - node_js: "4" env: COVERAGE=true - node_js: "11.7" env: TEST=true ALLOW_FAILURE=true - node_js: "11.6" env: TEST=true ALLOW_FAILURE=true - node_js: "11.5" env: TEST=true ALLOW_FAILURE=true - node_js: "11.4" env: TEST=true ALLOW_FAILURE=true - node_js: "11.3" env: TEST=true ALLOW_FAILURE=true - node_js: "11.2" env: TEST=true ALLOW_FAILURE=true - node_js: "11.1" env: TEST=true ALLOW_FAILURE=true - node_js: "11.0" env: TEST=true ALLOW_FAILURE=true - node_js: "10.14" env: TEST=true ALLOW_FAILURE=true - node_js: "10.13" env: TEST=true ALLOW_FAILURE=true - node_js: "10.12" env: TEST=true ALLOW_FAILURE=true - node_js: "10.11" env: TEST=true ALLOW_FAILURE=true - node_js: "10.10" env: TEST=true ALLOW_FAILURE=true - node_js: "10.9" env: TEST=true ALLOW_FAILURE=true - node_js: "10.8" env: TEST=true ALLOW_FAILURE=true - node_js: "10.7" env: TEST=true ALLOW_FAILURE=true - node_js: "10.6" env: TEST=true ALLOW_FAILURE=true - node_js: "10.5" env: TEST=true ALLOW_FAILURE=true - node_js: "10.4" env: TEST=true ALLOW_FAILURE=true - node_js: "10.3" env: TEST=true ALLOW_FAILURE=true - node_js: "10.2" env: TEST=true ALLOW_FAILURE=true - node_js: "10.1" env: TEST=true ALLOW_FAILURE=true - node_js: "10.0" env: TEST=true ALLOW_FAILURE=true - node_js: "9.10" env: TEST=true ALLOW_FAILURE=true - node_js: "9.9" env: TEST=true ALLOW_FAILURE=true - node_js: "9.8" env: TEST=true ALLOW_FAILURE=true - node_js: "9.7" env: TEST=true ALLOW_FAILURE=true - node_js: "9.6" env: TEST=true ALLOW_FAILURE=true - node_js: "9.5" env: TEST=true ALLOW_FAILURE=true - node_js: "9.4" env: TEST=true ALLOW_FAILURE=true - node_js: "9.3" env: TEST=true ALLOW_FAILURE=true - node_js: "9.2" env: TEST=true ALLOW_FAILURE=true - node_js: "9.1" env: TEST=true ALLOW_FAILURE=true - node_js: "9.0" env: TEST=true ALLOW_FAILURE=true - node_js: "8.14" env: TEST=true ALLOW_FAILURE=true - node_js: "8.13" env: TEST=true ALLOW_FAILURE=true - node_js: "8.12" env: TEST=true ALLOW_FAILURE=true - node_js: "8.11" env: TEST=true ALLOW_FAILURE=true - node_js: "8.10" env: TEST=true ALLOW_FAILURE=true - node_js: "8.9" env: TEST=true ALLOW_FAILURE=true - node_js: "8.8" env: TEST=true ALLOW_FAILURE=true - node_js: "8.7" env: TEST=true ALLOW_FAILURE=true - node_js: "8.6" env: TEST=true ALLOW_FAILURE=true - node_js: "8.5" env: TEST=true ALLOW_FAILURE=true - node_js: "8.4" env: TEST=true ALLOW_FAILURE=true - node_js: "8.3" env: TEST=true ALLOW_FAILURE=true - node_js: "8.2" env: TEST=true ALLOW_FAILURE=true - node_js: "8.1" env: TEST=true ALLOW_FAILURE=true - node_js: "8.0" env: TEST=true ALLOW_FAILURE=true - node_js: "7.9" env: TEST=true ALLOW_FAILURE=true - node_js: "7.8" env: TEST=true ALLOW_FAILURE=true - node_js: "7.7" env: TEST=true ALLOW_FAILURE=true - node_js: "7.6" env: TEST=true ALLOW_FAILURE=true - node_js: "7.5" env: TEST=true ALLOW_FAILURE=true - node_js: "7.4" env: TEST=true ALLOW_FAILURE=true - node_js: "7.3" env: TEST=true ALLOW_FAILURE=true - node_js: "7.2" env: TEST=true ALLOW_FAILURE=true - node_js: "7.1" env: TEST=true ALLOW_FAILURE=true - node_js: "7.0" env: TEST=true ALLOW_FAILURE=true - node_js: "6.15" env: TEST=true ALLOW_FAILURE=true - node_js: "6.14" env: TEST=true ALLOW_FAILURE=true - node_js: "6.13" env: TEST=true ALLOW_FAILURE=true - node_js: "6.12" env: TEST=true ALLOW_FAILURE=true - node_js: "6.11" env: TEST=true ALLOW_FAILURE=true - node_js: "6.10" env: TEST=true ALLOW_FAILURE=true - node_js: "6.9" env: TEST=true ALLOW_FAILURE=true - node_js: "6.8" env: TEST=true ALLOW_FAILURE=true - node_js: "6.7" env: TEST=true ALLOW_FAILURE=true - node_js: "6.6" env: TEST=true ALLOW_FAILURE=true - node_js: "6.5" env: TEST=true ALLOW_FAILURE=true - node_js: "6.4" env: TEST=true ALLOW_FAILURE=true - node_js: "6.3" env: TEST=true ALLOW_FAILURE=true - node_js: "6.2" env: TEST=true ALLOW_FAILURE=true - node_js: "6.1" env: TEST=true ALLOW_FAILURE=true - node_js: "6.0" env: TEST=true ALLOW_FAILURE=true - node_js: "5.11" env: TEST=true ALLOW_FAILURE=true - node_js: "5.10" env: TEST=true ALLOW_FAILURE=true - node_js: "5.9" env: TEST=true ALLOW_FAILURE=true - node_js: "5.8" env: TEST=true ALLOW_FAILURE=true - node_js: "5.7" env: TEST=true ALLOW_FAILURE=true - node_js: "5.6" env: TEST=true ALLOW_FAILURE=true - node_js: "5.5" env: TEST=true ALLOW_FAILURE=true - node_js: "5.4" env: TEST=true ALLOW_FAILURE=true - node_js: "5.3" env: TEST=true ALLOW_FAILURE=true - node_js: "5.2" env: TEST=true ALLOW_FAILURE=true - node_js: "5.1" env: TEST=true ALLOW_FAILURE=true - node_js: "5.0" env: TEST=true ALLOW_FAILURE=true - node_js: "4.8" env: TEST=true ALLOW_FAILURE=true - node_js: "4.7" env: TEST=true ALLOW_FAILURE=true - node_js: "4.6" env: TEST=true ALLOW_FAILURE=true - node_js: "4.5" env: TEST=true ALLOW_FAILURE=true - node_js: "4.4" env: TEST=true ALLOW_FAILURE=true - node_js: "4.3" env: TEST=true ALLOW_FAILURE=true - node_js: "4.2" env: TEST=true ALLOW_FAILURE=true - node_js: "4.1" env: TEST=true ALLOW_FAILURE=true - node_js: "4.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.4" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.3" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.7" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.6" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.5" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.4" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.3" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.0" env: TEST=true ALLOW_FAILURE=true - node_js: "0.11" env: TEST=true ALLOW_FAILURE=true - node_js: "0.9" env: TEST=true ALLOW_FAILURE=true - node_js: "0.6" env: TEST=true ALLOW_FAILURE=true - node_js: "0.4" env: TEST=true ALLOW_FAILURE=true allow_failures: - os: osx - env: TEST=true ALLOW_FAILURE=true - env: COVERAGE=true - env: POSTTEST=true object-keys-1.1.1/CHANGELOG.md000066400000000000000000000165711345226023500155560ustar00rootroot000000000000001.1.1 / 2019-04-06 ================= * [Fix] exclude deprecated Firefox keys (#53) 1.1.0 / 2019-02-10 ================= * [New] [Refactor] move full implementation to `implementation` entry point * [Refactor] only evaluate the implementation if `Object.keys` is not present * [Tests] up to `node` `v11.8`, `v10.15`, `v8.15`, `v6.16` * [Tests] remove jscs * [Tests] switch to `npm audit` from `nsp` 1.0.12 / 2018-06-18 ================= * [Fix] avoid accessing `window.applicationCache`, to avoid issues with latest Chrome on HTTP (#46) 1.0.11 / 2016-07-05 ================= * [Fix] exclude keys regarding the style (eg. `pageYOffset`) on `window` to avoid reflow (#32) 1.0.10 / 2016-07-04 ================= * [Fix] exclude `height` and `width` keys on `window` to avoid reflow (#31) * [Fix] In IE 6, `window.external` makes `Object.keys` throw * [Tests] up to `node` `v6.2`, `v5.10`, `v4.4` * [Tests] use pretest/posttest for linting/security * [Dev Deps] update `tape`, `jscs`, `nsp`, `eslint`, `@ljharb/eslint-config` * [Dev Deps] remove unused eccheck script + dep 1.0.9 / 2015-10-19 ================= * [Fix] Blacklist 'frame' property on window (#16, #17) * [Dev Deps] update `jscs`, `eslint`, `@ljharb/eslint-config` 1.0.8 / 2015-10-14 ================= * [Fix] wrap automation equality bug checking in try/catch, per [es5-shim#327](https://github.com/es-shims/es5-shim/issues/327) * [Fix] Blacklist 'window.frameElement' per [es5-shim#322](https://github.com/es-shims/es5-shim/issues/322) * [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG * [Tests] up to `io.js` `v3.3`, `node` `v4.2` * [Dev Deps] update `eslint`, `tape`, `@ljharb/eslint-config`, `jscs` 1.0.7 / 2015-07-18 ================= * [Fix] A proper fix for 176f03335e90d5c8d0d8125a99f27819c9b9cdad / https://github.com/es-shims/es5-shim/issues/275 that doesn't break dontEnum/constructor fixes in IE 8. * [Fix] Remove deprecation message in Chrome by touching deprecated window properties (#15) * [Tests] Improve test output for automation equality bugfix * [Tests] Test on `io.js` `v2.4` 1.0.6 / 2015-07-09 ================= * [Fix] Use an object lookup rather than ES5's `indexOf` (#14) * [Tests] ES3 browsers don't have `Array.isArray` * [Tests] Fix `no-shadow` rule, as well as an IE 8 bug caused by engine NFE shadowing bugs. 1.0.5 / 2015-07-03 ================= * [Fix] Fix a flabbergasting IE 8 bug where `localStorage.constructor.prototype === localStorage` throws * [Tests] Test up to `io.js` `v2.3` * [Dev Deps] Update `nsp`, `eslint` 1.0.4 / 2015-05-23 ================= * Fix a Safari 5.0 bug with `Object.keys` not working with `arguments` * Test on latest `node` and `io.js` * Update `jscs`, `tape`, `eslint`, `nsp`, `is`, `editorconfig-tools`, `covert` 1.0.3 / 2015-01-06 ================= * Revert "Make `object-keys` more robust against later environment tampering" to maintain ES3 compliance 1.0.2 / 2014-12-28 ================= * Update lots of dev dependencies * Tweaks to README * Make `object-keys` more robust against later environment tampering 1.0.1 / 2014-09-03 ================= * Update URLs and badges in README 1.0.0 / 2014-08-26 ================= * v1.0.0 0.6.1 / 2014-08-25 ================= * v0.6.1 * Updating dependencies (tape, covert, is) * Update badges in readme * Use separate var statements 0.6.0 / 2014-04-23 ================= * v0.6.0 * Updating dependencies (tape, covert) * Make sure boxed primitives, and arguments objects, work properly in ES3 browsers * Improve test matrix: test all node versions, but only latest two stables are a failure * Remove internal foreach shim. 0.5.1 / 2014-03-09 ================= * 0.5.1 * Updating dependencies (tape, covert, is) * Removing forEach from the module (but keeping it in tests) 0.5.0 / 2014-01-30 ================= * 0.5.0 * Explicitly returning the shim, instead of returning native Object.keys when present * Adding a changelog. * Cleaning up IIFE wrapping * Testing on node 0.4 through 0.11 0.4.0 / 2013-08-14 ================== * v0.4.0 * In Chrome 4-10 and Safari 4, typeof (new RegExp) === 'function' * If it's a string, make sure to use charAt instead of brackets. * Only use Function#call if necessary. * Making sure the context tests actually run. * Better function detection * Adding the android browser * Fixing testling files * Updating tape * Removing the "is" dependency. * Making an isArguments shim. * Adding a local forEach shim and tests. * Updating paths. * Moving the shim test. * v0.3.0 0.3.0 / 2013-05-18 ================== * README tweak. * Fixing constructor enum issue. Fixes [#5](https://github.com/ljharb/object-keys/issues/5). * Adding a test for [#5](https://github.com/ljharb/object-keys/issues/5) * Updating readme. * Updating dependencies. * Giving credit to lodash. * Make sure that a prototype's constructor property is not enumerable. Fixes [#3](https://github.com/ljharb/object-keys/issues/3). * Adding additional tests to handle arguments objects, and to skip "prototype" in functions. Fixes [#2](https://github.com/ljharb/object-keys/issues/2). * Fixing a typo on this test for [#3](https://github.com/ljharb/object-keys/issues/3). * Adding node 0.10 to travis. * Adding an IE < 9 test per [#3](https://github.com/ljharb/object-keys/issues/3) * Adding an iOS 5 mobile Safari test per [#2](https://github.com/ljharb/object-keys/issues/2) * Moving "indexof" and "is" to be dev dependencies. * Making sure the shim works with functions. * Flattening the tests. 0.2.0 / 2013-05-10 ================== * v0.2.0 * Object.keys should work with arrays. 0.1.8 / 2013-05-10 ================== * v0.1.8 * Upgrading dependencies. * Using a simpler check. * Fixing a bug in hasDontEnumBug browsers. * Using the newest tape! * Fixing this error test. * "undefined" is probably a reserved word in ES3. * Better test message. 0.1.7 / 2013-04-17 ================== * Upgrading "is" once more. * The key "null" is breaking some browsers. 0.1.6 / 2013-04-17 ================== * v0.1.6 * Upgrading "is" 0.1.5 / 2013-04-14 ================== * Bumping version. * Adding more testling browsers. * Updating "is" 0.1.4 / 2013-04-08 ================== * Using "is" instead of "is-extended". 0.1.3 / 2013-04-07 ================== * Using "foreach" instead of my own shim. * Removing "tap"; I'll just wait for "tape" to fix its node 0.10 bug. 0.1.2 / 2013-04-03 ================== * Adding dependency status; moving links to an index at the bottom. * Upgrading is-extended; version 0.1.2 * Adding an npm version badge. 0.1.1 / 2013-04-01 ================== * Adding Travis CI. * Bumping the version. * Adding indexOf since IE sucks. * Adding a forEach shim since older browsers don't have Array#forEach. * Upgrading tape - 0.3.2 uses Array#map * Using explicit end instead of plan. * Can't test with Array.isArray in older browsers. * Using is-extended. * Fixing testling files. * JSHint/JSLint-ing. * Removing an unused object. * Using strict mode. 0.1.0 / 2013-03-30 ================== * Changing the exports should have meant a higher version bump. * Oops, fixing the repo URL. * Adding more tests. * 0.0.2 * Merge branch 'export_one_thing'; closes [#1](https://github.com/ljharb/object-keys/issues/1) * Move shim export to a separate file. object-keys-1.1.1/LICENSE000066400000000000000000000020701345226023500147370ustar00rootroot00000000000000The MIT License (MIT) Copyright (C) 2013 Jordan Harband Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.object-keys-1.1.1/README.md000066400000000000000000000046341345226023500152210ustar00rootroot00000000000000#object-keys [![Version Badge][npm-version-svg]][package-url] [![Build Status][travis-svg]][travis-url] [![dependency status][deps-svg]][deps-url] [![dev dependency status][dev-deps-svg]][dev-deps-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][npm-badge-png]][package-url] [![browser support][testling-svg]][testling-url] An Object.keys shim. Invoke its "shim" method to shim Object.keys if it is unavailable. Most common usage: ```js var keys = Object.keys || require('object-keys'); ``` ## Example ```js var keys = require('object-keys'); var assert = require('assert'); var obj = { a: true, b: true, c: true }; assert.deepEqual(keys(obj), ['a', 'b', 'c']); ``` ```js var keys = require('object-keys'); var assert = require('assert'); /* when Object.keys is not present */ delete Object.keys; var shimmedKeys = keys.shim(); assert.equal(shimmedKeys, keys); assert.deepEqual(Object.keys(obj), keys(obj)); ``` ```js var keys = require('object-keys'); var assert = require('assert'); /* when Object.keys is present */ var shimmedKeys = keys.shim(); assert.equal(shimmedKeys, Object.keys); assert.deepEqual(Object.keys(obj), keys(obj)); ``` ## Source Implementation taken directly from [es5-shim][es5-shim-url], with modifications, including from [lodash][lodash-url]. ## Tests Simply clone the repo, `npm install`, and run `npm test` [package-url]: https://npmjs.org/package/object-keys [npm-version-svg]: http://versionbadg.es/ljharb/object-keys.svg [travis-svg]: https://travis-ci.org/ljharb/object-keys.svg [travis-url]: https://travis-ci.org/ljharb/object-keys [deps-svg]: https://david-dm.org/ljharb/object-keys.svg [deps-url]: https://david-dm.org/ljharb/object-keys [dev-deps-svg]: https://david-dm.org/ljharb/object-keys/dev-status.svg [dev-deps-url]: https://david-dm.org/ljharb/object-keys#info=devDependencies [testling-svg]: https://ci.testling.com/ljharb/object-keys.png [testling-url]: https://ci.testling.com/ljharb/object-keys [es5-shim-url]: https://github.com/es-shims/es5-shim/blob/master/es5-shim.js#L542-589 [lodash-url]: https://github.com/lodash/lodash [npm-badge-png]: https://nodei.co/npm/object-keys.png?downloads=true&stars=true [license-image]: http://img.shields.io/npm/l/object-keys.svg [license-url]: LICENSE [downloads-image]: http://img.shields.io/npm/dm/object-keys.svg [downloads-url]: http://npm-stat.com/charts.html?package=object-keys object-keys-1.1.1/implementation.js000066400000000000000000000062221345226023500173200ustar00rootroot00000000000000'use strict'; var keysShim; if (!Object.keys) { // modified from https://github.com/es-shims/es5-shim var has = Object.prototype.hasOwnProperty; var toStr = Object.prototype.toString; var isArgs = require('./isArguments'); // eslint-disable-line global-require var isEnumerable = Object.prototype.propertyIsEnumerable; var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype'); var dontEnums = [ 'toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor' ]; var equalsConstructorPrototype = function (o) { var ctor = o.constructor; return ctor && ctor.prototype === o; }; var excludedKeys = { $applicationCache: true, $console: true, $external: true, $frame: true, $frameElement: true, $frames: true, $innerHeight: true, $innerWidth: true, $onmozfullscreenchange: true, $onmozfullscreenerror: true, $outerHeight: true, $outerWidth: true, $pageXOffset: true, $pageYOffset: true, $parent: true, $scrollLeft: true, $scrollTop: true, $scrollX: true, $scrollY: true, $self: true, $webkitIndexedDB: true, $webkitStorageInfo: true, $window: true }; var hasAutomationEqualityBug = (function () { /* global window */ if (typeof window === 'undefined') { return false; } for (var k in window) { try { if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { try { equalsConstructorPrototype(window[k]); } catch (e) { return true; } } } catch (e) { return true; } } return false; }()); var equalsConstructorPrototypeIfNotBuggy = function (o) { /* global window */ if (typeof window === 'undefined' || !hasAutomationEqualityBug) { return equalsConstructorPrototype(o); } try { return equalsConstructorPrototype(o); } catch (e) { return false; } }; keysShim = function keys(object) { var isObject = object !== null && typeof object === 'object'; var isFunction = toStr.call(object) === '[object Function]'; var isArguments = isArgs(object); var isString = isObject && toStr.call(object) === '[object String]'; var theKeys = []; if (!isObject && !isFunction && !isArguments) { throw new TypeError('Object.keys called on a non-object'); } var skipProto = hasProtoEnumBug && isFunction; if (isString && object.length > 0 && !has.call(object, 0)) { for (var i = 0; i < object.length; ++i) { theKeys.push(String(i)); } } if (isArguments && object.length > 0) { for (var j = 0; j < object.length; ++j) { theKeys.push(String(j)); } } else { for (var name in object) { if (!(skipProto && name === 'prototype') && has.call(object, name)) { theKeys.push(String(name)); } } } if (hasDontEnumBug) { var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); for (var k = 0; k < dontEnums.length; ++k) { if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { theKeys.push(dontEnums[k]); } } } return theKeys; }; } module.exports = keysShim; object-keys-1.1.1/index.js000066400000000000000000000014671345226023500154100ustar00rootroot00000000000000'use strict'; var slice = Array.prototype.slice; var isArgs = require('./isArguments'); var origKeys = Object.keys; var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation'); var originalKeys = Object.keys; keysShim.shim = function shimObjectKeys() { if (Object.keys) { var keysWorksWithArguments = (function () { // Safari 5.0 bug var args = Object.keys(arguments); return args && args.length === arguments.length; }(1, 2)); if (!keysWorksWithArguments) { Object.keys = function keys(object) { // eslint-disable-line func-name-matching if (isArgs(object)) { return originalKeys(slice.call(object)); } return originalKeys(object); }; } } else { Object.keys = keysShim; } return Object.keys || keysShim; }; module.exports = keysShim; object-keys-1.1.1/isArguments.js000066400000000000000000000006461345226023500166000ustar00rootroot00000000000000'use strict'; var toStr = Object.prototype.toString; module.exports = function isArguments(value) { var str = toStr.call(value); var isArgs = str === '[object Arguments]'; if (!isArgs) { isArgs = str !== '[object Array]' && value !== null && typeof value === 'object' && typeof value.length === 'number' && value.length >= 0 && toStr.call(value.callee) === '[object Function]'; } return isArgs; }; object-keys-1.1.1/package.json000066400000000000000000000035571345226023500162330ustar00rootroot00000000000000{ "name": "object-keys", "version": "1.1.1", "author": { "name": "Jordan Harband", "email": "ljharb@gmail.com", "url": "http://ljharb.codes" }, "contributors": [ { "name": "Jordan Harband", "email": "ljharb@gmail.com", "url": "http://ljharb.codes" }, { "name": "Raynos", "email": "raynos2@gmail.com" }, { "name": "Nathan Rajlich", "email": "nathan@tootallnate.net" }, { "name": "Ivan Starkov", "email": "istarkov@gmail.com" }, { "name": "Gary Katsevman", "email": "git@gkatsev.com" } ], "description": "An Object.keys replacement, in case Object.keys is not available. From https://github.com/es-shims/es5-shim", "license": "MIT", "main": "index.js", "scripts": { "pretest": "npm run --silent lint", "test": "npm run --silent tests-only", "posttest": "npm run --silent audit", "tests-only": "node test/index.js", "coverage": "covert test/*.js", "coverage-quiet": "covert test/*.js --quiet", "lint": "eslint .", "preaudit": "npm install --package-lock --package-lock-only", "audit": "npm audit", "postaudit": "rm package-lock.json" }, "repository": { "type": "git", "url": "git://github.com/ljharb/object-keys.git" }, "keywords": [ "Object.keys", "keys", "ES5", "shim" ], "dependencies": {}, "devDependencies": { "@ljharb/eslint-config": "^13.1.1", "covert": "^1.1.1", "eslint": "^5.13.0", "foreach": "^2.0.5", "indexof": "^0.0.1", "is": "^3.3.0", "tape": "^4.9.2" }, "testling": { "files": "test/index.js", "browsers": [ "iexplore/6.0..latest", "firefox/3.0..6.0", "firefox/15.0..latest", "firefox/nightly", "chrome/4.0..10.0", "chrome/20.0..latest", "chrome/canary", "opera/10.0..latest", "opera/next", "safari/4.0..latest", "ipad/6.0..latest", "iphone/6.0..latest", "android-browser/4.2" ] }, "engines": { "node": ">= 0.4" } } object-keys-1.1.1/test/000077500000000000000000000000001345226023500147125ustar00rootroot00000000000000object-keys-1.1.1/test/.eslintrc000066400000000000000000000002051345226023500165330ustar00rootroot00000000000000{ "rules": { "array-bracket-newline": 0, "array-element-newline": 0, "max-nested-callbacks": 0, "no-magic-numbers": 0, } } object-keys-1.1.1/test/index.js000066400000000000000000000000751345226023500163610ustar00rootroot00000000000000'use strict'; require('./isArguments'); require('./shim'); object-keys-1.1.1/test/isArguments.js000066400000000000000000000010241345226023500175460ustar00rootroot00000000000000'use strict'; var test = require('tape'); var isArguments = require('../isArguments'); test('is.arguments', function (t) { t.notOk(isArguments([]), 'array is not arguments'); (function () { t.ok(isArguments(arguments), 'arguments is arguments'); }()); (function () { t.notOk(isArguments(Array.prototype.slice.call(arguments)), 'sliced arguments is not arguments'); }()); var fakeOldArguments = { callee: function () {}, length: 3 }; t.ok(isArguments(fakeOldArguments), 'old-style arguments is arguments'); t.end(); }); object-keys-1.1.1/test/shim.js000066400000000000000000000171201345226023500162110ustar00rootroot00000000000000/* global window */ 'use strict'; var test = require('tape'); var is = require('is'); var keysShim; var reRequire = function reRequireImplementation() { delete require.cache[require.resolve('../implementation')]; delete require.cache[require.resolve('../')]; keysShim = require('../'); // eslint-disable-line global-require }; reRequire(); var indexOf = require('indexof'); var has = Object.prototype.hasOwnProperty; var enumerable = Object.prototype.propertyIsEnumerable; var obj = { aNull: null, arr: [], bool: true, num: 42, obj: {}, str: 'boz', undef: undefined }; var objKeys = ['aNull', 'arr', 'bool', 'num', 'obj', 'str', 'undef']; var returnEmptyArray = function () { return []; }; var preserve = function preserveProperty(object, property, callback) { reRequire(); return function preserved() { var original = object[property]; try { return callback.apply(this, arguments); } finally { object[property] = original; // eslint-disable-next-line no-unsafe-finally if (object[property] !== original) { throw new EvalError('should never happen'); } reRequire(); } }; }; test('exports a "shim" function', function (t) { t.equal(typeof keysShim.shim, 'function', 'keysShim.shim is a function'); t.test('when Object.keys is present', preserve(Object, 'keys', function (st) { Object.keys = returnEmptyArray; st.equal(Object.keys, returnEmptyArray, 'Object.keys has been replaced'); var shimmedKeys = keysShim.shim(); st.notEqual(Object.keys, keysShim, 'Object.keys is not overridden to the shim'); st.notEqual(Object.keys, returnEmptyArray, 'Object.keys is overridden, is not returnEmptyArray'); st.equal(shimmedKeys, Object.keys, 'Object.keys is returned'); st.end(); })); t.test('when Object.keys is not present', { skip: Object.keys }, preserve(Object, 'keys', function (st) { st.notOk(Object.keys, 'Object.keys does not exist'); var shimmedKeys = keysShim.shim(); st.equal(Object.keys, keysShim, 'Object.keys is overridden'); st.equal(shimmedKeys, keysShim, 'shim is returned'); st.end(); })); t.test('when Object.keys has arguments bug', preserve(Object, 'keys', function (st) { st.deepEqual(arguments.length, 1, 'arguments has expected length'); var originalObjectKeys = Object.keys; var fakeKeys = function keys(object) { if (is.args(object)) { return []; } return originalObjectKeys(object); }; Object.keys = fakeKeys; st.deepEqual(Object.keys(arguments), [], 'Object.keys has arguments bug'); var shimmedKeys = keysShim.shim(); st.notEqual(fakeKeys, shimmedKeys, 'Object.keys is not original fake value'); st.equal(Object.keys, shimmedKeys, 'Object.keys is overridden'); st.deepEqual(Object.keys(arguments), ['0'], 'Object.keys now works with arguments'); st.end(); })); t.end(); }); test('working with actual shim', function (t) { t.notEqual(Object.keys, keysShim, 'keys shim is not native Object.keys'); t.end(); }); test('works with an object literal', function (t) { var theKeys = keysShim(obj); t.equal(is.array(theKeys), true, 'returns an array'); t.deepEqual(theKeys, objKeys, 'Object has expected keys'); t.end(); }); test('works with an arguments object', function (t) { (function () { t.equal(arguments.length, 3, 'arguments has length of 3'); t.deepEqual(keysShim(arguments), ['0', '1', '2'], 'returns keys of arguments'); }(1, 2, 3)); t.end(); }); test('works with a boxed primitive', function (t) { t.deepEqual(keysShim(Object('hello')), ['0', '1', '2', '3', '4'], 'object string returns proper keys'); /* eslint-disable no-new-wrappers */ t.deepEqual(keysShim(new String('hello')), ['0', '1', '2', '3', '4'], 'String object returns proper keys'); var x = new String('x'); /* eslint-enable no-new-wrappers */ x.y = 1; t.deepEqual(keysShim(x).sort(), ['0', 'y'].sort(), 'String object with extra properties returns proper keys'); t.end(); }); test('works with an array', function (t) { var arr = [1, 2, 3]; var theKeys = keysShim(arr); t.equal(is.array(theKeys), true, 'returns an array'); t.deepEqual(theKeys, ['0', '1', '2'], 'Array has expected keys'); t.end(); }); test('works with a function', function (t) { var foo = function () {}; foo.a = true; t.doesNotThrow(function () { return keysShim(foo); }, 'does not throw an error'); t.deepEqual(keysShim(foo), ['a'], 'returns expected keys'); t.end(); }); test('returns names which are own properties', function (t) { var theKeys = keysShim(obj); for (var i = 0; i < theKeys.length; ++i) { t.equal(has.call(obj, theKeys[i]), true, theKeys[i] + ' should be returned'); } t.end(); }); test('returns names which are enumerable', function (t) { var k; var loopedValues = []; for (k in obj) { if (enumerable.call(obj, k)) { loopedValues.push(k); } } var theKeys = keysShim(obj); for (var i = 0; i < theKeys.length; ++i) { t.notEqual(indexOf(loopedValues, theKeys[i]), -1, theKeys[i] + ' is not enumerable'); } t.end(); }); test('throws an error for a non-object', function (t) { t['throws']( function () { return keysShim(null); }, new TypeError('Object.keys called on a non-object'), 'throws on a non-object' ); t.end(); }); test('works with an object instance', function (t) { var Prototype = function () {}; Prototype.prototype.foo = true; var instance = new Prototype(); instance.bar = true; var theKeys = keysShim(instance); t.equal(is.array(theKeys), true, 'returns an array'); t.deepEqual(theKeys, ['bar'], 'Instance has expected keys'); t.end(); }); test('works in iOS 5 mobile Safari', function (t) { var Foo = function () {}; Foo.a = function () {}; // the bug is keysShim(Foo) => ['a', 'prototype'] instead of ['a'] t.deepEqual(keysShim(Foo), ['a'], 'has expected keys'); t.end(); }); test('works in environments with the dontEnum bug (IE < 9)', function (t) { var Foo = function () {}; Foo.prototype.a = function () {}; // the bug is keysShim(Foo.prototype) => ['a', 'constructor'] instead of ['a'] t.deepEqual(keysShim(Foo.prototype), ['a'], 'has expected keys'); t.end(); }); test('shadowed properties', function (t) { var shadowedProps = [ 'dummyControlProp', /* just to be sure */ 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf' ]; shadowedProps.sort(); var shadowedObject = {}; for (var i = 0; i < shadowedProps.length; ++i) { shadowedObject[shadowedProps[i]] = i; } var shadowedObjectKeys = keysShim(shadowedObject); shadowedObjectKeys.sort(); t.deepEqual(shadowedObjectKeys, shadowedProps, 'troublesome shadowed properties are keys of object literals'); t.end(); }); test('host objects on `window` constructor.prototype equal to themselves', { skip: typeof window === 'undefined' }, function (t) { var keys, exception; var excludedKeys = { $applicationCache: true, $console: true, $external: true, $frame: true, $frameElement: true, $frames: true, $innerHeight: true, $innerWidth: true, $onmozfullscreenchange: true, $onmozfullscreenerror: true, $outerHeight: true, $outerWidth: true, $pageXOffset: true, $pageYOffset: true, $parent: true, $scrollLeft: true, $scrollTop: true, $scrollX: true, $scrollY: true, $self: true, $webkitIndexedDB: true, $webkitStorageInfo: true, $window: true }; for (var k in window) { keys = undefined; exception = undefined; if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { try { keys = keysShim(window[k]); } catch (e) { exception = e; } t.ok(is.array(keys), 'keys of window["' + k + '"] is an array'); t.equal(exception, undefined, 'there is no exception: window["' + k + '"]'); } } t.end(); });