#object-keys <sup>Version Badge</sup>

Build Status dependency status dev dependency status License Downloads

npm badge

browser support

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 - Installation

To install object-keys via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install object-keys --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install object-keys

Learn more about the config option.

PNPM

pnpm install object-keys --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install object-keys --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

object-keys - Download

Download Tarball (v1.1.1)

Integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==
SHASUM 1c47f272df277f3b1daf061677d9c82e2322c60e
Tarball https://js.registry.sudovanilla.org/object-keys/-/object-keys-1.1.1.tgz