Comparing version 0.5.0 to 0.6.0
@@ -25,7 +25,6 @@ "use strict"; | ||
var matches = args.reduce(matchArg, { | ||
events: events, | ||
extras: [] | ||
args: [], | ||
events: events | ||
}); | ||
var propsArray = (0, _props.propsToArray)(matches.props); | ||
matches.extras = matches.extras.length ? matches.extras : undefined; | ||
matches.propsArray = propsArray.length ? propsArray : undefined; | ||
@@ -49,3 +48,3 @@ return matches; | ||
memo.extras.push(arg); | ||
memo.args.push(arg); | ||
} | ||
@@ -52,0 +51,0 @@ |
@@ -73,3 +73,2 @@ "use strict"; | ||
fn((0, _payload.buildPayload)({ | ||
events: events, | ||
state: state | ||
@@ -133,3 +132,2 @@ })); | ||
return buildOnceEmittedFound({ | ||
events: events, | ||
fn: fn, | ||
@@ -154,3 +152,3 @@ state: state | ||
_regenerator.default.mark(function _callee(_ref) { | ||
var events, fn, state, payload; | ||
var fn, state, payload; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
@@ -160,5 +158,4 @@ while (1) { | ||
case 0: | ||
events = _ref.events, fn = _ref.fn, state = _ref.state; | ||
fn = _ref.fn, state = _ref.state; | ||
payload = (0, _payload.buildPayload)({ | ||
events: events, | ||
state: state | ||
@@ -165,0 +162,0 @@ }); |
@@ -21,9 +21,8 @@ "use strict"; | ||
state = _ref.state; | ||
var events = state.events, | ||
_state$extras = state.extras, | ||
extras = _state$extras === void 0 ? [] : _state$extras, | ||
var _state$args = state.args, | ||
args = _state$args === void 0 ? [] : _state$args, | ||
events = state.events, | ||
op = state.op, | ||
_state$options = state.options, | ||
options = _state$options === void 0 ? {} : _state$options, | ||
props = state.props, | ||
propsArray = state.propsArray; | ||
@@ -34,7 +33,6 @@ | ||
event: { | ||
extras: extras, | ||
args: args, | ||
op: op, | ||
options: options, | ||
props: props, | ||
propsArray: propsArray, | ||
props: propsArray, | ||
signal: {} | ||
@@ -44,21 +42,19 @@ } | ||
} else { | ||
var prevEvent = opts.event || {}; | ||
var prevExtras = prevEvent.extras || []; | ||
var emitEvent = opts.event || {}; | ||
var emitArgs = emitEvent.args || []; | ||
var wildcardVar = (0, _props.propVar)({ | ||
listenPropsArray: prevEvent.propsArray, | ||
emitPropsArray: emitEvent.props, | ||
propsArray: propsArray | ||
}); | ||
var nextExtras = prevExtras.concat(extras); | ||
var prevOptions = prevEvent.options || {}; | ||
var nextOptions = Object.assign({}, prevOptions, options, wildcardVar); | ||
return (0, _objectSpread4.default)({}, nextOptions, (0, _defineProperty2.default)({ | ||
var emitOptions = emitEvent.options || {}; | ||
var newOptions = Object.assign({}, emitOptions, options, wildcardVar); | ||
return (0, _objectSpread4.default)({}, newOptions, (0, _defineProperty2.default)({ | ||
event: { | ||
extras: nextExtras.length ? nextExtras : undefined, | ||
listenProps: props, | ||
listenPropsArray: propsArray, | ||
op: prevEvent.op, | ||
options: Object.keys(nextOptions).length ? nextOptions : undefined, | ||
props: prevEvent.props, | ||
propsArray: prevEvent.propsArray, | ||
signal: prevEvent.signal | ||
args: emitArgs.length ? emitArgs : undefined, | ||
listenArgs: args.length ? args : undefined, | ||
listenProps: propsArray, | ||
op: emitEvent.op, | ||
options: Object.keys(newOptions).length ? newOptions : undefined, | ||
props: emitEvent.props, | ||
signal: emitEvent.signal | ||
} | ||
@@ -65,0 +61,0 @@ }, events.name, events)); |
@@ -45,3 +45,3 @@ "use strict"; | ||
function propVar(_ref) { | ||
var listenPropsArray = _ref.listenPropsArray, | ||
var emitPropsArray = _ref.emitPropsArray, | ||
propsArray = _ref.propsArray; | ||
@@ -61,3 +61,3 @@ | ||
if (match) { | ||
propVar[match[1]] = listenPropsArray[index]; | ||
propVar[match[1]] = emitPropsArray[index]; | ||
} | ||
@@ -64,0 +64,0 @@ |
@@ -10,4 +10,4 @@ // Helpers | ||
const matches = args.reduce(matchArg, { | ||
args: [], | ||
events, | ||
extras: [], | ||
}) | ||
@@ -17,6 +17,2 @@ | ||
matches.extras = matches.extras.length | ||
? matches.extras | ||
: undefined | ||
matches.propsArray = propsArray.length | ||
@@ -52,3 +48,3 @@ ? propsArray | ||
memo.extras.push(arg) | ||
memo.args.push(arg) | ||
} | ||
@@ -55,0 +51,0 @@ |
@@ -33,3 +33,3 @@ import { initState } from "./args" | ||
if (found) { | ||
fn(buildPayload({ events, state })) | ||
fn(buildPayload({ state })) | ||
} | ||
@@ -67,3 +67,3 @@ | ||
if (found) { | ||
return buildOnceEmittedFound({ events, fn, state }) | ||
return buildOnceEmittedFound({ fn, state }) | ||
} else { | ||
@@ -74,8 +74,4 @@ return once({ state, type }) | ||
async function buildOnceEmittedFound({ | ||
events, | ||
fn, | ||
state, | ||
}) { | ||
const payload = buildPayload({ events, state }) | ||
async function buildOnceEmittedFound({ fn, state }) { | ||
const payload = buildPayload({ state }) | ||
await fn(payload) | ||
@@ -82,0 +78,0 @@ return payload |
@@ -5,7 +5,6 @@ import { propVar } from "./props" | ||
const { | ||
args = [], | ||
events, | ||
extras = [], | ||
op, | ||
options = {}, | ||
props, | ||
propsArray, | ||
@@ -18,7 +17,6 @@ } = state | ||
event: { | ||
extras, | ||
args, | ||
op, | ||
options, | ||
props, | ||
propsArray, | ||
props: propsArray, | ||
signal: {}, | ||
@@ -29,16 +27,15 @@ }, | ||
} else { | ||
const prevEvent = opts.event || {} | ||
const prevExtras = prevEvent.extras || [] | ||
const emitEvent = opts.event || {} | ||
const emitArgs = emitEvent.args || [] | ||
const wildcardVar = propVar({ | ||
listenPropsArray: prevEvent.propsArray, | ||
emitPropsArray: emitEvent.props, | ||
propsArray, | ||
}) | ||
const nextExtras = prevExtras.concat(extras) | ||
const prevOptions = prevEvent.options || {} | ||
const emitOptions = emitEvent.options || {} | ||
const nextOptions = Object.assign( | ||
const newOptions = Object.assign( | ||
{}, | ||
prevOptions, | ||
emitOptions, | ||
options, | ||
@@ -49,14 +46,13 @@ wildcardVar | ||
return { | ||
...nextOptions, | ||
...newOptions, | ||
event: { | ||
extras: nextExtras.length ? nextExtras : undefined, | ||
listenProps: props, | ||
listenPropsArray: propsArray, | ||
op: prevEvent.op, | ||
options: Object.keys(nextOptions).length | ||
? nextOptions | ||
args: emitArgs.length ? emitArgs : undefined, | ||
listenArgs: args.length ? args : undefined, | ||
listenProps: propsArray, | ||
op: emitEvent.op, | ||
options: Object.keys(newOptions).length | ||
? newOptions | ||
: undefined, | ||
props: prevEvent.props, | ||
propsArray: prevEvent.propsArray, | ||
signal: prevEvent.signal, | ||
props: emitEvent.props, | ||
signal: emitEvent.signal, | ||
}, | ||
@@ -63,0 +59,0 @@ [events.name]: events, |
@@ -28,3 +28,3 @@ // Constants | ||
export function propVar({ listenPropsArray, propsArray }) { | ||
export function propVar({ emitPropsArray, propsArray }) { | ||
if (!propsArray) { | ||
@@ -39,3 +39,3 @@ return | ||
if (match) { | ||
propVar[match[1]] = listenPropsArray[index] | ||
propVar[match[1]] = emitPropsArray[index] | ||
} | ||
@@ -42,0 +42,0 @@ |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "0.5.0", | ||
"version": "0.6.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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
104621
1872