Git Product home page Git Product logo

object-keys's Introduction

object-keys Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An Object.keys shim. Invoke its "shim" method to shim Object.keys if it is unavailable.

Most common usage:

var keys = Object.keys || require('object-keys');

Example

var keys = require('object-keys');
var assert = require('assert');
var obj = {
	a: true,
	b: true,
	c: true
};

assert.deepEqual(keys(obj), ['a', 'b', 'c']);
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));
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, with modifications, including from lodash.

Tests

Simply clone the repo, npm install, and run npm test

object-keys's People

Contributors

gkatsev avatar istarkov avatar joshuacc avatar ljharb avatar raynos avatar vdh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

object-keys's Issues

An in-range update of tape is breaking the build ๐Ÿšจ

Version 4.7.0 of tape just got published.

Branch Build failing ๐Ÿšจ
Dependency tape
Current Version 4.6.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As tape is โ€œonlyโ€ a devDependency of this project it might not break production or downstream projects, but โ€œonlyโ€ your build or test tools โ€“ preventing new deploys or publishes.

I recommend you give this issue a high priority. Iโ€™m sure you can resolve this ๐Ÿ’ช

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 19 commits.

  • 1d0df26 v4.7.0
  • 51597e2 Merge pull request #374 from feross/master
  • b06f914 [Refactor] instead of throwing on undefined.forEach, throw explicitly.
  • dd93216 [Fix] fix spurious "test exited without ending"
  • 1a8e936 [Deps] update glob, resolve
  • 7eb9e36 [Dev Deps] update falafel, js-yaml
  • e030260 [Tests] on node v8; no need for sudo; v0.8 passes now; allow v5/v7/iojs to fail.
  • 4375661 [Tests] npm v5+ breaks on node < v4
  • df48bfa Only apps should have lock files.
  • 35e47e1 [Tests] npm v4.6+ breaks on node < v1
  • dc1ffa5 [Deps] update object-inspect
  • 66519cb [Deps] update resolve
  • e6d4625 [Dev Deps] update concat-stream, js-yaml
  • bdf2b04 tap-min moved to derhuerst/tap-min
  • 8b3a77e [Tests] fix thrower stack in node 0.8

There are 19 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot ๐ŸŒด

The `!(skipConstructor && name === 'constructor')` should be moved into the `hasDontEnumBug` block.

The !(skipConstructor && name === 'constructor') should be moved into the hasDontEnumBug block. And constructor should be added to the dontEnums array.

You can test this by having an object of properties, smth like I do in my own tests:

var shadowedProps = [
    'constructor',
    'hasOwnProperty',
    'isPrototypeOf',
    'propertyIsEnumerable',
    'toLocaleString',
    'toString',
    'valueOf'
  ];

  /** Used to check problem JScript properties too */
  var shadowedObject = _.invert(shadowedProps);

In older IE Object.keys(shadowedObject) should produce an array of keys that is equiv to shadowedProps. The constructor check which should be moved to the hasDontEnumBug is to ensure that the constructor property is skipped on prototype objects but not plain object literals.

Avoid reflow at accessing the window object

Accessing all keys in the window object leads to an reflow at line 41 in index.js. A fast and dirty workaround of me would be to avoid all attributes with with or height in it.

if(k.toLowerCase().indexOf('width') > -1 || k.toLowerCase.indexOf('height') > -1) continue;

As I don't understand the reason for the function completely I'm not really able to propose a correct pull request. That's why I just raised an issue. I hope that's okay.

An in-range update of is is breaking the build ๐Ÿšจ

The devDependency is was updated from 3.2.1 to 3.3.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

is is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 9 commits.

  • 188a52b v3.3.0
  • 90076dc [New] add is.bigint
  • ce27962 [Tests] up to node v11.4, v10.14, v9.11, v8.14, v7.10, v6.15, v4.9; use nvm install-latest-npm
  • ec12d8f Only apps should have lockfiles
  • 71b29dd [Dev Deps] update eslint, @ljharb/eslint-config, safe-publish-latest, tape
  • 982047c Merge pull request #34 from kpiotr/fixTypeAnnotations
  • 9bca53f Change "Mixed" type annotations to wildcards
  • 1354001 [Tests] up to node v7.7, v6.10, v4.8
  • 852b4e5 [Dev Deps] update eslint

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Outputs tons of errors in Chrome app environment

When I use object-keys in Chrome app (usually through some other package, but that doesn't matter really), it outputs all these errors:

extensions::platformApp:17 window.localStorage is not available in packaged apps. Use chrome.storage.local instead.
extensions::platformApp:17 window.toolbar is not available in packaged apps.
extensions::platformApp:17 window.statusbar is not available in packaged apps.
extensions::platformApp:17 window.scrollbars is not available in packaged apps.
extensions::platformApp:17 window.personalbar is not available in packaged apps.
extensions::platformApp:17 window.menubar is not available in packaged apps.
extensions::platformApp:17 window.locationbar is not available in packaged apps.
extensions::platformApp:17 window.localStorage is not available in packaged apps. Use chrome.storage.local instead.

It comes from this part
https://github.com/ljharb/object-keys/blob/master/index.js#L46-L63

It seems window.localStorage etc. is "available" to list throuch for-in, but shows that error message on accessing it. (Not sure if it actually throws an error or not.)

It is a purely cosmetic bug and doesn't affect the functionality at all (it doesn't crash the application); however, it's not "nice" that it barfs all the bugs at the start

An in-range update of eslint is breaking the build ๐Ÿšจ

Version 4.12.0 of eslint was just published.

Branch Build failing ๐Ÿšจ
Dependency eslint
Current Version 4.11.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v4.12.0
  • 76dab18 Upgrade: doctrine@^2.0.2 (#9656) (Kevin Partington)
  • 28c9c8e New: add a Linter#defineParser function (#9321) (Ives van Hoorne)
  • 5619910 Update: Add autofix for sort-vars (#9496) (Trevin Hofmann)
  • 71eedbf Update: add beforeStatementContinuationChars to semi (fixes #9521) (#9594) (Toru Nagashima)
  • 4118f14 New: Adds implicit-arrow-linebreak rule (refs #9510) (#9629) (Sharmila Jesupaul)
  • 208fb0f Fix: Use XML 1.1 on XML formatters (fixes #9607) (#9608) (Daniel Reigada)
  • 6e04f14 Upgrade: globals to 11.0.1 (fixes #9614) (#9632) (Toru Nagashima)
  • e13d439 Fix: space-in-parens crash (#9655) (Toru Nagashima)
  • 92171cc Docs: Updating migration guide for single-line disable (#9385) (Justin Helmer)
  • f39ffe7 Docs: remove extra punctuation from readme (#9640) (Teddy Katz)
  • a015234 Fix: prefer-destructuring false positive on "super" (fixes #9625) (#9626) (Kei Ito)
  • 0cf081e Update: add importNames option to no-restricted-imports (#9506) (Benjamin R Gibson)
  • 332c214 Docs: Add @platinumazure to TSC (#9618) (Ilya Volodin)
Commits

The new version differs by 15 commits.

  • f4a65c6 4.12.0
  • 1cd1627 Build: changelog update for 4.12.0
  • 76dab18 Upgrade: doctrine@^2.0.2 (#9656)
  • 28c9c8e New: add a Linter#defineParser function (#9321)
  • 5619910 Update: Add autofix for sort-vars (#9496)
  • 71eedbf Update: add beforeStatementContinuationChars to semi (fixes #9521) (#9594)
  • 4118f14 New: Adds implicit-arrow-linebreak rule (refs #9510) (#9629)
  • 208fb0f Fix: Use XML 1.1 on XML formatters (fixes #9607) (#9608)
  • 6e04f14 Upgrade: globals to 11.0.1 (fixes #9614) (#9632)
  • e13d439 Fix: space-in-parens crash (#9655)
  • 92171cc Docs: Updating migration guide for single-line disable (#9385)
  • f39ffe7 Docs: remove extra punctuation from readme (#9640)
  • a015234 Fix: prefer-destructuring false positive on "super" (fixes #9625) (#9626)
  • 0cf081e Update: add importNames option to no-restricted-imports (#9506)
  • 332c214 Docs: Add @platinumazure to TSC (#9618)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

`constructor` property inconsistency

In environments with the [[DontEnum]] bug, IE < 9

function Foo() {}
Foo.prototype.a = function(){}

Object.keys(Foo.prototype);
// => ['a', 'constructor'] instead of ['a']

If you'd dig addressing it, libs like Lo-Dash tackle this issue.

An in-range update of eslint is breaking the build ๐Ÿšจ

Version 4.6.1 of eslint just got published.

Branch Build failing ๐Ÿšจ
Dependency eslint
Current Version 4.6.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint is โ€œonlyโ€ a devDependency of this project it might not break production or downstream projects, but โ€œonlyโ€ your build or test tools โ€“ preventing new deploys or publishes.

I recommend you give this issue a high priority. Iโ€™m sure you can resolve this ๐Ÿ’ช

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v4.6.1
  • bdec46d Build: avoid process leak when generating website (#9217) (Teddy Katz)
  • cb74b87 Fix: avoid adding globals when an env is used with false (fixes #9202) (#9203) (Teddy Katz)
  • f9b7544 Docs: Correct a typo in generator-star-spacing documentation (#9205) (Ethan Rutherford)
  • e5c5e83 Build: Fixing issue with docs generation (Fixes #9199) (#9200) (Ilya Volodin)
Commits

The new version differs by 6 commits.

  • d65c540 4.6.1
  • 61c845c Build: changelog update for 4.6.1
  • bdec46d Build: avoid process leak when generating website (#9217)
  • cb74b87 Fix: avoid adding globals when an env is used with false (fixes #9202) (#9203)
  • f9b7544 Docs: Correct a typo in generator-star-spacing documentation (#9205)
  • e5c5e83 Build: Fixing issue with docs generation (Fixes #9199) (#9200)

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot ๐ŸŒด

Simplify module

I came across this module looking for object keys working in all browsers.
It solves the problem, but IMO is very complex and could do with a lot less code.

I'm thinking along the lines of mdn polyfill.

I don't know the history of this module, maybe some things I regard as unnecessary are here to fix certain bugs/issues, but basically I'd like to simplify this in order to use it in lots of libraries without getting too much code bloat.

Would you consider a PR to basically replace the current implementation with the MDN polyfill? Of course I'd rewrite it to not override Object.keys but instead expose a simple function.
If not that is fine as well, just let me know, I just wanted to ask before I publish another module that solves the same problem.

An in-range update of @ljharb/eslint-config is breaking the build ๐Ÿšจ

The devDependency @ljharb/eslint-config was updated from 13.0.0 to 13.1.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@ljharb/eslint-config is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 5 commits.

  • 2dd67e5 v13.1.0
  • 34a402a [Minor] update config and require eslint v5.11
  • fd1f310 [Dev Deps] update eslint, replace, safe-publish-latest, semver
  • 2d1a944 [Tests] use npm audit instead of nsp
  • a02c14b [Tests] up to node v11.6, v10.15, v8.15, v6.16

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Loading this shim on Chrome 67 will raise a warning

When using this code in my project:

import objectKeys from 'object-keys';

I will see this warning in Chrome 67.0.3396.87 console:
index.js:51 [Deprecation] Application Cache is deprecated in non-secure contexts, and will be restricted to secure contexts in M69, around September 2018. Please consider migrating your application to HTTPS, and eventually shifting over to Service Workers. See https://goo.gl/rStTGz for more details.

You can reproduce the warning by downloading this project https://codesandbox.io/s/kxp55lx90o and then do:

npm install
npm start

An in-range update of tape is breaking the build ๐Ÿšจ

The devDependency tape was updated from 4.10.0 to 4.10.1.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

tape is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 4 commits.

  • 4708a3d v4.10.1
  • a63261e [Deps] update resolve
  • 34ebb4c [Refactor] consistent spacing
  • b74c4fd Partial revert of #403: fbe4b951cb6c6cc4f0e9e3ae4a57b123dd82c0fb and 367b010d21c7c9814c4bc6b21d1c2a9a67596c11

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Function.prototype iteration issue

Following up from an xtend issue...
IOS 5 versions of mobile Safari will incorrectly iterate over Function.prototype.

function Foo() {}
Foo.a = function(){};

Object.keys(Foo);
// => ['a', 'prototype'] instead of ['a']

If you're interested in addressing it, libs like YUI and Lo-Dash tackle this issue.

An in-range update of eslint is breaking the build ๐Ÿšจ

Version 4.11.0 of eslint was just published.

Branch Build failing ๐Ÿšจ
Dependency eslint
Current Version 4.10.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v4.11.0
  • d4557a6 Docs: disallow use of the comma operator using no-restricted-syntax (#9585) (่–›ๅฎš่ฐ”็š„็Œซ)
  • d602f9e Upgrade: espree v3.5.2 (#9611) (Kai Cataldo)
  • 4def876 Chore: avoid handling rules instances in config-validator (#9364) (Teddy Katz)
  • fe5ac7e Chore: fix incorrect comment in safe-emitter.js (#9605) (Teddy Katz)
  • 6672fae Docs: Fixed a typo on lines-between-class-members doc (#9603) (Moinul Hossain)
  • 980ecd3 Chore: Update copyright and license info (#9599) (่–›ๅฎš่ฐ”็š„็Œซ)
  • cc2c7c9 Build: use Node 8 in appveyor (#9595) (่–›ๅฎš่ฐ”็š„็Œซ)
  • 2542f04 Docs: Add missing options for lines-around-comment (#9589) (Clรฉment Fiorio)
  • b6a7490 Build: ensure fuzzer tests get run with npm test (#9590) (Teddy Katz)
  • 1073bc5 Build: remove shelljs-nodecli (refs #9533) (#9588) (Teddy Katz)
  • 7e3bf6a Fix: edge-cases of semi-style (#9560) (Toru Nagashima)
  • e5a37ce Fix: object-curly-newline for flow code (#9458) (Tiddo Langerak)
  • 9064b9c Chore: add equalTokens in ast-utils. (#9500) (่–›ๅฎš่ฐ”็š„็Œซ)
  • b7c5b19 Fix: Correct [object Object] output of error.data. (#9561) (Jonathan Pool)
  • 51c8cf0 Docs: Disambiguate definition of Update tag (#9584) (Jonathan Pool)
  • afc3c75 Docs: clarify what eslint-config-eslint is (#9582) (Teddy Katz)
  • aedae9d Docs: fix spelling in valid-typeof example (#9574) (Maksim Degtyarev)
  • 4c5aaf3 Docs: Fix typo in no-underscore-dangle rule (#9567) (Fabien Lucas)
  • 3623600 Chore: upgrade [email protected] (#9557) (่–›ๅฎš่ฐ”็š„็Œซ)
  • 1b606cd Chore: Remove an indirect dependency on jsonify (#9444) (Rouven WeรŸling)
  • 4d7d7ab Update: Resolve npm installed formatters (#5900) (#9464) (Tom Erik Stรธwer)
  • accc490 Fix: Files with no failures get "passing" testcase (#9547) (Samuel Levy)
  • ab0f66d Docs: Add examples to better show rule coverage. (#9548) (Jonathan Pool)
  • 88d2303 Chore: Add object-property-newline tests to increase coverage. (#9553) (Jonathan Pool)
  • 7f37b1c Build: test Node 9 on Travis (#9556) (Teddy Katz)
  • acccfbd Docs: Minor rephrase in no-invalid-this. (#9542) (Francisc)
  • 8f9c0fe Docs: improve id-match usage advice (#9544) (Teddy Katz)
  • a9606a3 Fix: invalid tests with super (fixes #9539) (#9545) (Teddy Katz)
  • 8e1a095 Chore: enable a modified version of multiline-comment-style on codebase (#9452) (Teddy Katz)
  • cb60285 Chore: remove commented test for HTML formatter (#9532) (Teddy Katz)
  • 06b491e Docs: fix duplicate entries in changelog (#9530) (Teddy Katz)
  • 2224733 Chore: use eslint-plugin-rulesdir instead of --rulesdir for self-linting (#9164) (Teddy Katz)
  • 9cf4ebe Docs: add .md to link(for github users) (#9529) (่–›ๅฎš่ฐ”็š„็Œซ)
Commits

The new version differs by 35 commits.

  • 1a9a6a5 4.11.0
  • ef4d268 Build: changelog update for 4.11.0
  • d4557a6 Docs: disallow use of the comma operator using no-restricted-syntax (#9585)
  • d602f9e Upgrade: espree v3.5.2 (#9611)
  • 4def876 Chore: avoid handling rules instances in config-validator (#9364)
  • fe5ac7e Chore: fix incorrect comment in safe-emitter.js (#9605)
  • 6672fae Docs: Fixed a typo on lines-between-class-members doc (#9603)
  • 980ecd3 Chore: Update copyright and license info (#9599)
  • cc2c7c9 Build: use Node 8 in appveyor (#9595)
  • 2542f04 Docs: Add missing options for lines-around-comment (#9589)
  • b6a7490 Build: ensure fuzzer tests get run with npm test (#9590)
  • 1073bc5 Build: remove shelljs-nodecli (refs #9533) (#9588)
  • 7e3bf6a Fix: edge-cases of semi-style (#9560)
  • e5a37ce Fix: object-curly-newline for flow code (#9458)
  • 9064b9c Chore: add equalTokens in ast-utils. (#9500)

There are 35 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Config files being published to npm

Currently the following files are all published on npm:

.editorconfig
.eslintrc
.jscs.json
.travis.yml

These are all developer-related config files rather than user-related, so they shouldn't be published to npm.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.