object.fromentries

ES proposal-spec-compliant Object.fromEntries shim.

MIT 11 个版本
安装
npm install object.fromentries
yarn add object.fromentries
pnpm add object.fromentries
bun add object.fromentries
README

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

版本列表
2.0.8 2024-03-18
2.0.7 2023-08-29
2.0.6 2022-11-06
2.0.5 2021-10-03
2.0.4 2021-02-21
2.0.3 2020-11-27
2.0.2 2019-12-12
2.0.1 2019-10-03
2.0.0 2018-08-09
1.0.0 2018-04-04
0.0.1-security 2018-04-04