Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
object-keys
Advanced tools
An Object.keys replacement, in case Object.keys is not available. From https://github.com/es-shims/es5-shim
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.
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']
Lodash is a popular utility library that includes a method called _.keys, which is similar to object-keys. It provides a more robust solution for getting the keys of an object, handling edge cases and supporting a wider range of environments, but it is part of a larger library which may be more than needed if only this functionality is required.
Core-js is a modular standard library for JavaScript, which includes polyfills for many ECMAScript features. It offers a polyfill for Object.keys, among many other features. It is more comprehensive than object-keys, but also larger in size, which might not be ideal for projects looking to minimize dependencies.
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');
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));
Implementation taken directly from es5-shim, with modifications, including from lodash.
Simply clone the repo, npm install
, and run npm test
FAQs
An Object.keys replacement, in case Object.keys is not available. From https://github.com/es-shims/es5-shim
The npm package object-keys receives a total of 19,542,184 weekly downloads. As such, object-keys popularity was classified as popular.
We found that object-keys demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.