summaryrefslogtreecommitdiff
path: root/build-es/internal/consoleFunc.js
blob: d56a7bd448ac321c4eaa4587c515b60596b73d0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';

import arrayEach from 'lodash-es/_arrayEach';
import rest from 'lodash-es/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);
                    });
                }
            }
        })]));
    });
}