Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
core-js-pure
Advanced tools
The core-js-pure package is a version of core-js that doesn't pollute the global namespace. It provides polyfills for ECMAScript features, including promises, symbols, collections, iterators, typed arrays, and many other features that are part of the ECMAScript specification but may not be available in all JavaScript environments.
Polyfilling Promises
This code sample demonstrates how to polyfill Promises using core-js-pure. It allows you to use Promises in environments where they are not natively supported.
import 'core-js-pure/stable/promise';
const promise = Promise.resolve(42);
promise.then(value => console.log(value));
Polyfilling Array methods
This code sample shows how to polyfill Array.prototype.find method. It enables the use of this method in environments where it is not part of the Array prototype.
import 'core-js-pure/stable/array/find';
const array = [1, 2, 3];
const found = array.find(item => item > 1);
console.log(found); // 2
Polyfilling Object static methods
This code sample illustrates how to polyfill Object.assign method. It allows the merging of multiple source objects into a target object in environments that do not support this method natively.
import 'core-js-pure/stable/object/assign';
const target = { a: 1 };
const source = { b: 2 };
const returnedTarget = Object.assign(target, source);
console.log(returnedTarget); // { a: 1, b: 2 }
Polyfilling String methods
This code sample demonstrates how to polyfill String.prototype.includes method. It provides a way to check if one string may be found within another string, returning true or false as appropriate.
import 'core-js-pure/stable/string/includes';
const string = 'hello world';
const includesHello = string.includes('hello');
console.log(includesHello); // true
Babel-polyfill is a package that includes core-js and a custom regenerator runtime to emulate a full ES2015+ environment. It's similar to core-js-pure but is more tightly coupled with Babel's transpilation process.
The es6-shim package provides polyfills for many new JavaScript features introduced in ES5 and ES6. It is similar to core-js-pure but does not offer as modular an approach, and it may include shims for features that are not strictly polyfills.
The polyfill-service (also known as polyfill.io) is a service that provides polyfills based on the user's browser user-agent. Unlike core-js-pure, it is a service rather than a package you include in your code, and it dynamically serves only the polyfills needed by the browser.
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].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 version without global namespace pollution (the third example), for more info see core-js
documentation.
.asIndexedPairs
renamed to .indexed
, proposal-iterator-helpers/183:
Iterator.prototype.asIndexedPairs
-> Iterator.prototype.indexed
AsyncIterator.prototype.asIndexedPairs
-> AsyncIterator.prototype.indexed
%AsyncFromSyncIteratorPrototype%
in AsyncIterator.from
and Iterator.prototype.toAsync
, proposal-iterator-helpers/182, proposal-iterator-helpers/202%WrapForValidAsyncIteratorPrototype%.next
, proposal-iterator-helpers/197%WrapForValid(Async)IteratorPrototype%.next
, proposal-iterator-helpers/197 and proposal-iterator-helpers/205.next
/ .return
to an underlying iterator by the extended iterator protocol, a part of proposal-iterator-helpers/194.throw
methods removed from all wrappers / helpers prototypes, a part of proposal-iterator-helpers/194{ Iterator, AsyncIterator }.prototype.flatMap
proxy iterators on .return
, proposal-iterator-helpers/195RangeError
on NaN
in { Iterator, AsyncIterator }.prototype.{ drop, take }
, proposal-iterator-helpers/181%TypedArray%.prototype.toSpliced
method removed from the change array by copy proposal and marked as obsolete in core-js
, proposal-change-array-by-copy/88Promise
with unhandledrejection
event support (browser style) in Deno < 1.24core-js-compat
/ core-js-builder
and added compat data for them:
FAQs
Standard library
The npm package core-js-pure receives a total of 11,130,302 weekly downloads. As such, core-js-pure popularity was classified as popular.
We found that core-js-pure demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.