Socket
Socket
Sign inDemoInstall

core-js

Package Overview
Dependencies
0
Maintainers
1
Versions
272
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    core-js

Standard library


Version published
Weekly downloads
28M
decreased by-17.78%
Maintainers
1
Install size
0.975 MB
Created
Weekly downloads
 

Package description

What is core-js?

The core-js npm package is a modular standard library for JavaScript, which includes polyfills for ECMAScript features. It provides reliable polyfills to ensure that code behaves consistently across different environments, including older browsers.

What are core-js's main functionalities?

Polyfilling ECMAScript features

This feature allows developers to use the latest ECMAScript features while ensuring backward compatibility with older environments that do not support these features natively.

require('core-js/stable');
// Now you can use ES6 features like Promise in environments that do not support them natively.

Polyfilling Web Standards

Core-js can also polyfill web standards, allowing developers to use modern web APIs in environments that have not implemented them.

require('core-js/web');
// This includes polyfills for web standards like DOM collections (e.g., NodeList), timers, and more.

Polyfilling Proposals

Developers can experiment with proposed ECMAScript features before they are finalized and adopted into the standard, ensuring forward compatibility.

require('core-js/proposals');
// This will include polyfills for ECMAScript proposals that are not yet part of the standard.

Other packages similar to core-js

Changelog

Source

3.25.1 - 2022.09.08

  • Added some fixes and workarounds of FF30- typed arrays bug that does not properly convert objects to numbers
  • Added sideEffects field to core-js-pure package.json for better tree shaking, #1117
  • Dropped semver dependency from core-js-compat
    • semver package (ironically) added a breaking change and dropped NodeJS 8 support in the minor 7.1 version, after that semver in core-js-compat was pinned to 7.0 since for avoiding breaking changes it should support NodeJS 8. However, since core-js-compat is usually used with other packages that use semver dependency, it causes multiple duplication of semver in dependencies. So I decided to remove semver dependency and replace it with a couple of simple helpers.
  • Added Bun 0.1.6-0.1.11 compat data
  • Added Deno 1.25 compat data mapping
  • Updated Electron 21 compat data mapping
  • Some stylistic changes, minor fixes, and improvements

Readme

Source

logo

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

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.

As advertising: the author is looking for a good job -)

core-js@3, babel and a look into the future

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




Example of usage:

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].group(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';      // <- 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].group(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 group from 'core-js-pure/actual/array/group';
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]
group([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.

Keywords

FAQs

Last updated on 07 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc