@agnostack/requestd
Version:
Please contact agnoStack via info@agnostack.com for any questions
44 lines • 1.69 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const AbstractStorage_1 = __importDefault(require("./AbstractStorage"));
const utils_1 = require("../utils");
class StorageNode extends AbstractStorage_1.default {
constructor(config) {
super(config);
const { storage_key } = (0, utils_1.ensureObject)(config);
try {
// NOTE: intentionally in here as optional devDependency
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { LocalStorage } = require('node-localstorage');
if (LocalStorage) {
this.storage = new LocalStorage(storage_key);
}
}
catch (ignore) {
console.info(`Ignoring import of 'node-localstorage'`);
}
}
// TODO: handle expires in setItem
setItem(key, value) {
var _a;
(_a = this.storage) === null || _a === void 0 ? void 0 : _a.setItem(key, value);
}
// TODO: handle expired in getItem
getItem(key) {
var _a;
return (_a = this.storage) === null || _a === void 0 ? void 0 : _a.getItem(key);
}
removeItem(key) {
var _a;
(_a = this.storage) === null || _a === void 0 ? void 0 : _a.removeItem(key);
}
static isSupported() {
var _a;
return ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) != undefined;
}
}
exports.default = StorageNode;
//# sourceMappingURL=StorageNode.js.map