peach a19a732be8 commit message | 2 yıl önce | |
---|---|---|
.. | ||
actual | 2 yıl önce | |
es | 2 yıl önce | |
features | 2 yıl önce | |
full | 2 yıl önce | |
internals | 2 yıl önce | |
modules | 2 yıl önce | |
proposals | 2 yıl önce | |
stable | 2 yıl önce | |
stage | 2 yıl önce | |
web | 2 yıl önce | |
LICENSE | 2 yıl önce | |
README.md | 2 yıl önce | |
configurator.js | 2 yıl önce | |
index.js | 2 yıl önce | |
package.json | 2 yıl önce | |
postinstall.js | 2 yıl önce |
Modular standard library for JavaScript. Includes polyfills for ECMAScript up to 2021: 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.
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, Bitcoin ( bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz ).
import 'core-js/actual'; // <- at the top of your entry point
Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4, 5].groupBy(it => it % 2); // => { 1: [1, 3, 5], 0: [2, 4] }
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
You can load only required features:
import 'core-js/actual/array/from'; // <- at the top of your entry point
import 'core-js/actual/array/group-by'; // <- at the top of your entry point
import 'core-js/actual/set'; // <- at the top of your entry point
import 'core-js/actual/promise'; // <- at the top of your entry point
import 'core-js/actual/structured-clone'; // <- at the top of your entry point
import 'core-js/actual/queue-microtask'; // <- at the top of your entry point
Array.from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
[1, 2, 3, 4, 5].groupBy(it => it % 2); // => { 1: [1, 3, 5], 0: [2, 4] }
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
Or use it without global namespace pollution:
import from from 'core-js-pure/actual/array/from';
import groupBy from 'core-js-pure/actual/array/group-by';
import Set from 'core-js-pure/actual/set';
import Promise from 'core-js-pure/actual/promise';
import structuredClone from 'core-js-pure/actual/structured-clone';
import queueMicrotask from 'core-js-pure/actual/queue-microtask';
from(new Set([1, 2, 3, 2, 1])); // => [1, 2, 3]
groupBy([1, 2, 3, 4, 5], it => it % 2); // => { 1: [1, 3, 5], 0: [2, 4] }
Promise.resolve(42).then(x => console.log(x)); // => 42
structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
queueMicrotask(() => console.log('called as microtask'));
It's a global version (first 2 examples), for more info see core-js
documentation.