Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
object.fromentries
Advanced tools
Package description
The object.fromentries npm package is a polyfill for the Object.fromEntries() method, which transforms a list of key-value pairs into an object. This is particularly useful for converting Map objects or arrays of arrays into object literals, allowing for easy manipulation and access of data structures.
Converting Map to Object
This feature allows for the conversion of Map objects to plain objects, making it easier to work with and access data stored in Maps.
const map = new Map([['foo', 'bar'], ['baz', 42]]);
const obj = Object.fromEntries(map);
console.log(obj); // Output: { foo: 'bar', baz: 42 }
Converting Array of Arrays to Object
This feature enables the transformation of an array of arrays (each inner array representing a key-value pair) into an object, simplifying the process of creating objects from structured data arrays.
const entries = [['foo', 'bar'], ['baz', 42]];
const obj = Object.fromEntries(entries);
console.log(obj); // Output: { foo: 'bar', baz: 42 }
Lodash's _.fromPairs() method offers similar functionality to Object.fromEntries by converting an array of key-value pairs into an object. While lodash.frompairs provides this as part of a larger utility library, object.fromentries focuses solely on this conversion feature.
Ramda's R.fromPairs function also converts an array of key-value pairs into an object. Compared to object.fromentries, Ramda offers this functionality within a functional programming context, providing a broader set of tools for data transformation and manipulation.
Changelog
v2.0.6 - 2022-11-06
867603d
auto-changelog
3621c90
eslint
, @ljharb/eslint-config
, @es-shims/api
, safe-publish-latest
, tape
d6c3de7
define-properties
, es-abstract
a0eca66
91df159
e7f2c96
eslint
, @ljharb/eslint-config
, aud
, tape
ec22968
es-abstract
has
depprepublishOnly
script for npm 7+eslint
, @ljharb/eslint-config
, @es-shims/api
, aud
, tape
node/install
instead of node/run
; use codecov
actioncall-bind
, es-abstract
eslint
, @ljharb/eslint-config
, aud
, has-strict-mode
, tape
es-abstract
; remove function-bind
; use call-bind
where applicableeslint
, @ljharb/eslint-config
, tape
; add aud
, safe-publish-latest
pull_request_target
eventnyc
on all testsimplementation
test; run es-shim-api
in postlint; use tape
runneres-abstract
(63% bundle size decrease)eslint
, @ljharb/eslint-config
funding
fieldObject.fromEntries
when already presentdefine-properties
, es-abstract
, has
eslint
, @ljharb/eslint-config
, covert
, tape
node
v12.9
, v11.15
, v10.16
, v9.11
, v8.16
, v6.17
, v4.9
npx aud
instead of nsp
or npm audit
with hoopsiterable
is nullishReadme
An ES spec-proposal-compliant Object.fromEntries
shim. Invoke its "shim" method to shim Object.fromEntries
if it is unavailable or noncompliant.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.
Most common usage:
var assert = require('assert');
var fromEntries = require('object.fromentries');
var obj = { a: 1, b: 2, c: 3 };
var actual = fromEntries(Object.entries(obj));
assert.deepEqual(obj, actual);
if (!Object.fromEntries) {
fromEntries.shim();
}
assert.deepEqual(Object.fromEntries(Object.entries(obj)), obj);
Simply clone the repo, npm install
, and run npm test
FAQs
ES proposal-spec-compliant Object.fromEntries shim.
The npm package object.fromentries receives a total of 21,117,563 weekly downloads. As such, object.fromentries popularity was classified as popular.
We found that object.fromentries demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.