All Projects → sindresorhus → Ponyfill

sindresorhus / Ponyfill

🦄 Like polyfill but with pony pureness

Projects that are alternatives of or similar to Ponyfill

Promise Fun
Promise packages, patterns, chat, and tutorials
Stars: ✭ 3,779 (+299.89%)
Mutual labels:  polyfill, unicorns, ponyfill
Core Js
Standard Library
Stars: ✭ 15,854 (+1577.67%)
Mutual labels:  polyfill, ponyfill
Scroll Into View If Needed
Element.scrollIntoView ponyfills for things like "if-needed" and "smooth"
Stars: ✭ 811 (-14.18%)
Mutual labels:  polyfill, ponyfill
fromentries
Object.fromEntries() ponyfill (in 6 lines)
Stars: ✭ 62 (-93.44%)
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 (+23.39%)
Mutual labels:  polyfill, ponyfill
Tickedoff
Tiny library (<200B gzip) for deferring something by a "tick"
Stars: ✭ 213 (-77.46%)
Mutual labels:  polyfill, ponyfill
mini-create-react-context
(A smaller) polyfill for the react context API
Stars: ✭ 34 (-96.4%)
Mutual labels:  polyfill, ponyfill
Resize Observer Polyfill
A polyfill for the Resize Observer API
Stars: ✭ 1,530 (+61.9%)
Mutual labels:  polyfill, ponyfill
Fakeindexeddb
A pure JS in-memory implementation of the IndexedDB API
Stars: ✭ 373 (-60.53%)
Mutual labels:  polyfill, ponyfill
Abortcontroller Polyfill
Polyfill for the AbortController DOM API and abortable fetch (stub that calls catch, doesn't actually abort request).
Stars: ✭ 273 (-71.11%)
Mutual labels:  polyfill, ponyfill
o9n
🖥 A screen.orientation ponyfill
Stars: ✭ 55 (-94.18%)
Mutual labels:  polyfill, ponyfill
Unfetch
🐕 Bare minimum 500b fetch polyfill.
Stars: ✭ 5,239 (+454.39%)
Mutual labels:  polyfill, ponyfill
web-streams-polyfill
Web Streams, based on the WHATWG spec reference implementation
Stars: ✭ 198 (-79.05%)
Mutual labels:  polyfill, ponyfill
Resize Observer
Polyfills the ResizeObserver API.
Stars: ✭ 540 (-42.86%)
Mutual labels:  polyfill, ponyfill
Clipboard Polyfill
📋 Simple copying on the web, with maximum browser compatibility.
Stars: ✭ 748 (-20.85%)
Mutual labels:  polyfill, ponyfill
Hyperform
Capture form validation back from the browser
Stars: ✭ 729 (-22.86%)
Mutual labels:  polyfill
Is countable Polyfill
A trivial but working polyfill for PHP 7.3 is_countable function. Supports PHP versions >= 5.3
Stars: ✭ 16 (-98.31%)
Mutual labels:  polyfill
Native Promise Only
A polyfill for native ES6 Promises as close as possible (no extensions) to the strict spec definitions.
Stars: ✭ 708 (-25.08%)
Mutual labels:  polyfill
Polyfill Service
Javascript polyfills as a service. Java implementation.
Stars: ✭ 8 (-99.15%)
Mutual labels:  polyfill
Fetch
A window.fetch JavaScript polyfill.
Stars: ✭ 25,118 (+2557.99%)
Mutual labels:  polyfill

Ponyfill

Like polyfill but with pony pureness




Use ponyfill.com for linking here.

Pony pureness, really?

While polyfills are naughty, ponyfills are pure, just like ponies.

How are ponyfills better than polyfills?

A polyfill is code that adds missing functionality by monkey patching an API. Unfortunately, it usually globally patches built-ins, which affects all code running in the environment. This is especially problematic when a polyfill is not fully spec compliant (which in some cases is impossible), as it could cause very hard to debug bugs and inconsistencies. Or when the spec for a new feature changes and your code depends on behavior that a module somewhere else in the dependency tree polyfills differently. In general, you should not modify API's you don't own.

A ponyfill, in contrast, doesn't monkey patch anything, but instead exports the functionality as a normal module, so you can use it locally without affecting other code.

tl;dr; Polyfills are naughty as they patch native APIs, while ponyfills are pure and don't affect the environment.

Polyfill

Number.isNaN = Number.isNaN || function (value) {
	return value !== value;
};
require('is-nan-polyfill');

Number.isNaN(5);

Ponyfill

module.exports = function (value) {
	return value !== value;
};
var isNanPonyfill = require('is-nan-ponyfill');

isNanPonyfill(5);

Ponyfills should never use the native API, even if available, as it might have slightly different behavior between environments, which can cause bugs.

Where can I find ponyfills?

Search npm.

How do I make a ponyfill?

  • Read the specification or source code of the feature you want to ponyfill.
  • Initialize an npm package.
  • Write some tests to ease writing the ponyfill logic.
  • Link to documentation about the feature in your readme. Example.
  • Link to https://ponyfill.com in your readme. Example.
  • Add ponyfill to the keywords section in package.json.
  • Publish!

Resources

License

CC0

To the extent possible under law, Sindre Sorhus has waived all copyright and related or neighboring rights to this work.

Header based on work by Mary Winkler.

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].