X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fcommon.js;h=1d4223b1749d1cce37b729233f988098abc36b5a;hb=HEAD;hp=4c7e6392fe1f7e6f28a9321680d56fbf933404cb;hpb=b9782b5dfca21a6da610eebf8bd7207f10256fbf;p=squeep-mystery-box diff --git a/lib/common.js b/lib/common.js deleted file mode 100644 index 4c7e639..0000000 --- a/lib/common.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -const path = require('path'); -const { randomBytes } = require('crypto'); -const { promisify } = require('util'); -const randomBytesAsync = promisify(randomBytes); - - -/** - * Return a function which combines a part of the filename with a scope, for use in logging. - * @param {string} filename - */ -const fileScope = (filename) => { - let fScope = path.basename(filename, '.js'); - if (fScope === 'index') { - fScope = path.basename(path.dirname(filename)); - } - return (scope) => `${fScope}:${scope}`; -} - - -module.exports = { - fileScope, - randomBytesAsync, -}; \ No newline at end of file