leveldb-registry
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -100,5 +100,3 @@ "use strict"; | ||
.get(id) | ||
.then(function (data) { | ||
return JSON.parse(data); | ||
})["catch"](function () { | ||
.then(JSON.parse)["catch"](function () { | ||
})]; | ||
@@ -152,4 +150,20 @@ case 1: | ||
}; | ||
return { add: add, remove: remove, fetch: fetch, list: list }; | ||
var ids = function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2, withLeveldb(function (r) { | ||
return new Promise(function (resolve, reject) { | ||
var keys = []; | ||
r.createKeyStream() | ||
.on('data', function (key) { | ||
keys.push(key.toString()); | ||
}) | ||
.on('close', function () { return resolve(keys); }) | ||
.on('end', function () { return resolve(keys); }) | ||
.on('error', function () { return reject(); }); | ||
}); | ||
})]; | ||
}); | ||
}); }; | ||
return { add: add, remove: remove, fetch: fetch, list: list, ids: ids }; | ||
}; | ||
exports.leveldbRegistry = leveldbRegistry; |
@@ -12,2 +12,3 @@ export interface Identifiable { | ||
list: (filter?: Filter<TItem>) => Promise<TItem[]>; | ||
ids: () => Promise<string[]>; | ||
} |
{ | ||
"name": "leveldb-registry", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "leveldb registry", | ||
@@ -12,3 +12,2 @@ "files": [ | ||
"build": "tsc", | ||
"build:watch": "tsc --watch", | ||
"test": "jest", | ||
@@ -40,2 +39,3 @@ "test:watch": "jest --watchAll", | ||
"@typescript-eslint/eslint-plugin": "^5.54.1", | ||
"@typescript-eslint/parser": "^5.59.6", | ||
"eslint": "^8.35.0", | ||
@@ -42,0 +42,0 @@ "eslint-plugin-import": "^2.27.5", |
@@ -34,3 +34,6 @@ ## leveldb-registry | ||
const user = await registry.add({ id: randomUUID(), name: "haz" }); | ||
return await registry.fetch(user.id); | ||
const found = await registry.fetch(user.id); | ||
const users = await registry.list(); | ||
const userIds = await registry.ids(); | ||
``` |
22754
188
39
13