UNPKG

ioredis-mock

Version:

This library emulates ioredis by performing all operations in-memory.

17 lines (15 loc) 434 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.incrby = incrby; function incrby(key) { var increment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; if (!this.data.has(key)) { this.data.set(key, '0'); } var curVal = Number(this.data.get(key)); var nextVal = curVal + parseInt(increment, 10); this.data.set(key, nextVal.toString()); return nextVal; }