🎯A collection of polyfills that focuses on being ultra light-weight 🎯
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
import { Polyfill as Map, LightMap } from "minimal-polyfills/Map";
const map: LightMap<string, number>= new Map();
const map = new Map<string, number>();
Others data structures:
import { Polyfill as Set, LightSet } from "minimal-polyfills/Set";
import { Polyfill as WeakMap } from "minimal-polyfills/WeakMap";
Common missing features on older browsers:
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.
Run the example