{"id":13549783,"url":"https://github.com/sindresorhus/ponyfill","last_synced_at":"2025-05-16T07:06:30.363Z","repository":{"id":39614493,"uuid":"69574700","full_name":"sindresorhus/ponyfill","owner":"sindresorhus","description":"🦄 Like polyfill but with pony pureness","archived":false,"fork":false,"pushed_at":"2024-02-06T09:31:52.000Z","size":566,"stargazers_count":1247,"open_issues_count":1,"forks_count":25,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-05-12T01:32:04.454Z","etag":null,"topics":["polyfill","ponies","ponyfill","unicorns"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2016-09-29T14:19:54.000Z","updated_at":"2025-05-08T21:37:16.000Z","dependencies_parsed_at":"2022-07-13T10:30:30.496Z","dependency_job_id":"fbef8b0d-b31b-465f-9099-b09136da5911","html_url":"https://github.com/sindresorhus/ponyfill","commit_stats":{"total_commits":15,"total_committers":6,"mean_commits":2.5,"dds":"0.33333333333333337","last_synced_commit":"260eb9c0f567e162307131e58a6bf936556cde5a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fponyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fponyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fponyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fponyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/ponyfill/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485063,"owners_count":22078767,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["polyfill","ponies","ponyfill","unicorns"],"created_at":"2024-08-01T12:01:25.485Z","updated_at":"2025-05-16T07:06:30.274Z","avatar_url":"https://github.com/sindresorhus.png","language":null,"funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Others"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n\t\u003cimg src=\"media/header-min.svg\" alt=\"Ponyfill\"\u003e\n\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003eLike polyfill but with pony pureness\u003c/h4\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n*Use [ponyfill.com](https://ponyfill.com) for linking here.*\n\n## Pony pureness, really?\n\nWhile polyfills are naughty, ponyfills are pure, just like ponies.\n\n## How are ponyfills better than polyfills?\n\nA [polyfill](https://en.wikipedia.org/wiki/Polyfill_(programming)) is code that adds missing functionality by [monkey patching](https://en.wikipedia.org/wiki/Monkey_patch) 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.](https://www.nczonline.net/blog/2010/03/02/maintainable-javascript-dont-modify-objects-you-down-own/)\n\nA 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.\n\n*tl;dr:* Polyfills are naughty as they patch native APIs, while ponyfills are pure and don't affect the environment.\n\n### Polyfill\n\n```js\nNumber.isNaN ??= function (value) {\n\treturn value !== value;\n};\n```\n\n```js\nimport 'is-nan-polyfill';\n\nNumber.isNaN(5);\n```\n\n### Ponyfill\n\n```js\nexport default function isNaN(value) {\n\treturn value !== value;\n};\n```\n\n```js\nimport isNanPonyfill from 'is-nan-ponyfill';\n\nisNanPonyfill(5);\n```\n\n**Ponyfills should avoid using native APIs**, because potential bugs or differences in the native APIs will make such a ponyfill less robust (therefore defeating one of its main purposes). There are important exceptions, such as when:\n\n- There is no way to implement some of the ponyfill without native APIs.\n- Reimplementing native parts would have a large cost (e.g. performance or code size).\n\nIn such cases, it's still valuable for the ponyfill to minimize any assumptions about the underlying environment.\n\n## Where can I find ponyfills?\n\n[Search npm.](https://npms.io/search?q=keywords%3Aponyfill)\n\n## How do I make a ponyfill?\n\n- Read the specification or source code of the feature you want to ponyfill.\n- Initialize an [npm package](https://github.com/sindresorhus/generator-nm).\n- [Write some tests](https://avajs.dev) to ease writing the ponyfill logic.\n- Link to documentation about the feature in your readme. [Example.](https://github.com/sindresorhus/buffer-includes#readme)\n- Link to `https://ponyfill.com` in your readme. [Example.](https://github.com/sindresorhus/object-assign#readme)\n- Add `ponyfill` to the `keywords` section in package.json.\n- Publish!\n\n## Resources\n\n- [Ponyfill definition - Silicon Valley Dictionary](http://svdictionary.com/words/ponyfill)\n- [Polyfills or Ponyfills? - Pony Foo](https://ponyfoo.com/articles/polyfills-or-ponyfills)\n- [Polyfill, Ponyfill and Prollyfill - Kikobeats](https://kikobeats.com/polyfill-ponyfill-and-prollyfill/)\n\n## License\n\n[![CC0](http://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg)](https://creativecommons.org/publicdomain/zero/1.0/)\n\nTo the extent possible under law, [Sindre Sorhus](https://sindresorhus.com) has waived all copyright and related or neighboring rights to this work.\n\nHeader based on work by [Mary Winkler](https://www.vecteezy.com/members/acrylicana).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fponyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fponyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fponyfill/lists"}