All Projects → feross → fromentries

feross / fromentries

Licence: MIT License
Object.fromEntries() ponyfill (in 6 lines)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to fromentries

Clipboard Polyfill
📋 Simple copying on the web, with maximum browser compatibility.
Stars: ✭ 748 (+1106.45%)
Mutual labels:  polyfill, ponyfill
mini-create-react-context
(A smaller) polyfill for the react context API
Stars: ✭ 34 (-45.16%)
Mutual labels:  polyfill, ponyfill
Scroll Into View If Needed
Element.scrollIntoView ponyfills for things like "if-needed" and "smooth"
Stars: ✭ 811 (+1208.06%)
Mutual labels:  polyfill, ponyfill
Fakeindexeddb
A pure JS in-memory implementation of the IndexedDB API
Stars: ✭ 373 (+501.61%)
Mutual labels:  polyfill, ponyfill
Object.fromEntries
Official ES spec-compliant polyfill for Object.fromEntries
Stars: ✭ 33 (-46.77%)
Mutual labels:  object, fromentries
Resize Observer
Polyfills the ResizeObserver API.
Stars: ✭ 540 (+770.97%)
Mutual labels:  polyfill, ponyfill
Css Vars Ponyfill
Client-side support for CSS custom properties (aka "CSS variables") in legacy and modern browsers
Stars: ✭ 1,166 (+1780.65%)
Mutual labels:  polyfill, ponyfill
Ponyfill
🦄 Like polyfill but with pony pureness
Stars: ✭ 945 (+1424.19%)
Mutual labels:  polyfill, ponyfill
Core Js
Standard Library
Stars: ✭ 15,854 (+25470.97%)
Mutual labels:  polyfill, ponyfill
Tickedoff
Tiny library (<200B gzip) for deferring something by a "tick"
Stars: ✭ 213 (+243.55%)
Mutual labels:  polyfill, ponyfill
Promise Fun
Promise packages, patterns, chat, and tutorials
Stars: ✭ 3,779 (+5995.16%)
Mutual labels:  polyfill, ponyfill
object-keys
Object.keys shim
Stars: ✭ 41 (-33.87%)
Mutual labels:  polyfill, object
Abortcontroller Polyfill
Polyfill for the AbortController DOM API and abortable fetch (stub that calls catch, doesn't actually abort request).
Stars: ✭ 273 (+340.32%)
Mutual labels:  polyfill, ponyfill
Unfetch
🐕 Bare minimum 500b fetch polyfill.
Stars: ✭ 5,239 (+8350%)
Mutual labels:  polyfill, ponyfill
web-streams-polyfill
Web Streams, based on the WHATWG spec reference implementation
Stars: ✭ 198 (+219.35%)
Mutual labels:  polyfill, ponyfill
Resize Observer Polyfill
A polyfill for the Resize Observer API
Stars: ✭ 1,530 (+2367.74%)
Mutual labels:  polyfill, ponyfill
Object.getOwnPropertyDescriptors
Spec-compliant shim for `Object.getOwnPropertyDescriptors` that works in ES5.
Stars: ✭ 19 (-69.35%)
Mutual labels:  polyfill, object
o9n
🖥 A screen.orientation ponyfill
Stars: ✭ 55 (-11.29%)
Mutual labels:  polyfill, ponyfill
glob-object
Filter an object using glob patterns and dot notation.
Stars: ✭ 25 (-59.68%)
Mutual labels:  object
core-web
like core-js but for Web APIs (based on polyfill.io)
Stars: ✭ 34 (-45.16%)
Mutual labels:  polyfill

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) pull in a bunch of dependencies and adds over 8 KB to the browser bundle size. This allows them to work in ES3 environments like IE6, but it's also overkill; almost no one supports IE6 anymore.

I'd rather not ship tons of extra code to 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)
constole.log(obj) // { a: 1, b: 2, c: 3 }

const searchParams = new URLSearchParams('foo=bar&baz=qux')
const obj2 = fromEntries(searchParams)
console.log(obj2) // { foo: 'bar', 'baz': 'qux' }

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].