UNPKG

@silverwind/ioredis-mock

Version:

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

27 lines (20 loc) 658 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.zcount = zcount; var _lodash = require("lodash"); var _zrangeCommand = require("./zrange-command.common"); function zcount(key, inputMin, inputMax) { const map = this.data.get(key); if (!map) { return 0; } if (this.data.has(key) && !(this.data.get(key) instanceof Map)) { return 0; } const min = (0, _zrangeCommand.parseLimit)(inputMin); const max = (0, _zrangeCommand.parseLimit)(inputMax); const filteredArray = (0, _lodash.filter)(Array.from(map.values()), (0, _zrangeCommand.filterPredicate)(min, max)); return filteredArray.length; }