@silverwind/ioredis-mock
Version:
This library emulates ioredis by performing all operations in-memory.
17 lines (14 loc) • 397 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.rpush = rpush;
function rpush(key, ...values) {
if (this.data.has(key) && !(this.data.get(key) instanceof Array)) {
throw new Error(`Key ${key} does not contain a list`);
}
const list = this.data.get(key) || [];
const length = list.push(...values);
this.data.set(key, list);
return length;
}