Socket
Socket
Sign inDemoInstall

object-keys

Package Overview
Dependencies
0
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    object-keys

An Object.keys replacement, in case Object.keys is not available. From https://github.com/es-shims/es5-shim


Version published
Weekly downloads
35M
decreased by-0.43%
Maintainers
1
Install size
27.0 kB
Created
Weekly downloads
 

Package description

What is object-keys?

The object-keys npm package is a utility that provides a shim for the Object.keys method, which returns an array of a given object's own enumerable property names. It is particularly useful for environments that do not support the native Object.keys method, such as older versions of JavaScript engines.

What are object-keys's main functionalities?

Shim for Object.keys

Provides a cross-browser implementation of Object.keys to retrieve the keys of an object.

var keys = require('object-keys');
var obj = { a: 1, b: 2, c: 3 };
console.log(keys(obj)); // ['a', 'b', 'c']

Other packages similar to object-keys

Readme

Source

#object-keys Version Badge

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

Keywords

FAQs

Last updated on 07 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc