greglebreton 4e8a693745
Some checks failed
continuous-integration/drone/push Build is failing
add garagenum exp + maj url site projets
2023-01-08 16:50:31 +01:00

27 lines
644 B
JavaScript

export function levelup(store) {
return Object.assign(Object.create(store), {
get(key, options, callback) {
let result = store.get(key);
if (typeof options == 'function')
callback = options;
if (callback) {
if (result === undefined)
callback(new NotFoundError());
else
callback(null, result);
} else {
if (result === undefined)
return Promise.reject(new NotFoundError());
else
return Promise.resolve(result);
}
},
});
}
class NotFoundError extends Error {
constructor(message) {
super(message);
this.name = 'NotFoundError';
this.notFound = true;
}
}