You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 regels
457 B

  1. export class LocalStorageMock {
  2. constructor(storage = {}) {
  3. this.storage = storage;
  4. }
  5. setItem(key, value) {
  6. this.storage[key] = value || '';
  7. }
  8. getItem(key) {
  9. return this.storage[key] || null;
  10. }
  11. removeItem(key) {
  12. delete this.storage[key];
  13. }
  14. key(i) {
  15. const keys = Object.keys(this.storage);
  16. return keys[i] || null;
  17. }
  18. clear() {
  19. this.storage = {};
  20. }
  21. }