# minimal-polyfills

> An ultra light-weight, nonexhaustive, polyfills library

Latest version **2.2.3** (published 2023-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install minimal-polyfills
pnpm add minimal-polyfills
yarn add minimal-polyfills
bun add minimal-polyfills
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.2.3 |
| Published | 2023-05-21 |
| First published | 2020-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 37.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Joseph Garrone |
| Maintainers | garronej |
| Keywords | polyfills, light-weight, nonexhaustive, Map, Set, WeakMap, typescript, Array.prototype.find, Array.prototype.from, Array.prototype.isView, String.prototype.startsWith |

## Links

- npm: https://www.npmjs.com/package/minimal-polyfills
- Repository: https://github.com/garronej/minimal_polyfills
- Homepage: https://github.com/garronej/minimal_polyfills#readme
- Issues: https://github.com/garronej/minimal_polyfills/issues
- npm.io page: https://npm.io/package/minimal-polyfills

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 2.2.3 (latest) — 2023-05-21
- 2.2.2 — 2022-08-25
- 2.2.1 — 2021-05-26
- 2.2.0 — 2021-05-26
- 2.1.6 — 2020-12-14
- 2.1.5 — 2020-08-27
- 2.1.4 — 2020-08-10
- 2.1.3 — 2020-07-19
- 2.1.2 — 2020-05-25
- 2.1.1 — 2020-05-25
- 2.1.0 — 2020-05-23
- 2.0.1 — 2020-05-21
- 2.0.0 — 2020-05-21
- 1.0.8 — 2020-04-16
- 1.0.7 — 2020-04-14
- … 7 more at https://npm.io/package/minimal-polyfills/versions

## README

<p align="center">
    <img src="https://user-images.githubusercontent.com/6702424/74083910-7305c180-4a69-11ea-9595-331c7976c292.png">  
</p>
<p align="center">
    <i> 🎯A collection of polyfills that focuses on being ultra light-weight 🎯 </i>
    <br>
    <br>
    <img src="https://github.com/garronej/minimal_polyfills/workflows/ci/badge.svg?branch=develop">
    <img src="https://img.shields.io/bundlephobia/minzip/minimal-polyfills">
    <img src="https://img.shields.io/npm/l/minimal-polyfills">
</p>

---

Set of polyfills for ``Map``, ``Set``, ``WeakMap`` and other standard functions that could be missing in some legacy runtime environnement.
Focus is placed on bundle size rather than performance and transparency.  
The goal is to allow our code to run on older browsers without significantly increasing the bundle size by adding exhaustive polyfills that in 95% of the cases won't be necessary.  
The classes exposed only implement the more common features of their native counterpart, it does so in a very naïve and inefficient way to keep the code as short as possible.
As you would expect the polyfills will only be used when the native classes are missing.

# Usage

## Example with Map

```typescript
//Example with map.
import { Polyfill as Map, LightMap } from "minimal-polyfills/Map";

// Explicitly define the type of your variable to make it clear
// that you are using a subset of Map...
const map: LightMap<string, number>= new Map();
//...or let the type be inferred.
const map = new Map<string, number>();
```

![Screenshot 2020-02-08 at 10 45 06](https://user-images.githubusercontent.com/6702424/82556081-564d4f80-9b69-11ea-9b62-46eaa910a2e3.png)
![Screenshot 2020-02-08 at 10 46 34](https://user-images.githubusercontent.com/6702424/82556246-a5938000-9b69-11ea-8b3f-6a6036288ba1.png)

## Others data structures: 

```typescript
import { Polyfill as Set, LightSet } from "minimal-polyfills/Set";
//WARNING: If not natively supported WeakMap will only be a simple Map that will keep string references of it's keys.
import { Polyfill as WeakMap } from "minimal-polyfills/WeakMap";
import { Polyfill as WeakSet } from "minimal-polyfills/WeakSet";
```

## Common missing features on older browsers:

```typescript
import "minimal-polyfills/Array.prototype.find";
import "minimal-polyfills/String.prototype.startsWith.ts";
import "minimal-polyfills/Array.from.ts";
import "minimal-polyfills/ArrayBuffer.isView.ts";
import "minimal-polyfills/Object.fromEntries";
import "minimal-polyfills/Object.is.ts";
import "minimal-polyfills/Object.assign.ts";
```

# Try it now

Thanks to Stackblitz you can try this lib with within your browser like if you where in VSCode. 

<p align="center">
    <img src="https://user-images.githubusercontent.com/6702424/82556457-0622bd00-9b6a-11ea-8056-5a9c31a4ba39.png">  
</p>

[__Run the example__](https://stackblitz.com/edit/minimal-polyfills-demo?embed=1&file=index.ts)

---
_Source: https://npm.io/package/minimal-polyfills · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
