StringArrayStorage.ts 926 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { injectable } from 'inversify';
  2. import { ArrayStorage } from '../ArrayStorage';
  3. import { RandomGeneratorUtils } from '../../utils/RandomGeneratorUtils';
  4. import { Utils } from '../../utils/Utils';
  5. @injectable()
  6. export class StringArrayStorage extends ArrayStorage <string> {
  7. constructor () {
  8. super();
  9. this.initialize();
  10. }
  11. /**
  12. * @param args
  13. */
  14. public initialize (...args: any[]): void {
  15. super.initialize(args);
  16. this.storageId = RandomGeneratorUtils.getRandomVariableName(4, false);
  17. }
  18. /**
  19. * @param rotationValue
  20. */
  21. public rotateArray (rotationValue: number): void {
  22. this.storage = Utils.arrayRotate(this.storage, rotationValue);
  23. }
  24. /**
  25. * @returns {string}
  26. */
  27. public toString (): string {
  28. return this.storage.map((value: string) => {
  29. return `'${value}'`;
  30. }).toString();
  31. }
  32. }