diff options
Diffstat (limited to 'lib/internal/consoleFunc.js')
-rw-r--r-- | lib/internal/consoleFunc.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/internal/consoleFunc.js b/lib/internal/consoleFunc.js new file mode 100644 index 0000000..fd8130d --- /dev/null +++ b/lib/internal/consoleFunc.js @@ -0,0 +1,23 @@ +'use strict'; + +import arrayEach from 'lodash/_arrayEach'; +import rest from 'lodash/rest'; + +export default function consoleFunc(name) { + return rest(function (fn, args) { + fn.apply(null, args.concat([rest(function (err, args) { + if (typeof console === 'object') { + if (err) { + if (console.error) { + console.error(err); + } + } + else if (console[name]) { + arrayEach(args, function (x) { + console[name](x); + }); + } + } + })])); + }); +} |