flexible-storage
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -95,5 +95,7 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var FlexibleStorage = exports.FlexibleStorage = function () { | ||
function FlexibleStorage(storage, keyPrefix) { | ||
function FlexibleStorage(storage) { | ||
var _this = this; | ||
var keyPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; | ||
_classCallCheck(this, FlexibleStorage); | ||
@@ -100,0 +102,0 @@ |
@@ -6,3 +6,3 @@ /// <reference types="moment" /> | ||
protected storage: Storage; | ||
constructor(storage: Storage, keyPrefix: string | ((key: string) => string)); | ||
constructor(storage: Storage, keyPrefix?: string | ((key: string) => string)); | ||
exists(key: string): boolean; | ||
@@ -9,0 +9,0 @@ pull: <T = any>(key: string, validator?: (value?: T) => void | T) => T; |
{ | ||
"name": "flexible-storage", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Cache on frontend using LocalStorage", | ||
@@ -5,0 +5,0 @@ "main": "src/index.ts", |
@@ -1,2 +0,2 @@ | ||
import { Moment } from "moment"; | ||
import {Moment} from "moment"; | ||
@@ -7,3 +7,3 @@ export class FlexibleStorage { | ||
constructor(storage: Storage, keyPrefix: string | ((key: string) => string)) { | ||
constructor(storage: Storage, keyPrefix: string | ((key: string) => string) = "") { | ||
this.storage = storage; | ||
@@ -42,3 +42,3 @@ this.buildKey = "function" === typeof keyPrefix | ||
const { value } = JSON.parse(this.storage.getItem(this.buildKey(key))); | ||
const {value} = JSON.parse(this.storage.getItem(this.buildKey(key))); | ||
@@ -45,0 +45,0 @@ return validator(value) as T; |
@@ -22,2 +22,5 @@ import { expect } from "chai"; | ||
expect(cacheWithDefaultBuildKey.buildKey("key")).to.be.equal("prefix_key"); | ||
const cacheWithNoKeyPrefix = new FlexibleStorage(storage); | ||
expect(cacheWithNoKeyPrefix.buildKey("key")).to.equal("key"); | ||
}); | ||
@@ -24,0 +27,0 @@ |
Sorry, the diff of this file is not supported yet
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
69036
637