solace
Version:
Alternative to console log which automatically beautifies the output
57 lines (43 loc) • 1.56 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', {
value: true
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
var stringify = function stringify(value) {
return JSON.stringify(value) + '\n';
};
exports['default'] = {
name: 'machine',
title: 'Format the output in a compact manner easily readable by a machine',
writeError: function writeError(messager, message, options) {
var hasTitle = _lodash2['default'].isString(options.title);
if (hasTitle) {
messager.write(options.title + ': ' + message + '\n');
} else {
messager.write(message + '\n');
}
}, //end write
writeSimpleValue: function writeSimpleValue(messager, message, options) {
var hasTitle = _lodash2['default'].isString(options.title);
if (hasTitle) {
messager.write(options.title + ': ' + message + '\n');
} else {
messager.write(message + '\n');
}
}, //end write
writeObject: function writeObject(messager, message) {
messager.write(stringify(message));
},
writeEmptyArray: function writeEmptyArray(messager, message) {
messager.write(stringify(message));
},
writeArrayOfSimpleValues: function writeArrayOfSimpleValues(messager, message) {
messager.write(stringify(message));
},
writeArrayOfSimpleObjects: function writeArrayOfSimpleObjects(messager, message) {
messager.write(stringify(message));
}
};
module.exports = exports['default'];