summaryrefslogtreecommitdiff
path: root/lib/internal/consoleFunc.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/consoleFunc.js')
-rw-r--r--lib/internal/consoleFunc.js26
1 files changed, 9 insertions, 17 deletions
diff --git a/lib/internal/consoleFunc.js b/lib/internal/consoleFunc.js
index c977647..d2c1cb1 100644
--- a/lib/internal/consoleFunc.js
+++ b/lib/internal/consoleFunc.js
@@ -1,23 +1,15 @@
-import slice from './slice';
import wrapAsync from './wrapAsync';
export default function consoleFunc(name) {
- return function (fn/*, ...args*/) {
- var args = slice(arguments, 1);
- args.push(function (err/*, ...args*/) {
- var args = slice(arguments, 1);
- if (typeof console === 'object') {
- if (err) {
- if (console.error) {
- console.error(err);
- }
- } else if (console[name]) {
- args.forEach(function (x) {
- console[name](x);
- });
+ return (fn, ...args) => wrapAsync(fn)(...args, (err, ...resultArgs) => {
+ if (typeof console === 'object') {
+ if (err) {
+ if (console.error) {
+ console.error(err);
}
+ } else if (console[name]) {
+ resultArgs.forEach(x => console[name](x));
}
- })
- wrapAsync(fn).apply(null, args);
- };
+ }
+ })
}