UNPKG

@songkeys/nestjs-redis-health

Version:

Redis(ioredis) health checks module for Nest framework (node.js).

26 lines (25 loc) 778 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseUsedMemory = exports.removeLineBreaks = void 0; /** * Replaces the line breaks with a space. * * @param text - Some text */ const removeLineBreaks = (text) => { return text.replace(/(\r\n|\n|\r)/gm, ' ').replace(/\s+/g, ' '); }; exports.removeLineBreaks = removeLineBreaks; /** * Parses used_memory to an integer. * * @param info - Memory consumption related information */ const parseUsedMemory = (info) => { const start = info.indexOf('used_memory'); const end = info.indexOf('used_memory_human') - 1; if (start < 0 || end < 0) return 0; return Number.parseInt(info.slice(start, end).split(':')[1], 10); }; exports.parseUsedMemory = parseUsedMemory;