All files / src/storages/string-array StringArrayStorage.ts

93.75% Statements 15/16
50% Branches 1/2
100% Functions 2/2
92.31% Lines 12/13
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 36 37 38 39 401x   1x 1x 1x     1x   6265x   6265x             6265x   6265x             728x             728x 10294x        
import { injectable } from 'inversify';
 
import { ArrayStorage } from '../ArrayStorage';
import { RandomGeneratorUtils } from '../../utils/RandomGeneratorUtils';
import { Utils } from '../../utils/Utils';
 
@injectable()
export class StringArrayStorage extends ArrayStorage <string> {
    constructor () {
        super();
 
        this.initialize();
    }
 
    /**
     * @param args
     */
    public initialize (...args: any[]): void {
        super.initialize(args);
 
        this.storageId = RandomGeneratorUtils.getRandomString(4, RandomGeneratorUtils.randomGeneratorPoolHexadecimal);
    }
 
    /**
     * @param rotationValue
     */
    public rotateArray (rotationValue: number): void {
        this.storage = Utils.arrayRotate(this.storage, rotationValue);
    }
 
    /**
     * @returns {string}
     */
    public toString (): string {
        return this.storage.map((value: string) => {
            return `'${value}'`;
        }).toString();
    }
}