2017-05-03 15:35:00 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
exports.default = consoleFunc;
|
|
|
|
|
|
|
|
var _arrayEach = require('lodash/_arrayEach');
|
|
|
|
|
|
|
|
var _arrayEach2 = _interopRequireDefault(_arrayEach);
|
|
|
|
|
2017-05-24 15:10:37 +02:00
|
|
|
var _slice = require('./slice');
|
2017-05-03 15:35:00 +02:00
|
|
|
|
2017-05-24 15:10:37 +02:00
|
|
|
var _slice2 = _interopRequireDefault(_slice);
|
2017-05-03 15:35:00 +02:00
|
|
|
|
|
|
|
var _wrapAsync = require('./wrapAsync');
|
|
|
|
|
|
|
|
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
function consoleFunc(name) {
|
2017-05-24 15:10:37 +02:00
|
|
|
return function (fn /*, ...args*/) {
|
|
|
|
var args = (0, _slice2.default)(arguments, 1);
|
|
|
|
args.push(function (err /*, ...args*/) {
|
|
|
|
var args = (0, _slice2.default)(arguments, 1);
|
2017-05-03 15:35:00 +02:00
|
|
|
if (typeof console === 'object') {
|
|
|
|
if (err) {
|
|
|
|
if (console.error) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
|
|
|
} else if (console[name]) {
|
|
|
|
(0, _arrayEach2.default)(args, function (x) {
|
|
|
|
console[name](x);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2017-05-24 15:10:37 +02:00
|
|
|
});
|
|
|
|
(0, _wrapAsync2.default)(fn).apply(null, args);
|
|
|
|
};
|
2017-05-03 15:35:00 +02:00
|
|
|
}
|
|
|
|
module.exports = exports['default'];
|