Skip to content

Instantly share code, notes, and snippets.

@jackphilippi
jackphilippi / messageCache.js
Last active August 13, 2021 02:39
Message cache for handling queues with sqs
const logger = require('../../logger');
/**
* A cache for handling the delay of SQS messages
* @param {Object} opts The options object
*/
function MessageCache(opts) {
// Store the messages that we receive, so that we can
// keep track of the visibility timeout for these messages
this.messageCache = {};
let byte = 0;
let shift = 0;
[0, 1, 1, 1, 1, 0, 0, 1]
.map((bit) => {
byte = byte | bit << (7 - shift);
});
console.log(`The input byte evaluates to ${byte}`);