@helpscout/helix
Version:
A Faker-powered fixture generator for Javascript
80 lines (61 loc) • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Exception = exports.error = exports.warn = exports.log = void 0;
var _lodash = require("lodash");
var _this = void 0;
/**
* Higher order functional wrapper for the other log methods
*
* @param function $fn Console.log method
* @param string $message Message to log
*
* @returns function
*/
/* istanbul ignore next */
var logWrapper = function logWrapper(fn) {
return (
/* istanbul ignore next */
function (message) {
/* istanbul ignore next */
if (process.env.NODE_ENV !== 'test') {
return fn(message);
}
}
);
};
/* istanbul ignore next */
var log =
/* istanbul ignore next */
function log(message) {
/* istanbul ignore next */
return logWrapper(console.log, message);
};
/* istanbul ignore next */
exports.log = log;
var warn =
/* istanbul ignore next */
function warn(message) {
/* istanbul ignore next */
return logWrapper(console.warn, message);
};
/* istanbul ignore next */
exports.warn = warn;
var error =
/* istanbul ignore next */
function error(message) {
/* istanbul ignore next */
return logWrapper(console.error, message);
};
/* istanbul ignore next */
exports.error = error;
var Exception = function Exception(methodName, message) {
/* istanbul ignore next */
if (!(0, _lodash.isString)(methodName) || !(0, _lodash.isString)(message)) {
warn('helix: Exception(): Arguments need to be strings.');
}
/* istanbul ignore next */
_this.message = "helix: ".concat(methodName, "(): ").concat(message);
};
exports.Exception = Exception;