|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +[](https://opencollective.com/core-js) [](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [](https://www.npmjs.com/package/core-js) [](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=core-js-compat&from=2014-11-18) [](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=core-js-compat&from=2014-11-18) [](https://www.jsdelivr.com/package/npm/core-js-bundle) |
| 4 | + |
| 5 | +</div> |
| 6 | + |
| 7 | +> Modular standard library for JavaScript. Includes polyfills for ECMAScript up to 2025, ECMAScript proposals and some cross-platform WHATWG / W3C features. |
| 8 | +
|
| 9 | +<div class="features"> |
| 10 | + <div class="feature"> |
| 11 | + <div class="title"> |
| 12 | + <span class="icon"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> |
| 13 | + <path stroke-linecap="round" stroke-linejoin="round" d="M15.362 5.214A8.252 8.252 0 0 1 12 21 8.25 8.25 0 0 1 6.038 7.047 8.287 8.287 0 0 0 9 9.601a8.983 8.983 0 0 1 3.361-6.867 8.21 8.21 0 0 0 3 2.48Z"></path> |
| 14 | + <path stroke-linecap="round" stroke-linejoin="round" d="M12 18a3.75 3.75 0 0 0 .495-7.468 5.99 5.99 0 0 0-1.925 3.547 5.975 5.975 0 0 1-2.133-1.001A3.75 3.75 0 0 0 12 18Z"></path> |
| 15 | + </svg></span> |
| 16 | + <span>Maximum Coverage</span> |
| 17 | + </div> |
| 18 | + <div class="desc">Delivers the most complete support for modern and upcoming JavaScript features</div> |
| 19 | + </div> |
| 20 | + <div class="feature"> |
| 21 | + <div class="title"> |
| 22 | + <span class="icon"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> |
| 23 | + <path stroke-linecap="round" stroke-linejoin="round" d="M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"></path> |
| 24 | + </svg></span> |
| 25 | + <span>Spec Compliance</span> |
| 26 | + </div> |
| 27 | + <div class="desc">Strictly follows ECMAScript standards and fixes engine bugs for consistent behavior</div> |
| 28 | + </div> |
| 29 | + <div class="feature"> |
| 30 | + <div class="title"> |
| 31 | + <span class="icon"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> |
| 32 | + <path stroke-linecap="round" stroke-linejoin="round" d="M6.429 9.75 2.25 12l4.179 2.25m0-4.5 5.571 3 5.571-3m-11.142 0L2.25 7.5 12 2.25l9.75 5.25-4.179 2.25m0 0L21.75 12l-4.179 2.25m0 0 4.179 2.25L12 21.75 2.25 16.5l4.179-2.25m11.142 0-5.571 3-5.571-3"></path> |
| 33 | + </svg></span> |
| 34 | + <span>Modularity</span> |
| 35 | + </div> |
| 36 | + <div class="desc">Import only the polyfills you need for smaller bundles and faster loading</div> |
| 37 | + </div> |
| 38 | + <div class="feature"> |
| 39 | + <div class="title"> |
| 40 | + <span class="icon"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> |
| 41 | + <path stroke-linecap="round" stroke-linejoin="round" d="M11.42 15.17 17.25 21A2.652 2.652 0 0 0 21 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 1 1-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 0 0 4.486-6.336l-3.276 3.277a3.004 3.004 0 0 1-2.25-2.25l3.276-3.276a4.5 4.5 0 0 0-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437 1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008Z"></path> |
| 42 | + </svg></span> |
| 43 | + <span>Easy to Optimize</span> |
| 44 | + </div> |
| 45 | + <div class="desc">It can be automatically injected and optimized by tools like Babel and SWC</div> |
| 46 | + </div> |
| 47 | + <div class="feature"> |
| 48 | + <div class="title"> |
| 49 | + <span class="icon"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> |
| 50 | + <path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285Z"></path> |
| 51 | + </svg></span> |
| 52 | + <span>Pure Version</span> |
| 53 | + </div> |
| 54 | + <div class="desc">It can be used without global pollution to avoid conflicts</div> |
| 55 | + </div> |
| 56 | + <div class="feature"> |
| 57 | + <div class="title"> |
| 58 | + <span class="icon"><svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> |
| 59 | + <path stroke-linecap="round" stroke-linejoin="round" d="M16.5 18.75h-9m9 0a3 3 0 0 1 3 3h-15a3 3 0 0 1 3-3m9 0v-3.375c0-.621-.503-1.125-1.125-1.125h-.871M7.5 18.75v-3.375c0-.621.504-1.125 1.125-1.125h.872m5.007 0H9.497m5.007 0a7.454 7.454 0 0 1-.982-3.172M9.497 14.25a7.454 7.454 0 0 0 .981-3.172M5.25 4.236c-.982.143-1.954.317-2.916.52A6.003 6.003 0 0 0 7.73 9.728M5.25 4.236V4.5c0 2.108.966 3.99 2.48 5.228M5.25 4.236V2.721C7.456 2.41 9.71 2.25 12 2.25c2.291 0 4.545.16 6.75.47v1.516M7.73 9.728a6.726 6.726 0 0 0 2.748 1.35m8.272-6.842V4.5c0 2.108-.966 3.99-2.48 5.228m2.48-5.492a46.32 46.32 0 0 1 2.916.52 6.003 6.003 0 0 1-5.395 4.972m0 0a6.726 6.726 0 0 1-2.749 1.35m0 0a6.772 6.772 0 0 1-3.044 0"></path> |
| 60 | + </svg></span> |
| 61 | + <span>Widely Used</span> |
| 62 | + </div> |
| 63 | + <div class="desc">Trusted by most of the popular websites for ensuring cross-browser compatibility</div> |
| 64 | + </div> |
| 65 | +</div> |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +Example of usage: |
| 70 | + |
| 71 | +```js |
| 72 | +import 'core-js/actual'; |
| 73 | + |
| 74 | +await Promise.try(() => 42); // => 42 |
| 75 | + |
| 76 | +Array.from(new Set([1, 2, 3]).union(new Set([3, 4, 5]))); // => [1, 2, 3, 4, 5] |
| 77 | + |
| 78 | +[1, 2].flatMap(it => [it, it]); // => [1, 1, 2, 2] |
| 79 | + |
| 80 | +Iterator.concat([1, 2], function * (i) { while (true) yield i++; }(3)) |
| 81 | + .drop(1).take(5) |
| 82 | + .filter(it => it % 2) |
| 83 | + .map(it => it ** 2) |
| 84 | + .toArray(); // => [9, 25] |
| 85 | + |
| 86 | +structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) |
| 87 | +``` |
| 88 | + |
| 89 | +You can load only required features: |
| 90 | + |
| 91 | +```js |
| 92 | +import 'core-js/actual/promise'; |
| 93 | +import 'core-js/actual/set'; |
| 94 | +import 'core-js/actual/iterator'; |
| 95 | +import 'core-js/actual/array/from'; |
| 96 | +import 'core-js/actual/array/flat-map'; |
| 97 | +import 'core-js/actual/structured-clone'; |
| 98 | + |
| 99 | +await Promise.try(() => 42); // => 42 |
| 100 | + |
| 101 | +Array.from(new Set([1, 2, 3]).union(new Set([3, 4, 5]))); // => [1, 2, 3, 4, 5] |
| 102 | + |
| 103 | +[1, 2].flatMap(it => [it, it]); // => [1, 1, 2, 2] |
| 104 | + |
| 105 | +Iterator.concat([1, 2], function * (i) { while (true) yield i++; }(3)) |
| 106 | + .drop(1).take(5) |
| 107 | + .filter(it => it % 2) |
| 108 | + .map(it => it ** 2) |
| 109 | + .toArray(); // => [9, 25] |
| 110 | + |
| 111 | +structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) |
| 112 | +``` |
| 113 | + |
| 114 | +or use it without global namespace pollution: |
| 115 | + |
| 116 | +```ts |
| 117 | +import Promise from 'core-js-pure/actual/promise'; |
| 118 | +import Set from 'core-js-pure/actual/set'; |
| 119 | +import Iterator from 'core-js-pure/actual/iterator'; |
| 120 | +import from from 'core-js-pure/actual/array/from'; |
| 121 | +import flatMap from 'core-js-pure/actual/array/flat-map'; |
| 122 | +import structuredClone from 'core-js-pure/actual/structured-clone'; |
| 123 | + |
| 124 | +await Promise.try(() => 42); // => 42 |
| 125 | + |
| 126 | +from(new Set([1, 2, 3]).union(new Set([3, 4, 5]))); // => [1, 2, 3, 4, 5] |
| 127 | + |
| 128 | +flatMap([1, 2], it => [it, it]); // => [1, 1, 2, 2] |
| 129 | + |
| 130 | +Iterator.concat([1, 2], function * (i) { while (true) yield i++; }(3)) |
| 131 | + .drop(1).take(5) |
| 132 | + .filter(it => it % 2) |
| 133 | + .map(it => it ** 2) |
| 134 | + .toArray(); // => [9, 25] |
| 135 | + |
| 136 | +structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) |
| 137 | +``` |
| 138 | + |
| 139 | +## Raising funds |
| 140 | + |
| 141 | +`core-js` isn't backed by a company, so the future of this project depends on you. Become a sponsor or a backer if you are interested in `core-js`: [**Open Collective**](https://opencollective.com/core-js), [**Patreon**](https://patreon.com/zloirock), [**Boosty**](https://boosty.to/zloirock), **Bitcoin ( bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz )**, [**Alipay**](https://user-images.githubusercontent.com/2213682/219464783-c17ad329-17ce-4795-82a7-f609493345ed.png). |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +<div class="sponsors"> |
| 146 | + <a href="https://opencollective.com/core-js/sponsor/0/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/0/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/1/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/1/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/2/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/2/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/3/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/3/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/4/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/4/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/5/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/5/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/6/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/6/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/7/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/7/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/8/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/8/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/9/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/9/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/10/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/10/avatar.svg"></a><a href="https://opencollective.com/core-js/sponsor/11/website" target="_blank"><img src="https://opencollective.com/core-js/sponsor/11/avatar.svg"></a> |
| 147 | +</div> |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +<div align="center"> |
| 152 | + <details> |
| 153 | + <summary>More backers</summary> |
| 154 | + <a href="https://opencollective.com/core-js#backers" target="_blank"><img src="https://opencollective.com/core-js/backers.svg?width=890"></a> |
| 155 | + </details> |
| 156 | +</div> |
| 157 | + |
| 158 | +--- |
0 commit comments