X-Git-Url: https://git.squeep.com/?p=squeep-authentication-module;a=blobdiff_plain;f=lib%2Fcommon.js;fp=lib%2Fcommon.js;h=d69e6ad6a2131d12d975dbaaddaca70fdb3551e5;hp=816b65c5bea9ad23052eaf75b06961a20e999037;hb=681ff60618195ab6754e5b8718a32e53ab2222ec;hpb=dcbdec0fcdf0b0241a155c89ae03f63ecba6d395 diff --git a/lib/common.js b/lib/common.js index 816b65c..d69e6ad 100644 --- a/lib/common.js +++ b/lib/common.js @@ -20,10 +20,22 @@ const freezeDeep = (o) => { return o; }; +/** + * Return a new object duplicating `o`, without the properties specified. + * @param {Object} o + * @param {String[]} props + * @returns {Object} + */ const omit = (o, props) => { return Object.fromEntries(Object.entries(o).filter(([k]) => !props.includes(k))); }; +/** + * Helper to log mystery-box statistics. + * @param {ConsoleLike} logger + * @param {String} scope + * @returns {Function} + */ const mysteryBoxLogger = (logger, scope) => { return (s) => { logger.debug(scope, `${s.packageName}@${s.packageVersion}:${s.method}`, omit(s, [