mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-03 20:17:59 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			698 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			698 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/**
 | 
						|
 * Copyright (c) HashiCorp, Inc.
 | 
						|
 * SPDX-License-Identifier: MPL-2.0
 | 
						|
 */
 | 
						|
 | 
						|
export default {
 | 
						|
  getItem(key) {
 | 
						|
    var item = window.localStorage.getItem(key);
 | 
						|
    return item && JSON.parse(item);
 | 
						|
  },
 | 
						|
 | 
						|
  setItem(key, val) {
 | 
						|
    window.localStorage.setItem(key, JSON.stringify(val));
 | 
						|
  },
 | 
						|
 | 
						|
  removeItem(key) {
 | 
						|
    return window.localStorage.removeItem(key);
 | 
						|
  },
 | 
						|
 | 
						|
  keys() {
 | 
						|
    return Object.keys(window.localStorage);
 | 
						|
  },
 | 
						|
 | 
						|
  cleanUpStorage(string, keyToKeep) {
 | 
						|
    if (!string) return;
 | 
						|
    const relevantKeys = this.keys().filter((str) => str.startsWith(string));
 | 
						|
    relevantKeys?.forEach((key) => {
 | 
						|
      if (key !== keyToKeep) {
 | 
						|
        localStorage.removeItem(key);
 | 
						|
      }
 | 
						|
    });
 | 
						|
  },
 | 
						|
};
 |