support providing multiple secrets, always encrypt with first, attempt decryption...
[squeep-mystery-box] / lib / common.js
index 4c7e6392fe1f7e6f28a9321680d56fbf933404cb..1d4223b1749d1cce37b729233f988098abc36b5a 100644 (file)
@@ -19,7 +19,23 @@ const fileScope = (filename) => {
 }
 
 
+/**
+ * Return an array containing x if x is something and not an array
+ * @param {*} x
+ */
+const ensureArray = (x) => {
+  if (x === undefined) {
+    return [];
+  }
+  if (!Array.isArray(x)) {
+    return Array(x);
+  }
+  return x;
+};
+
+
 module.exports = {
+  ensureArray,
   fileScope,
   randomBytesAsync,
 };
\ No newline at end of file