All files DictionaryIterator.ts

25% Statements 2/8
100% Branches 0/0
0% Functions 0/3
25% Lines 2/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 361x                     1x                                                
import {Iterator} from './Iterator';
 
export interface IDictionary {
    [key: string]: any;
}
 
export interface IDictionaryIteratorResult {
    key: string;
    value: any;
}
 
export class DictionaryIterator extends Iterator<string> {
    private dictionary: IDictionary;
 
    public constructor(dictionary: IDictionary, startingIndex?: number) {
        super(Object.keys(dictionary));
        this.dictionary = dictionary;
    }
 
    public next(): any {
        let key: any = super.next();
        return {
            key : key,
            value : this.dictionary[key]
        };
    }
 
    public previous(): any {
        let key: any = super.previous();
        return {
            key : key,
            value : this.dictionary[key]
        };
    }
}