@algolia/cache-browser-local-storage
Advanced tools
Comparing version 4.0.0-beta.11 to 4.0.0-beta.12
@@ -6,6 +6,4 @@ 'use strict'; | ||
function createBrowserLocalStorageCache(options) { | ||
/* eslint-disable functional/immutable-data */ | ||
const storage = options.localStorage || window.localStorage; | ||
const namespaceKey = `algoliasearch-client-js-${options.key}`; | ||
// eslint-disable-next-line functional/prefer-readonly-type | ||
const getNamespace = () => { | ||
@@ -32,2 +30,3 @@ return JSON.parse(storage.getItem(namespaceKey) || '{}'); | ||
const namespace = getNamespace(); | ||
// eslint-disable-next-line functional/immutable-data | ||
namespace[JSON.stringify(key)] = value; | ||
@@ -41,2 +40,3 @@ storage.setItem(namespaceKey, JSON.stringify(namespace)); | ||
const namespace = getNamespace(); | ||
// eslint-disable-next-line functional/immutable-data | ||
delete namespace[JSON.stringify(key)]; | ||
@@ -43,0 +43,0 @@ storage.setItem(namespaceKey, JSON.stringify(namespace)); |
import { Cache } from '@algolia/cache-common'; | ||
export declare type BrowserLocalStorageOptions = { | ||
/** | ||
* The cache key. | ||
*/ | ||
readonly key: string; | ||
/** | ||
* The native local storage implementation. | ||
*/ | ||
readonly localStorage?: Storage; | ||
readonly fallback?: Cache; | ||
}; | ||
@@ -8,0 +13,0 @@ |
function createBrowserLocalStorageCache(options) { | ||
/* eslint-disable functional/immutable-data */ | ||
const storage = options.localStorage || window.localStorage; | ||
const namespaceKey = `algoliasearch-client-js-${options.key}`; | ||
// eslint-disable-next-line functional/prefer-readonly-type | ||
const getNamespace = () => { | ||
@@ -27,2 +25,3 @@ return JSON.parse(storage.getItem(namespaceKey) || '{}'); | ||
const namespace = getNamespace(); | ||
// eslint-disable-next-line functional/immutable-data | ||
namespace[JSON.stringify(key)] = value; | ||
@@ -36,2 +35,3 @@ storage.setItem(namespaceKey, JSON.stringify(namespace)); | ||
const namespace = getNamespace(); | ||
// eslint-disable-next-line functional/immutable-data | ||
delete namespace[JSON.stringify(key)]; | ||
@@ -38,0 +38,0 @@ storage.setItem(namespaceKey, JSON.stringify(namespace)); |
{ | ||
"name": "@algolia/cache-browser-local-storage", | ||
"version": "4.0.0-beta.11", | ||
"version": "4.0.0-beta.12", | ||
"private": false, | ||
@@ -16,4 +16,4 @@ "description": "Promise-based cache library for browser using local storage.", | ||
"dependencies": { | ||
"@algolia/cache-common": "4.0.0-beta.11" | ||
"@algolia/cache-common": "4.0.0-beta.12" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4510
99
+ Added@algolia/cache-common@4.0.0-beta.12(transitive)
- Removed@algolia/cache-common@4.0.0-beta.11(transitive)