@algolia/cache-in-memory
Advanced tools
Comparing version 4.0.0-beta.8 to 4.0.0-beta.9
@@ -5,3 +5,3 @@ 'use strict'; | ||
function createInMemoryCache() { | ||
function createInMemoryCache(options = { serializable: true }) { | ||
/* eslint-disable functional/immutable-data, functional/no-let, functional/prefer-readonly-type */ | ||
@@ -15,3 +15,3 @@ let cache = {}; | ||
if (keyAsString in cache) { | ||
return Promise.resolve(Object.assign({}, cache[keyAsString])); | ||
return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]); | ||
} | ||
@@ -23,3 +23,3 @@ const promise = defaultValue(); | ||
set(key, value) { | ||
cache[JSON.stringify(key)] = value; | ||
cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value; | ||
return Promise.resolve(value); | ||
@@ -26,0 +26,0 @@ }, |
import { Cache } from '@algolia/cache-common'; | ||
export declare function createInMemoryCache(): Cache; | ||
export declare function createInMemoryCache(options?: InMemoryCacheOptions): Cache; | ||
export declare type InMemoryCacheOptions = { | ||
readonly serializable?: boolean; | ||
}; | ||
export { } |
@@ -1,2 +0,2 @@ | ||
function createInMemoryCache() { | ||
function createInMemoryCache(options = { serializable: true }) { | ||
/* eslint-disable functional/immutable-data, functional/no-let, functional/prefer-readonly-type */ | ||
@@ -10,3 +10,3 @@ let cache = {}; | ||
if (keyAsString in cache) { | ||
return Promise.resolve(Object.assign({}, cache[keyAsString])); | ||
return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]); | ||
} | ||
@@ -18,3 +18,3 @@ const promise = defaultValue(); | ||
set(key, value) { | ||
cache[JSON.stringify(key)] = value; | ||
cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value; | ||
return Promise.resolve(value); | ||
@@ -21,0 +21,0 @@ }, |
{ | ||
"name": "@algolia/cache-in-memory", | ||
"version": "4.0.0-beta.8", | ||
"version": "4.0.0-beta.9", | ||
"private": false, | ||
@@ -16,4 +16,4 @@ "description": "Promise-based cache library using memory.", | ||
"dependencies": { | ||
"@algolia/cache-common": "4.0.0-beta.8" | ||
"@algolia/cache-common": "4.0.0-beta.9" | ||
} | ||
} |
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
3259
70
+ Added@algolia/cache-common@4.0.0-beta.9(transitive)
- Removed@algolia/cache-common@4.0.0-beta.8(transitive)