Provides support for ES6
Map
, Set
, WeakMap
and WeakSet
in ES5
for older JS environments i.e. older browsers or NodeJS
.
require("symbol-es6");
require("collections-es6");
If you prefer CDN, then just insert it into your HTML page on the top of other scripts:
"use strict";
Â
var ES6 = require("symbol-es6");
ES6Â =Â require("collections-es6");
Â
Â
var map = new Map([[1, 2], ["Hi", "Hello World"]]);
Â
console.log(map.has(1));Â
console.log(map.has("Hi"));Â
Â
map.set(NaN, "NaN");
map.set(NaN, "Again NaN!");
map.set(0, "Zero");
map.set(-0, "Again Zero!");
Â
console.log(map.size);Â
console.log(map.has(NaN));Â
console.log(map.size);Â
console.log(map.has(0));Â
console.log(map.has(-0));Â
Â
var set = new Set([NaN, 0, -0, "Hi", "Hello World"]);
set.add(Infinity);
Â
console.log(set.has(NaN));Â
console.log(set.has("Hi"));Â
console.log(set.size);Â
console.log(set.has(Infinity));Â
console.log(set.has(-Infinity));Â
Â
var wm = new WeakMap();
wm.set(Object, "object");
wm.set(Function, "function");
wm.set({}, "new Object");
Â
console.log(wm.has(Object));Â
console.log(wm.has({}));Â
Â
var ws = new WeakSet();
ws.add(Function);
ws.add({});
Â
console.log(ws.has({}));Â
console.log(ws.has(Function));Â
Â
console.log(ES6.isMap(map));Â
console.log(ES6.isSet(set));Â
console.log(ES6.isWeakMap(wm));Â
console.log(ES6.isWeakSet(ws));Â
Your PRs and stars are always welcome.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4