1d4223b1749d1cce37b729233f988098abc36b5a
3 const path
= require('path');
4 const { randomBytes
} = require('crypto');
5 const { promisify
} = require('util');
6 const randomBytesAsync
= promisify(randomBytes
);
10 * Return a function which combines a part of the filename with a scope, for use in logging.
11 * @param {string} filename
13 const fileScope
= (filename
) => {
14 let fScope
= path
.basename(filename
, '.js');
15 if (fScope
=== 'index') {
16 fScope
= path
.basename(path
.dirname(filename
));
18 return (scope
) => `${fScope}:${scope}`;
23 * Return an array containing x if x is something and not an array
26 const ensureArray
= (x
) => {
27 if (x
=== undefined) {
30 if (!Array
.isArray(x
)) {