Comparing version 2.3.0 to 2.4.0
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -15,4 +13,2 @@ value: true | ||
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); | ||
function debug(events) { | ||
@@ -72,8 +68,22 @@ return debugWindow(events) || debugProcess(events); | ||
log = _ref.log; | ||
var msg = [event.op ? event.op : null, event.props ? event.props.join(".") : null, event.args ? event.args.join(" ") : null].reduce(function (memo, arg) { | ||
return arg ? memo.concat([arg]) : memo; | ||
}, []); | ||
var msg = [event.op]; | ||
if (event.props) { | ||
msg.push(event.props.join(".")); | ||
} | ||
if (event.args && log) { | ||
var options = JSON.stringify(event.args[0]); | ||
if (options.length < 256) { | ||
msg.push(options); | ||
} else { | ||
msg.push("{ ".concat(Object.keys(event.args[0]).join(", "), " }")); | ||
} | ||
} else if (event.args) { | ||
msg.push(event.args[0]); | ||
} | ||
if (log) { | ||
log.write(msg.join(" ") + "\n"); | ||
log.write(msg.join("\t") + "\n\n"); | ||
} else { | ||
@@ -83,5 +93,5 @@ var _console; | ||
// eslint-disable-next-line no-console | ||
(_console = console).log.apply(_console, (0, _toConsumableArray2.default)(msg)); | ||
(_console = console).log.apply(_console, msg); | ||
} | ||
} | ||
//# sourceMappingURL=debug.js.map |
@@ -54,3 +54,7 @@ "use strict"; | ||
function makeChain(listener) { | ||
if ((0, _util.isObject)(listener)) { | ||
if (listener.then && typeof listener.then === "function") { | ||
return function () { | ||
return listener; | ||
}; | ||
} else if ((0, _util.isObject)(listener)) { | ||
if (listener.if) { | ||
@@ -57,0 +61,0 @@ return ifChain.bind({ |
@@ -44,2 +44,3 @@ export function debug(events) { | ||
const path = require("path") | ||
const log = fs.createWriteStream( | ||
@@ -49,2 +50,3 @@ path.join(process.cwd(), process.env.EVENTS), | ||
) | ||
events.withOptions({ log }).onAny(logger) | ||
@@ -54,12 +56,24 @@ } | ||
export function logger({ event, log }) { | ||
const msg = [ | ||
event.op ? event.op : null, | ||
event.props ? event.props.join(".") : null, | ||
event.args ? event.args.join(" ") : null, | ||
].reduce( | ||
(memo, arg) => (arg ? memo.concat([arg]) : memo), | ||
[] | ||
) | ||
const msg = [event.op] | ||
if (event.props) { | ||
msg.push(event.props.join(".")) | ||
} | ||
if (event.args && log) { | ||
const options = JSON.stringify(event.args[0]) | ||
if (options.length < 256) { | ||
msg.push(options) | ||
} else { | ||
msg.push( | ||
`{ ${Object.keys(event.args[0]).join(", ")} }` | ||
) | ||
} | ||
} else if (event.args) { | ||
msg.push(event.args[0]) | ||
} | ||
if (log) { | ||
log.write(msg.join(" ") + "\n") | ||
log.write(msg.join("\t") + "\n\n") | ||
} else { | ||
@@ -66,0 +80,0 @@ // eslint-disable-next-line no-console |
@@ -26,3 +26,8 @@ import { isObject } from "./util" | ||
function makeChain(listener) { | ||
if (isObject(listener)) { | ||
if ( | ||
listener.then && | ||
typeof listener.then === "function" | ||
) { | ||
return () => listener | ||
} else if (isObject(listener)) { | ||
if (listener.if) { | ||
@@ -29,0 +34,0 @@ return ifChain.bind({ listener }) |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "Build beautiful and extensible eventing APIs", | ||
@@ -18,0 +18,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124320
2287