Socket
Socket
Sign inDemoInstall

object.fromentries

Package Overview
Dependencies
65
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    object.fromentries

ES proposal-spec-compliant Object.fromEntries shim.


Version published
Weekly downloads
22M
decreased by-0.56%
Maintainers
1
Install size
3.50 MB
Created
Weekly downloads
 

Package description

What is object.fromentries?

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.

What are object.fromentries's main functionalities?

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 }

Other packages similar to object.fromentries

Changelog

Source

v2.0.6 - 2022-11-06

Commits

  • [actions] reuse common workflows 867603d
  • [meta] add auto-changelog 3621c90
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, safe-publish-latest, tape d6c3de7
  • [Deps] update define-properties, es-abstract a0eca66
  • [actions] update rebase action to use reusable workflow 91df159
  • [actions] update codecov uploader e7f2c96
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, tape ec22968
<!-- auto-changelog-above -->

2.0.5 / 2021-10-03

  • [readme] add actions and codecov badges
  • [Deps] update es-abstract
  • [Deps] remove unused has dep
  • [meta] use prepublishOnly script for npm 7+
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, aud, tape
  • [actions] update workflows
  • [actions] use node/install instead of node/run; use codecov action
  • [Tests] increase coverage

2.0.4 / 2021-02-21

  • [readme] fix repo URLs; remove travis badge
  • [meta] do not publish github action workflow files
  • [Deps] update call-bind, es-abstract
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, has-strict-mode, tape
  • [actions] update workflows

2.0.3 / 2020-11-26

  • [Deps] update es-abstract; remove function-bind; use call-bind where applicable
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape; add aud, safe-publish-latest
  • [actions] add "Allow Edits" workflow
  • [actions] switch Automatic Rebase workflow to pull_request_target event
  • [Tests] migrate tests to Github Actions
  • [Tests] run nyc on all tests
  • [Tests] add implementation test; run es-shim-api in postlint; use tape runner
  • [Tests] only audit prod deps

2.0.2 / 2019-12-12

  • [Refactor] use split-up es-abstract (63% bundle size decrease)
  • [readme] remove testling
  • [Dev Deps] update eslint, @ljharb/eslint-config
  • [meta] add funding field
  • [Tests] use shared travis-ci configs
  • [actions] add automatic rebasing / merge commit blocking

2.0.1 / 2019-10-03

  • [Fix] do not mutate Object.fromEntries when already present
  • [Deps] update define-properties, es-abstract, has
  • [Dev Deps] update eslint, @ljharb/eslint-config, covert, tape
  • [Tests] up to node v12.9, v11.15, v10.16, v9.11, v8.16, v6.17, v4.9
  • [Tests] use npx aud instead of nsp or npm audit with hoops

2.0.0 / 2018-08-09

  • [Breaking] throw when iterable is nullish
  • [Docs] Fix link to proposed spec

1.0.0 / 2018-03-21

  • v1.0.0

Readme

Source

object.fromentries Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

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);

Tests

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

Keywords

FAQs

Last updated on 06 Nov 2022

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