npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@polyfiller/ecma-262

v0.0.39

Published

An implementation of the ECMAScript® Language Specification

Downloads

593

Readme

An implementation of the ECMAScript® Language Specification

Description

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.

Features

Disclaimer

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

Table of Contents

Install

npm

$ npm install @polyfiller/ecma-262

Yarn

$ yarn add @polyfiller/ecma-262

pnpm

$ 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.

Usage

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";

Maintainers

| | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Frederik WessbergTwitter: @FredWessbergGithub: @wessbergLead Developer |

Backers

| | | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | BubblesTwitter: @use_bubbles | Christopher Blanchard |

Patreon

FAQ

License

MIT © Frederik Wessberg (@FredWessberg) (Website)