@silverwind/ioredis-mock
Version:
This library emulates ioredis by performing all operations in-memory.
29 lines (24 loc) • 479 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.zincrby = zincrby;
function zincrby(key, increment, value) {
if (!this.data.has(key)) {
this.data.set(key, new Map());
}
const map = this.data.get(key);
let score = 0;
if (map.has(value)) {
({
score
} = map.get(value));
}
score += parseFloat(increment);
map.set(value, {
value,
score
});
this.data.set(key, map);
return score.toString();
}