Every line of 'store array in localstorage' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
23 export function store(key: string, value: any) { 24 const bak = context.getItem(key); 25 context.setItem(key, JSON.stringify(value)); 26 return bak; 27 }
129 setLocal(key: string, value: string) { 130 if (this._supportsLocal) { 131 localStorage.setItem(key, value); 132 } 133 }
54 function store(storage, key, value) { 55 if (!storage) { throw new Error("Storage object is undefined"); } 56 57 // get 58 if (value === undefined) { 59 var item = storage.getItem(key); 60 return item && JSON.parse(item); 61 // set 62 } else { 63 try { 64 storage.setItem(key, JSON.stringify(value)); 65 } catch (err) { 66 // prevent catching old values 67 storage.removeItem(key); 68 } 69 } 70 }
2 export function store(key: string, value: string): void { 3 try { 4 if (window.localStorage) { 5 window.localStorage.setItem(key, value); 6 } 7 } 8 catch (ex) { 9 } 10 }
271 function store(name, val) { 272 if (typeof (Storage) !== 'undefined') { 273 localStorage.setItem(name, val) 274 } else { 275 window 276 .alert('Please use a modern browser to properly view this template!') 277 } 278 }
96 _saveLocalStorage(data: any) { 97 store.set(LOCAL_STORAGE_NAME, data); 98 }
69 saveObject(key, value) { 70 this.db.insert(this.prefix + key, JSON.stringify(value)); 71 }
21 function store(key, value, persist) { 22 if ($.exists(value) && $.isObject(value)) { 23 value = "!!stringified!!" + JSON.stringify(value); 24 } 25 26 if (persist) { 27 localStorage.setItem(key,value); 28 } else { 29 sessionStorage.setItem(key, value); 30 31 if ($.exists(localStorage.getItem(key))) { 32 localStorage.removeItem(key); 33 } 34 } 35 }
112 saveToLocalStorage(key, value) { 113 localStorage.setItem(key, JSON.stringify(value)); 114 }
21 public setLocalObject(key: string, obj: any): boolean { 22 return this.setObject(this.localStorage, key, obj); 23 }