@edjopato/datastore
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -42,3 +42,5 @@ "use strict"; | ||
this._singleQuery = (_b = query.singleQuery) !== null && _b !== void 0 ? _b : (async (key) => { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const result = await query.bulkQuery([key]); | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
return result[key]; | ||
@@ -49,2 +51,3 @@ }); | ||
.map(async (key) => { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const value = await query.singleQuery(key); | ||
@@ -88,2 +91,3 @@ return { key, value }; | ||
await Promise.all(Object.entries(queryResults) | ||
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types | ||
.map(async ([key, value]) => this._store.set(key, value, this._ttl))); | ||
@@ -94,2 +98,3 @@ } | ||
const value = await this._store.get(key); | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
return { key, value: value }; | ||
@@ -96,0 +101,0 @@ })); |
import { ExtendedStore } from './type'; | ||
export declare class KeyValueInMemoryFile<T> implements ExtendedStore<T> { | ||
private readonly _filepath; | ||
readonly ttlSupport = false; | ||
get ttlSupport(): boolean; | ||
private readonly _inMemoryStorage; | ||
@@ -6,0 +6,0 @@ constructor(_filepath: string); |
@@ -14,8 +14,2 @@ "use strict"; | ||
}); | ||
Object.defineProperty(this, "ttlSupport", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: false | ||
}); | ||
Object.defineProperty(this, "_inMemoryStorage", { | ||
@@ -35,2 +29,5 @@ enumerable: true, | ||
} | ||
get ttlSupport() { | ||
return false; | ||
} | ||
keys() { | ||
@@ -64,4 +61,4 @@ return [...this._inMemoryStorage.keys()]; | ||
const json = {}; | ||
for (const key of this._inMemoryStorage.keys()) { | ||
json[key] = this._inMemoryStorage.get(key); | ||
for (const [key, value] of this._inMemoryStorage.entries()) { | ||
json[key] = value; | ||
} | ||
@@ -68,0 +65,0 @@ return json; |
import { ExtendedStore } from './type'; | ||
export declare class KeyValueInMemoryFiles<T> implements ExtendedStore<T> { | ||
private readonly _directory; | ||
readonly ttlSupport = false; | ||
get ttlSupport(): boolean; | ||
private readonly _inMemoryStorage; | ||
@@ -6,0 +6,0 @@ constructor(_directory: string); |
@@ -14,8 +14,2 @@ "use strict"; | ||
}); | ||
Object.defineProperty(this, "ttlSupport", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: false | ||
}); | ||
Object.defineProperty(this, "_inMemoryStorage", { | ||
@@ -33,2 +27,5 @@ enumerable: true, | ||
} | ||
get ttlSupport() { | ||
return false; | ||
} | ||
keys() { | ||
@@ -35,0 +32,0 @@ return [...this._inMemoryStorage.keys()]; |
import { ExtendedStore } from './type'; | ||
export declare class KeyValueInMemory<T> implements ExtendedStore<T> { | ||
readonly ttlSupport = false; | ||
get ttlSupport(): boolean; | ||
private readonly _inMemoryStorage; | ||
@@ -5,0 +5,0 @@ keys(): readonly string[]; |
@@ -6,8 +6,2 @@ "use strict"; | ||
constructor() { | ||
Object.defineProperty(this, "ttlSupport", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: false | ||
}); | ||
Object.defineProperty(this, "_inMemoryStorage", { | ||
@@ -20,2 +14,5 @@ enumerable: true, | ||
} | ||
get ttlSupport() { | ||
return false; | ||
} | ||
keys() { | ||
@@ -22,0 +19,0 @@ return [...this._inMemoryStorage.keys()]; |
@@ -6,3 +6,3 @@ "use strict"; | ||
if (typeof ttl !== 'number') { | ||
return { value, until: Infinity }; | ||
return { value, until: Number.POSITIVE_INFINITY }; | ||
} | ||
@@ -9,0 +9,0 @@ const until = now + ttl; |
import { ExtendedStore } from './type'; | ||
export declare class TtlKeyValueInMemoryFile<T> implements ExtendedStore<T> { | ||
private readonly _filepath; | ||
readonly ttlSupport = true; | ||
get ttlSupport(): boolean; | ||
private readonly _inMemoryStorage; | ||
@@ -6,0 +6,0 @@ constructor(_filepath: string, cleanupIntervalMilliseconds?: number); |
@@ -15,8 +15,2 @@ "use strict"; | ||
}); | ||
Object.defineProperty(this, "ttlSupport", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: true | ||
}); | ||
Object.defineProperty(this, "_inMemoryStorage", { | ||
@@ -39,2 +33,5 @@ enumerable: true, | ||
} | ||
get ttlSupport() { | ||
return true; | ||
} | ||
keys() { | ||
@@ -76,4 +73,4 @@ return [...this._inMemoryStorage.keys()]; | ||
const json = {}; | ||
for (const key of this._inMemoryStorage.keys()) { | ||
json[key] = this._inMemoryStorage.get(key); | ||
for (const [key, value] of this._inMemoryStorage.entries()) { | ||
json[key] = value; | ||
} | ||
@@ -80,0 +77,0 @@ return json; |
import { ExtendedStore } from './type'; | ||
export declare class TtlKeyValueInMemoryFiles<T> implements ExtendedStore<T> { | ||
private readonly _directory; | ||
readonly ttlSupport = true; | ||
get ttlSupport(): boolean; | ||
private readonly _inMemoryStorage; | ||
@@ -6,0 +6,0 @@ constructor(_directory: string, cleanupIntervalMilliseconds?: number); |
@@ -15,8 +15,2 @@ "use strict"; | ||
}); | ||
Object.defineProperty(this, "ttlSupport", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: true | ||
}); | ||
Object.defineProperty(this, "_inMemoryStorage", { | ||
@@ -37,2 +31,5 @@ enumerable: true, | ||
} | ||
get ttlSupport() { | ||
return true; | ||
} | ||
keys() { | ||
@@ -39,0 +36,0 @@ return [...this._inMemoryStorage.keys()]; |
import { ExtendedStore } from './type'; | ||
export declare class TtlKeyValueInMemory<T> implements ExtendedStore<T> { | ||
readonly ttlSupport = true; | ||
get ttlSupport(): boolean; | ||
private readonly _inMemoryStorage; | ||
@@ -5,0 +5,0 @@ constructor(cleanupIntervalMilliseconds?: number); |
@@ -7,8 +7,2 @@ "use strict"; | ||
constructor(cleanupIntervalMilliseconds = 5 * 60 * 1000) { | ||
Object.defineProperty(this, "ttlSupport", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: true | ||
}); | ||
Object.defineProperty(this, "_inMemoryStorage", { | ||
@@ -24,2 +18,5 @@ enumerable: true, | ||
} | ||
get ttlSupport() { | ||
return true; | ||
} | ||
keys() { | ||
@@ -26,0 +23,0 @@ return [...this._inMemoryStorage.keys()]; |
{ | ||
"name": "@edjopato/datastore", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Handles different ways to store data within NodeJS", | ||
@@ -12,5 +12,2 @@ "license": "MIT", | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"scripts": { | ||
@@ -21,4 +18,16 @@ "build": "del-cli dist && tsc", | ||
}, | ||
"main": "dist", | ||
"types": "dist", | ||
"type": "commonjs", | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"dependencies": { | ||
"write-json-file": "^4.2.0" | ||
}, | ||
"devDependencies": { | ||
"@sindresorhus/tsconfig": "^1.0.2", | ||
"@types/node": "^15.0.1", | ||
"del-cli": "^3.0.0", | ||
"typescript": "^4.2.3", | ||
"xo": "^0.39.1" | ||
}, | ||
"files": [ | ||
@@ -28,24 +37,13 @@ "dist", | ||
], | ||
"keywords": [ | ||
"wikidata" | ||
], | ||
"main": "dist", | ||
"types": "dist", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"write-json-file": "^4.2.0" | ||
}, | ||
"devDependencies": { | ||
"@sindresorhus/tsconfig": "^0.8.0", | ||
"@types/node": "^14.0.5", | ||
"del-cli": "^3.0.0", | ||
"typescript": "^4.1.2", | ||
"xo": "^0.36.1" | ||
}, | ||
"xo": { | ||
"semicolon": false, | ||
"rules": { | ||
"@typescript-eslint/class-literal-property-style": "off" | ||
"@typescript-eslint/prefer-readonly-parameter-types": "error" | ||
} | ||
} | ||
} |
@@ -5,3 +5,2 @@ # @edjopato/datastore | ||
[![node](https://img.shields.io/node/v/@edjopato/datastore.svg)](https://www.npmjs.com/package/@edjopato/datastore) | ||
[![Build Status](https://travis-ci.com/EdJoPaTo/js-datastore.svg?branch=master)](https://travis-ci.com/EdJoPaTo/js-datastore) | ||
[![Dependency Status](https://david-dm.org/EdJoPaTo/js-datastore/status.svg)](https://david-dm.org/EdJoPaTo/js-datastore) | ||
@@ -8,0 +7,0 @@ [![Dev Dependency Status](https://david-dm.org/EdJoPaTo/js-datastore/dev-status.svg)](https://david-dm.org/EdJoPaTo/js-datastore?type=dev) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47085
782
23