ECMAScript6 WeakMap polyfill.
$ npm install --save weakmap-polyfill
Import or require
weakmap-polyfill, then WeakMap will be defined in the global scope if native WeakMap is not supported in running environment.
require('weakmap-polyfill'); var weakMap = new WeakMap();
import 'weakmap-polyfill'; const weakMap = new WeakMap();
<script src="weakmap-polyfill.min.js"></script> <script> var weakMap = new WeakMap(); </script>
This polyfill has following few limitations.
iterableargument is not supported. (184.108.40.206 WeakMap ( [ iterable ] ))
- Frozen and sealed objects are not supported.
- The values held by a WeakMap can't be collected once the map itself is GCed, since the values here are tied to the keys. #4