core-js (original) (raw)
3.42.0 • Public • Published 4 days ago
Modular standard library for JavaScript. Includes polyfills for ECMAScript up to 2023: promises, symbols, collections, iterators, typed arrays, many other features, ECMAScript proposals, some cross-platform WHATWG / W3C features and proposals like URL. 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.
import 'core-js/actual';
Promise.resolve(42).then(it => console.log(it)); // => 42
Array.from(new Set([1, 2, 3]).union(new Set([3, 4, 5]))); // => [1, 2, 3, 4, 5]
[1, 2].flatMap(it => [it, it]); // => [1, 1, 2, 2]
(function * (i) { while (true) yield i++; })(1) .drop(1).take(5) .filter(it => it % 2) .map(it => it ** 2) .toArray(); // => [9, 25]
structuredClone(new Set([1, 2, 3])); // => new 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/from'; import 'core-js/actual/array/flat-map'; import 'core-js/actual/structured-clone';
Promise.resolve(42).then(it => console.log(it)); // => 42
Array.from(new Set([1, 2, 3]).union(new Set([3, 4, 5]))); // => [1, 2, 3, 4, 5]
[1, 2].flatMap(it => [it, it]); // => [1, 1, 2, 2]
(function * (i) { while (true) yield i++; })(1) .drop(1).take(5) .filter(it => it % 2) .map(it => it ** 2) .toArray(); // => [9, 25]
structuredClone(new Set([1, 2, 3])); // => new 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 from from 'core-js-pure/actual/array/from'; import flatMap from 'core-js-pure/actual/array/flat-map'; import structuredClone from 'core-js-pure/actual/structured-clone';
Promise.resolve(42).then(it => console.log(it)); // => 42
from(new Set([1, 2, 3]).union(new Set([3, 4, 5]))); // => [1, 2, 3, 4, 5]
flatMap([1, 2], it => [it, it]); // => [1, 1, 2, 2]
Iterator.from(function * (i) { while (true) yield i++; }(1)) .drop(1).take(5) .filter(it => it % 2) .map(it => it ** 2) .toArray(); // => [9, 25]
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
It's a global version (first 2 examples), for more info see core-js documentation.
Readme
Keywords
- ES3
- ES5
- ES6
- ES7
- ES2015
- ES2016
- ES2017
- ES2018
- ES2019
- ES2020
- ES2021
- ES2022
- ES2023
- ES2024
- [ECMAScript 3](/search?q=keywords:"ECMAScript 3")
- [ECMAScript 5](/search?q=keywords:"ECMAScript 5")
- [ECMAScript 6](/search?q=keywords:"ECMAScript 6")
- [ECMAScript 7](/search?q=keywords:"ECMAScript 7")
- [ECMAScript 2015](/search?q=keywords:"ECMAScript 2015")
- [ECMAScript 2016](/search?q=keywords:"ECMAScript 2016")
- [ECMAScript 2017](/search?q=keywords:"ECMAScript 2017")
- [ECMAScript 2018](/search?q=keywords:"ECMAScript 2018")
- [ECMAScript 2019](/search?q=keywords:"ECMAScript 2019")
- [ECMAScript 2020](/search?q=keywords:"ECMAScript 2020")
- [ECMAScript 2021](/search?q=keywords:"ECMAScript 2021")
- [ECMAScript 2022](/search?q=keywords:"ECMAScript 2022")
- [ECMAScript 2023](/search?q=keywords:"ECMAScript 2023")
- [ECMAScript 2024](/search?q=keywords:"ECMAScript 2024")
- Map
- Set
- WeakMap
- WeakSet
- TypedArray
- Promise
- Observable
- Symbol
- Iterator
- AsyncIterator
- URL
- URLSearchParams
- queueMicrotask
- setImmediate
- structuredClone
- polyfill
- ponyfill
- shim