redux-persist-chrome-storage
Advanced tools
Comparing version
@@ -21,5 +21,3 @@ (function (global, factory) { | ||
_ChromeStorage = _interopRequireDefault(_ChromeStorage); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
/** | ||
@@ -26,0 +24,0 @@ * Copyright (c) 2018 - 2021 Robin Malburn |
@@ -20,11 +20,6 @@ (function (global, factory) { | ||
_exports["default"] = void 0; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
/** | ||
@@ -36,5 +31,5 @@ * Copyright (c) 2018 - 2021 Robin Malburn | ||
*/ | ||
var driverMap = new WeakMap(); | ||
var runtimeMap = new WeakMap(); | ||
var ChromeStorage = /*#__PURE__*/function () { | ||
@@ -51,6 +46,6 @@ /** | ||
_classCallCheck(this, ChromeStorage); | ||
driverMap.set(this, driver); | ||
runtimeMap.set(this, runtime); | ||
} | ||
/** | ||
@@ -61,4 +56,2 @@ * Return the storage driver. | ||
*/ | ||
_createClass(ChromeStorage, [{ | ||
@@ -69,2 +62,3 @@ key: "getDriver", | ||
} | ||
/** | ||
@@ -75,3 +69,2 @@ * Determine whether the runtime has an error. | ||
*/ | ||
}, { | ||
@@ -82,2 +75,3 @@ key: "hasError", | ||
} | ||
/** | ||
@@ -88,3 +82,2 @@ * Get the last error message | ||
*/ | ||
}, { | ||
@@ -95,2 +88,3 @@ key: "getError", | ||
} | ||
/** | ||
@@ -104,3 +98,2 @@ * Set an item in storage. | ||
*/ | ||
}, { | ||
@@ -110,3 +103,2 @@ key: "setItem", | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
@@ -117,3 +109,2 @@ _this.getDriver().set(_defineProperty({}, key, item), function () { | ||
} | ||
return resolve(); | ||
@@ -123,2 +114,3 @@ }); | ||
} | ||
/** | ||
@@ -131,3 +123,2 @@ * Get an item from storage. | ||
*/ | ||
}, { | ||
@@ -137,3 +128,2 @@ key: "getItem", | ||
var _this2 = this; | ||
return new Promise(function (resolve, reject) { | ||
@@ -144,3 +134,2 @@ _this2.getDriver().get(key, function (response) { | ||
} | ||
return resolve(response[key]); | ||
@@ -150,2 +139,3 @@ }); | ||
} | ||
/** | ||
@@ -158,3 +148,2 @@ * Remove an item from storage. | ||
*/ | ||
}, { | ||
@@ -164,3 +153,2 @@ key: "removeItem", | ||
var _this3 = this; | ||
return new Promise(function (resolve, reject) { | ||
@@ -171,3 +159,2 @@ _this3.getDriver().remove(key, function () { | ||
} | ||
return resolve(); | ||
@@ -178,7 +165,5 @@ }); | ||
}]); | ||
return ChromeStorage; | ||
}(); | ||
_exports["default"] = ChromeStorage; | ||
}); |
@@ -7,3 +7,5 @@ /** | ||
*/ | ||
import ChromeStorage from './storage/ChromeStorage'; | ||
/** | ||
@@ -16,5 +18,4 @@ * Create a ChromeStorage instance from the given chrome instance | ||
*/ | ||
export default function createChromeStorage(chrome, driver) { | ||
return new ChromeStorage(chrome.storage[driver], chrome.runtime); | ||
} |
@@ -7,2 +7,3 @@ /** | ||
*/ | ||
const driverMap = new WeakMap(); | ||
@@ -23,2 +24,3 @@ const runtimeMap = new WeakMap(); | ||
} | ||
/** | ||
@@ -29,7 +31,6 @@ * Return the storage driver. | ||
*/ | ||
getDriver() { | ||
return driverMap.get(this); | ||
} | ||
/** | ||
@@ -40,7 +41,6 @@ * Determine whether the runtime has an error. | ||
*/ | ||
hasError() { | ||
return !!this.getError(); | ||
} | ||
/** | ||
@@ -51,7 +51,6 @@ * Get the last error message | ||
*/ | ||
getError() { | ||
return runtimeMap.get(this).lastError; | ||
} | ||
/** | ||
@@ -65,4 +64,2 @@ * Set an item in storage. | ||
*/ | ||
setItem(key, item) { | ||
@@ -76,3 +73,2 @@ return new Promise((resolve, reject) => { | ||
} | ||
return resolve(); | ||
@@ -82,2 +78,3 @@ }); | ||
} | ||
/** | ||
@@ -90,4 +87,2 @@ * Get an item from storage. | ||
*/ | ||
getItem(key) { | ||
@@ -99,3 +94,2 @@ return new Promise((resolve, reject) => { | ||
} | ||
return resolve(response[key]); | ||
@@ -105,2 +99,3 @@ }); | ||
} | ||
/** | ||
@@ -113,4 +108,2 @@ * Remove an item from storage. | ||
*/ | ||
removeItem(key) { | ||
@@ -122,3 +115,2 @@ return new Promise((resolve, reject) => { | ||
} | ||
return resolve(); | ||
@@ -128,3 +120,2 @@ }); | ||
} | ||
} |
@@ -7,7 +7,4 @@ "use strict"; | ||
exports["default"] = createChromeStorage; | ||
var _ChromeStorage = _interopRequireDefault(require("./storage/ChromeStorage")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
/** | ||
@@ -14,0 +11,0 @@ * Copyright (c) 2018 - 2021 Robin Malburn |
@@ -7,11 +7,6 @@ "use strict"; | ||
exports["default"] = void 0; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
/** | ||
@@ -23,5 +18,5 @@ * Copyright (c) 2018 - 2021 Robin Malburn | ||
*/ | ||
var driverMap = new WeakMap(); | ||
var runtimeMap = new WeakMap(); | ||
var ChromeStorage = /*#__PURE__*/function () { | ||
@@ -38,6 +33,6 @@ /** | ||
_classCallCheck(this, ChromeStorage); | ||
driverMap.set(this, driver); | ||
runtimeMap.set(this, runtime); | ||
} | ||
/** | ||
@@ -48,4 +43,2 @@ * Return the storage driver. | ||
*/ | ||
_createClass(ChromeStorage, [{ | ||
@@ -56,2 +49,3 @@ key: "getDriver", | ||
} | ||
/** | ||
@@ -62,3 +56,2 @@ * Determine whether the runtime has an error. | ||
*/ | ||
}, { | ||
@@ -69,2 +62,3 @@ key: "hasError", | ||
} | ||
/** | ||
@@ -75,3 +69,2 @@ * Get the last error message | ||
*/ | ||
}, { | ||
@@ -82,2 +75,3 @@ key: "getError", | ||
} | ||
/** | ||
@@ -91,3 +85,2 @@ * Set an item in storage. | ||
*/ | ||
}, { | ||
@@ -97,3 +90,2 @@ key: "setItem", | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
@@ -104,3 +96,2 @@ _this.getDriver().set(_defineProperty({}, key, item), function () { | ||
} | ||
return resolve(); | ||
@@ -110,2 +101,3 @@ }); | ||
} | ||
/** | ||
@@ -118,3 +110,2 @@ * Get an item from storage. | ||
*/ | ||
}, { | ||
@@ -124,3 +115,2 @@ key: "getItem", | ||
var _this2 = this; | ||
return new Promise(function (resolve, reject) { | ||
@@ -131,3 +121,2 @@ _this2.getDriver().get(key, function (response) { | ||
} | ||
return resolve(response[key]); | ||
@@ -137,2 +126,3 @@ }); | ||
} | ||
/** | ||
@@ -145,3 +135,2 @@ * Remove an item from storage. | ||
*/ | ||
}, { | ||
@@ -151,3 +140,2 @@ key: "removeItem", | ||
var _this3 = this; | ||
return new Promise(function (resolve, reject) { | ||
@@ -158,3 +146,2 @@ _this3.getDriver().remove(key, function () { | ||
} | ||
return resolve(); | ||
@@ -165,6 +152,4 @@ }); | ||
}]); | ||
return ChromeStorage; | ||
}(); | ||
exports["default"] = ChromeStorage; |
{ | ||
"name": "redux-persist-chrome-storage", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "redux-persist storage adaptor for Chrome extensions storage API.", | ||
@@ -5,0 +5,0 @@ "repository": { |
19471
-0.22%