projects
/
squeep-mystery-box
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
support providing multiple secrets, always encrypt with first, attempt decryption...
[squeep-mystery-box]
/
lib
/
common.js
diff --git
a/lib/common.js
b/lib/common.js
index 4c7e6392fe1f7e6f28a9321680d56fbf933404cb..1d4223b1749d1cce37b729233f988098abc36b5a 100644
(file)
--- a/
lib/common.js
+++ b/
lib/common.js
@@
-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 = {
module.exports = {
+ ensureArray,
fileScope,
randomBytesAsync,
};
\ No newline at end of file
fileScope,
randomBytesAsync,
};
\ No newline at end of file