An implementation analogous to the Map specification in ES2015, with the exception of iterators. The entries, keys, and values methods are omitted, since forEach essentially provides the same functionality.
import { Map } from 'src/Map';
var map = new Map();
import { Map } from 'src/Map';
var map = new Map([
['age', 2],
['height', 1.5]
]);
import { Map } from 'src/Map';
var map = new Map([
['age', 2],
['height', 1.5]
]);
var key = 'weight';
var value = 14;
map.set(key, value);
import { Map } from 'src/Map';
var map = new Map([
['age', 2],
['height', 1.5]
]);
map.size() === 2; // true
import { Map } from 'src/Map';
var map = new Map([
['age', 2],
['height', 1.5]
]);
map.clear();
map.size() === 0; // true
import { Map } from 'src/Map';
var map = new Map([
['age', 2],
['height', 1.5]
]);
var key = 'age';
map.delete(key);
map.size() === 1; // true
import { Map } from 'src/Map';
var map = new Map([
['age', 2],
['height', 1.5]
]);
map.forEach((value, key, map) -> {
console.log('key: ' + key + ' value: ' + value);
});
import { Map } from 'src/Map';
var map = new Map([
['age', 2],
['height', 1.5]
]);
var key = 'age';
map.get(key) === 2; // true
import { Map } from 'src/Map';
var map = new Map([
['age', 2],
['height', 1.5]
]);
map.has('age'); // true
map.has('weight'); // false