JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6443070
  • Score
    100M100P100Q207858F
  • License MIT

Object.fromEntries() ponyfill (in 6 lines)

Package Exports

  • fromentries

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fromentries) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fromentries travis npm downloads javascript style guide

Object.fromEntries() ponyfill (in 6 lines)

Install

npm install fromentries

Why this package?

Existing polyfill packages (like [object.fromentries](https://github.com/es- shims/Object.fromEntries)) pulls in a bunch of dependencies and adds over 8 KB to the browser bundle size. This allows it work in ES3 environments like IE6, but it's also overkill since almost no one supports IE6 anymore.

I'd rather not ship tons of extra code to my website visitors. A polyfill for this feature can be implemented in a few short lines of code using modern language features. That's what fromentries (this package) does.

This means that fromentries only works in evergreen browsers like:

  • Chrome
  • Firefox
  • Edge
  • Safari
  • Opera

It does not work in browsers like IE11 and older (unless you transpile it first).

Usage

const fromEntries = require('fromentries')

const map = new Map([ [ 'a', 1 ], [ 'b', 2 ], [ 'c', 3 ] ])
const obj = fromEntries(map)

What is a ponyfill?

A ponyfill is almost the same as a polyfill, but not quite. Instead of patching functionality for older browsers, a ponyfill provides that functionality as a standalone module you can use.

Read more at PonyFoo.

See also

License

MIT. Copyright (c) Feross Aboukhadijeh.