beanstalkd-protocol
Version:
Beanstalkd protocol parser for Node.js/Javascript
20 lines (16 loc) • 510 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.reduce = reduce;
const CRLF = exports.CRLF = Buffer.from([0x0d, 0x0a]); // '\r\n'
const SPACE = exports.SPACE = Buffer.from([0x20]); // ' '
function reduce(collection, callback, accumulator) {
if (!collection) return accumulator;
var index = -1,
length = collection.length;
while (++index < length) {
accumulator = callback(accumulator, collection[index], index, collection);
}
return accumulator;
}