8000 GitHub - zloirock/core-js: Standard Library · GitHub
[go: up one dir, main page]

Skip to content
zloirockPublic

Repository files navigation

logo

fundraising PRs welcome version core-js downloads core-js-pure downloads

I highly recommend reading this: So, what's next?

Modular standard library for JavaScript. Includes polyfills for ECMAScript up to 2026: promises, collections, iterators, explicit resource management, typed arrays, many other features, ECMAScript proposals, some cross-platform WHATWG / W3C features like URL and structuredClone. You can load only required features or use it without global namespace pollution.

Raising funds

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, Patreon, Boosty, Bitcoin ( bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz ), Alipay.




Example of usage:

import 'core-js/actual';

await Promise.try(() => 42); // => 42

new Set([1, 2, 3]).union(new Set([3, 4, 5])); // => Set { 1, 2, 3, 4, 5 }

[3, 1, 2].toSorted(); // => [1, 2, 3]

Math.sumPrecise([1e20, 0.1, -1e20]); // => 0.1

Iterator.concat([1, 2], function * (i) { while (true) yield i++; }(3))
  .drop(1).take(5)
  .filter(it => it % 2)
  .map(it => it ** 2)
  .toArray(); // => [9, 25]

structuredClone(new Set([1, 2, 3])); // => Set { 1, 2, 3 }

You can load only required features:

import 'core-js/actual/promise';
import 'core-js/actual/set';
import 'core-js/actual/iterator';
import 'core-js/actual/array/to-sorted';
import 'core-js/actual/math/sum-precise';
import 'core-js/actual/structured-clone';

await Promise.try(() => 42); // => 42

new Set([1, 2, 3]).union(new Set([3, 4, 5])); // => Set { 1, 2, 3, 4, 5 }

[3, 1, 2].toSorted(); // => [1, 2, 3]

Math.sumPrecise([1e20, 0.1, -1e20]); // => 0.1

Iterator.concat([1, 2], function * (i) { while (true) yield i++; }(3))
  .drop(1).take(5)
  .filter(it => it % 2)
  .map(it => it ** 2)
  .toArray(); // => [9, 25]

structuredClone(new Set([1, 2, 3])); // => Set { 1, 2, 3 }

Or use it without global namespace pollution:

import Promise from 'core-js-pure/actual/promise';
import Set from 'core-js-pure/actual/set';
import Iterator from 'core-js-pure/actual/iterator';
import toSorted from 'core-js-pure/actual/array/to-sorted';
import sumPrecise from 'core-js-pure/actual/math/sum-precise';
import structuredClone from 'core-js-pure/actual/structured-clone';

await Promise.try(() => 42); // => 42

new Set([1, 2, 3]).union(new Set([3, 4, 5])); // => Set { 1, 2, 3, 4, 5 }

toSorted([3, 1, 2]); // => [1, 2, 3]

sumPrecise([1e20, 0.1, -1e20]); // => 0.1

Iterator.concat([1, 2], function * (i) { while (true) yield i++; }(3))
  .drop(1).take(5)
  .filter(it => it % 2)
  .map(it => it ** 2)
  .toArray(); // => [9, 25]

structuredClone(new Set([1, 2, 3])); // => Set { 1, 2, 3 }

Installation

# global version
npm install core-js@3.51.0
# version without global namespace pollution
npm install core-js-pure@3.51.0
# bundled global version
npm install core-js-bundle@3.51.0

Documentation

The documentation is available on core-js.io:

  • Usage - installation, entry points, usage with Babel and swc, custom build
  • Features - the catalog of our polyfills
  • Engines - supported engines and compatibility data

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

0