UNPKG

redis-smq

Version:

A simple high-performance Redis message queue for Node.js.

38 lines 1.77 kB
"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); exports._fromMessage = _fromMessage; const message_envelope_js_1 = require("../message-envelope.js"); const message_state_js_1 = require("../message-state.js"); const producible_message_js_1 = require("../producible-message.js"); function _fromMessage(msg, status, msgState) { const _a = typeof msg === 'string' ? JSON.parse(msg) : msg.toJSON(), { destinationQueue, consumerGroupId } = _a, params = __rest(_a, ["destinationQueue", "consumerGroupId"]); const messagePub = new producible_message_js_1.ProducibleMessage(); Object.assign(messagePub, params); const m = new message_envelope_js_1.MessageEnvelope(messagePub); m.setDestinationQueue(destinationQueue); if (consumerGroupId) { m.setConsumerGroupId(consumerGroupId); } if (status !== null) { m.setStatus(status); } if (msgState !== null) { const messageStateInstance = new message_state_js_1.MessageState(); const messageStateJSON = typeof msgState === 'string' ? JSON.parse(msgState) : msgState; Object.assign(messageStateInstance, messageStateJSON); m.setMessageState(messageStateInstance); } return m; } //# sourceMappingURL=_from-message.js.map