TypeScript icon, indicating that this package has built-in type declarations

0.0.39 • Public • Published

An implementation of the ECMAScript® Language Specification

Downloads per month NPM version Dependencies Contributors code style: prettier License: MIT Support on Patreon

Powered by Polyfiller


This is a highly modularized, work-in-progress implementation of the ECMAScript® Language Specification that can be used as a polyfill. This library also exports an implementation of every Abstract Operation of the language that can be used as the foundation for other polyfills. It is optimized for spec-compliance and aims for as close to 100% conformance with Test262, the official ECMAScript test suite as possible.



This is a work in progress. Not every feature is yet fully implemented.

Table of Contents



$ npm install @polyfiller/ecma-262


$ yarn add @polyfiller/ecma-262


$ pnpm add @polyfiller/ecma-262

Applying the polyfills

Applying one or more polyfills is as easy as adding imports for them. Each polyfill will only be applied if the runtime doesn't already natively support the feature. Everything is exported as modules. For example, if you want to polyfill Symbol, here's how you might do that:

import "@polyfiller/ecma-262/polyfill/symbol";

You can get as granular as you want. For example, here's how to polyfill only Symbol.asyncIterator:

import "@polyfiller/ecma-262/polyfill/symbol.async-iterator";

However, it is generally a good idea that you only include the polyfill(s) for runtimes that doesn't already support the language features you want to support. One way to do so if with dynamic imports:

if (!("asyncIterator" in Symbol)) {
	await import("@polyfiller/ecma-262/polyfill/symbol.async-iterator");

If you want to polyfill the entire ECMAScript® Language, you can import it as such:

import "@polyfiller/ecma-262/polyfill";

However, if you want to simply patch whatever holes there might be in the runtimes JavaScript support, you are strongly encouraged to use Polyfill.app which uses this polyfill and takes care of only including the language features that are actually needed by the runtime. That approach will produce the most minimal overhead.


This is not just a polyfill. This is an implementation of the ECMAScript language, written in TypeScript, and as such this library exposes all the constructs found in the specification such as Abstract Operations and common algorithms. This might be useful to you, for example as the foundation for another polyfill.

To use it as a library, simply import what you want:

// Import some Abstract Operations
import {ToInt32, CreateDataProperty, GetMethod} from "@polyfiller/ecma-262";

You can also use this approach to import implementations of language features for testing or to use as a ponyfill:

import {arrayPrototypeFlat as flat} from "@polyfiller/ecma-262";
flat.call([[[1]]], Infinity);

Beyond that, you also have access to all Well-Known Intrinsic Objects, as well as the current Realm:

import {getCurrentRealmRecord, getCurrentIntrinsics} from "@polyfiller/ecma-262";


Frederik Wessberg
Frederik Wessberg
Twitter: @FredWessberg
Github: @wessberg
Lead Developer


Bubbles Christopher Blanchard
Twitter: @use_bubbles
Christopher Blanchard


Patrons on Patreon



MIT © Frederik Wessberg (@FredWessberg) (Website)

Package Sidebar


npm i @polyfiller/ecma-262

Weekly Downloads






Unpacked Size

18 MB

Total Files


Last publish


  • wessberg