ioredis-mock
Version:
This library emulates ioredis by performing all operations in-memory.
18 lines (14 loc) • 398 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.lpop = lpop;
function lpop(key) {
if (this.data.has(key) && !(this.data.get(key) instanceof Array)) {
throw new Error("Key " + key + " does not contain a list");
}
var list = this.data.get(key) || [];
var item = list.length > 0 ? list.shift() : null;
this.data.set(key, list);
return item;
}