UNPKG

sqs-producer

Version:

Enqueues messages onto a given SQS queue

33 lines (32 loc) 986 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isString = isString; exports.isObject = isObject; exports.isMessageAttributeValid = isMessageAttributeValid; /** * Checks if the value is a string * @param value - The value to check */ function isString(value) { return typeof value === "string" || value instanceof String; } /** * Checks if the value is an object * @param value - The value to check */ function isObject(value) { return value && typeof value === "object" && value instanceof Object; } /** * Checks if a MessageAttribute is valid * @param messageAttribute - The MessageAttribute to check */ function isMessageAttributeValid(messageAttribute) { if (!messageAttribute.DataType) { throw new Error("A MessageAttribute must have a DataType key"); } if (!isString(messageAttribute.DataType)) { throw new Error("The DataType key of a MessageAttribute must be a String"); } return true; }