assets/mapshim.js
// Keep the class inside a function so it doesn't get compiled if it's not used.
Keep the class inside a function so it doesn't get compiled if it's not used.
Keep the class inside a function so it doesn ' t get compiled if it ' s not used .
function shimMap() {
    var MapIterator =  (function () {
        function MapIterator(currentEntry, selector) {
            this.currentEntry = currentEntry;
            this.selector = selector;
        }
        MapIterator.prototype.next = function () {
            while (this.currentEntry) {
                var skipNext = !!this.currentEntry.skipNext;
                this.currentEntry = this.currentEntry.nextEntry;
                if (!skipNext) {
                    break;
                }
            }
            if (this.currentEntry) {
                return { value: this.selector(this.currentEntry.key, this.currentEntry.value), done: false };
            }
            else {
                return { value: undefined, done: true };
            }
        };
        return MapIterator;
    }());
    return  (function () {
        function class_1() {
            this.data = createDictionaryObject();
            this.size = 0;
            this.firstEntry = {};
            this.lastEntry = this.firstEntry;
        }
        class_1.prototype.get = function (key) {
            var entry = this.data[key];
            return entry && entry.value;
        };
        class_1.prototype.set = function (key, value) {
            if (!this.has(key)) {
                this.size++;
                var newEntry = {
                    key: key,
                    value: value
                };
                this.data[key] = newEntry;
                var previousLastEntry = this.lastEntry;
                previousLastEntry.nextEntry = newEntry;
                newEntry.previousEntry = previousLastEntry;
                this.lastEntry = newEntry;
            }
            else {
                this.data[key].value = value;
            }
            return this;
        };
        class_1.prototype.has = function (key) {
            return key in this.data;
        };
        class_1.prototype.delete = function (key) {
            if (this.has(key)) {
                this.size--;
                var entry = this.data[key];
                delete this.data[key];
                var previousEntry = entry.previousEntry;
                previousEntry.nextEntry = entry.nextEntry;
                if (entry.nextEntry) {
                    entry.nextEntry.previousEntry = previousEntry;
                }
                if (this.lastEntry === entry) {
                    this.lastEntry = previousEntry;
                }
                entry.previousEntry = undefined;
                entry.nextEntry = previousEntry;
                entry.skipNext = true;
                return true;
            }
            return false;
        };
        class_1.prototype.clear = function () {
            this.data = createDictionaryObject();
            this.size = 0;
            var firstEntry = this.firstEntry;
            var currentEntry = firstEntry.nextEntry;
            while (currentEntry) {
                var nextEntry = currentEntry.nextEntry;
                currentEntry.previousEntry = undefined;
                currentEntry.nextEntry = firstEntry;
                currentEntry.skipNext = true;
                currentEntry = nextEntry;
            }
            firstEntry.nextEntry = undefined;
            this.lastEntry = firstEntry;
        };
        class_1.prototype.keys = function () {
            return new MapIterator(this.firstEntry, function (key) { return key; });
        };
        class_1.prototype.values = function () {
            return new MapIterator(this.firstEntry, function (_key, value) { return value; });
        };
        class_1.prototype.entries = function () {
            return new MapIterator(this.firstEntry, function (key, value) { return [key, value]; });
        };
        class_1.prototype.forEach = function (action) {
            var iterator = this.entries();
            while (true) {
                var iterResult = iterator.next();
                if (iterResult.done) {
                    break;
                }
                var _a = iterResult.value, key = _a[0], value = _a[1];
                action(value, key);
            }
        };
        return class_1;
    }());
}
function shimMap ( ) { var MapIterator = ( function ( ) { function MapIterator ( currentEntry , selector ) { this . currentEntry = currentEntry ; this . selector = selector ; } MapIterator . prototype . next = function ( ) { while ( this . currentEntry ) { var skipNext = ! ! this . currentEntry . skipNext ; this . currentEntry = this . currentEntry . nextEntry ; if ( ! skipNext ) { break ; } } if ( this . currentEntry ) { return { value : this . selector ( this . currentEntry . key , this . currentEntry . value ) , done : false } ; } else { return { value : undefined , done : true } ; } } ; return MapIterator ; } ( ) ) ; return ( function ( ) { function class_1 ( ) { this . data = createDictionaryObject ( ) ; this . size = 0 ; this . firstEntry = { } ; this . lastEntry = this . firstEntry ; } class_1 . prototype . get = function ( key ) { var entry = this . data [ key ] ; return entry && entry . value ; } ; class_1 . prototype . set = function ( key , value ) { if ( ! this . has ( key ) ) { this . size ++ ; var newEntry = { key : key , value : value } ; this . data [ key ] = newEntry ; var previousLastEntry = this . lastEntry ; previousLastEntry . nextEntry = newEntry ; newEntry . previousEntry = previousLastEntry ; this . lastEntry = newEntry ; } else { this . data [ key ] . value = value ; } return this ; } ; class_1 . prototype . has = function ( key ) { return key in this . data ; } ; class_1 . prototype . delete = function ( key ) { if ( this . has ( key ) ) { this . size -- ; var entry = this . data [ key ] ; delete this . data [ key ] ; var previousEntry = entry . previousEntry ; previousEntry . nextEntry = entry . nextEntry ; if ( entry . nextEntry ) { entry . nextEntry . previousEntry = previousEntry ; } if ( this . lastEntry === entry ) { this . lastEntry = previousEntry ; } entry . previousEntry = undefined ; entry . nextEntry = previousEntry ; entry . skipNext = true ; return true ; } return false ; } ; class_1 . prototype . clear = function ( ) { this . data = createDictionaryObject ( ) ; this . size = 0 ; var firstEntry = this . firstEntry ; var currentEntry = firstEntry . nextEntry ; while ( currentEntry ) { var nextEntry = currentEntry . nextEntry ; currentEntry . previousEntry = undefined ; currentEntry . nextEntry = firstEntry ; currentEntry . skipNext = true ; currentEntry = nextEntry ; } firstEntry . nextEntry = undefined ; this . lastEntry = firstEntry ; } ; class_1 . prototype . keys = function ( ) { return new MapIterator ( this . firstEntry , function ( key ) { return key ; } ) ; } ; class_1 . prototype . values = function ( ) { return new MapIterator ( this . firstEntry , function ( _key , value ) { return value ; } ) ; } ; class_1 . prototype . entries = function ( ) { return new MapIterator ( this . firstEntry , function ( key , value ) { return [ key , value ] ; } ) ; } ; class_1 . prototype . forEach = function ( action ) { var iterator = this . entries ( ) ; while ( true ) { var iterResult = iterator . next ( ) ; if ( iterResult . done ) { break ; } var _a = iterResult . value , key = _a [ 0 ] , value = _a [ 1 ] ; action ( value , key ) ; } } ; return class_1 ; } ( ) ) ; }
Keep the class inside a function so it doesn't get compiled if it's not used.
Keep the class inside a function so it doesn ' t get compiled if it ' s not used .
/** @class */ // Navigate to the next entry. /** @class */ // Create a first (stub) map entry that will not contain a key // and value but serves as starting point for iterators. // When the map is empty, the last entry is the same as the // first one. // Create a new entry that will be appended at the // end of the linked list. // Adjust the references. // tslint:disable-next-line:no-in-operator // Adjust the linked list references of the neighbor entries. // When the deleted entry was the last one, we need to // adjust the lastEntry reference. // Adjust the forward reference of the deleted entry // in case an iterator still references it. This allows us // to throw away the entry, but when an active iterator // (which points to the current entry) continues, it will // navigate to the entry that originally came before the // current one and skip it. // Reset the linked list. Note that we must adjust the forward // references of the deleted entries to ensure iterators stuck // in the middle of the list don't continue with deleted entries, // but can continue with new entries added after the clear() // operation.