mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 18:08:11 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
		
			631 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			631 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| class LocalStorageMock {
 | |
|   constructor() {
 | |
|     this.store = new Map();
 | |
|   }
 | |
| 
 | |
|   clear() {
 | |
|     this.store.clear();
 | |
|   }
 | |
| 
 | |
|   getItem(key) {
 | |
|     /**
 | |
|      * We return null to avoid returning `undefined`
 | |
|      * because `undefined` is not a valid JSON value.
 | |
|      */
 | |
|     return this.store.get(key) ?? null;
 | |
|   }
 | |
| 
 | |
|   setItem(key, value) {
 | |
|     this.store.set(key, String(value));
 | |
|   }
 | |
| 
 | |
|   removeItem(key) {
 | |
|     this.store.delete(key);
 | |
|   }
 | |
| 
 | |
|   get length() {
 | |
|     return this.store.size;
 | |
|   }
 | |
| }
 | |
| 
 | |
| // eslint-disable-next-line no-undef
 | |
| Object.defineProperty(window, 'localStorage', {
 | |
|   writable: true,
 | |
|   value: new LocalStorageMock(),
 | |
| });
 | 
