SmugMug Map

An ordered hash map data structure with an interface and behavior similar to (but not exactly the same as) ECMAScript 6 Maps.

Features

Useful Links

Example

Note: gallery-sm-map isn't yet available on the Y! CDN, but feel free to grab it from this git repo!

Run this example!

YUI().use('gallery-sm-map', function (Y) {
    var map = new Y.Map();

    // String keys are super efficient.
    map.set('foo', 'bar');
    console.log(map.get('foo')); // => 'bar'

    // ...but object keys can be super convenient.
    var object = {};
    map.set(object, 'my key is an object!');
    console.log(map.get(object)); // => 'my key is an object!'

    // Even NaN can be a key!
    map.set(NaN, 'my key is not a number!');
    console.log(map.get(NaN)); // => 'my key is not a number!'

    // Iteration is easy.
    map.each(function (value, key) {
        // ...
    });
});

Differences from ES6 Maps