Comparing version 1.0.1 to 1.1.0
@@ -174,3 +174,6 @@ "use strict"; | ||
}); | ||
var multiOutput = (0, _multi.multi)(state); | ||
var multiOutput = (0, _multi.multi)({ | ||
fn: on, | ||
state: state | ||
}); | ||
@@ -197,3 +200,6 @@ if (multiOutput) { | ||
}); | ||
var multiOutput = (0, _multi.multi)(state); | ||
var multiOutput = (0, _multi.multi)({ | ||
fn: onEmitted, | ||
state: state | ||
}); | ||
@@ -231,3 +237,6 @@ if (multiOutput) { | ||
}); | ||
var multiOutput = (0, _multi.multi)(state); | ||
var multiOutput = (0, _multi.multi)({ | ||
fn: once, | ||
state: state | ||
}); | ||
@@ -254,3 +263,6 @@ if (multiOutput) { | ||
}); | ||
var multiOutput = (0, _multi.multi)(state); | ||
var multiOutput = (0, _multi.multi)({ | ||
fn: onceEmitted, | ||
state: state | ||
}); | ||
@@ -257,0 +269,0 @@ if (multiOutput) { |
@@ -18,4 +18,2 @@ "use strict"; | ||
function contextComposer() { | ||
var _this = this; | ||
var opts = this; | ||
@@ -55,33 +53,2 @@ return { | ||
})), | ||
setOps: function setOps() { | ||
for (var _len = arguments.length, ops = new Array(_len), _key = 0; _key < _len; _key++) { | ||
ops[_key] = arguments[_key]; | ||
} | ||
for (var _i = 0; _i < ops.length; _i++) { | ||
var op = ops[_i]; | ||
(0, _op.opBase)({ | ||
op: op, | ||
options: opts | ||
}); | ||
} | ||
return _this; | ||
}, | ||
setSyncOps: function setSyncOps() { | ||
for (var _len2 = arguments.length, ops = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
ops[_key2] = arguments[_key2]; | ||
} | ||
for (var _i2 = 0; _i2 < ops.length; _i2++) { | ||
var op = ops[_i2]; | ||
(0, _op.opBase)({ | ||
op: op, | ||
options: opts, | ||
sync: true | ||
}); | ||
} | ||
return _this; | ||
}, | ||
withOp: function withOp(op) { | ||
@@ -88,0 +55,0 @@ (0, _op.opBase)({ |
@@ -20,2 +20,4 @@ "use strict"; | ||
var _op = require("./op"); | ||
var _util = require("./util"); | ||
@@ -82,2 +84,41 @@ | ||
(0, _createClass2.default)(Events, [{ | ||
key: "setOps", | ||
value: function setOps() { | ||
for (var _len = arguments.length, ops = new Array(_len), _key = 0; _key < _len; _key++) { | ||
ops[_key] = arguments[_key]; | ||
} | ||
for (var _i = 0; _i < ops.length; _i++) { | ||
var op = ops[_i]; | ||
(0, _op.opBase)({ | ||
op: op, | ||
options: { | ||
events: this | ||
} | ||
}); | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: "setSyncOps", | ||
value: function setSyncOps() { | ||
for (var _len2 = arguments.length, ops = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
ops[_key2] = arguments[_key2]; | ||
} | ||
for (var _i2 = 0; _i2 < ops.length; _i2++) { | ||
var op = ops[_i2]; | ||
(0, _op.opBase)({ | ||
op: op, | ||
options: { | ||
events: this | ||
}, | ||
sync: true | ||
}); | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: "setName", | ||
@@ -84,0 +125,0 @@ value: function setName(newName) { |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -14,15 +12,19 @@ | ||
var builders = _interopRequireWildcard(require("./build")); | ||
var _util = require("./util"); | ||
function multi(options) { | ||
if (options.props && options.fn || !options.args) { | ||
function multi(_ref) { | ||
var fn = _ref.fn, | ||
state = _ref.state; | ||
if (state.props && state.fn || !state.args) { | ||
return; | ||
} | ||
var arg = options.args[0]; | ||
var arg = state.args[0]; | ||
if ((0, _util.isObject)(arg)) { | ||
var offs = Object.keys(arg).map(multiMap.bind(options)); | ||
var offs = Object.keys(arg).map(multiMap.bind({ | ||
fn: fn, | ||
state: state | ||
})); | ||
return multiOff.bind({ | ||
@@ -35,6 +37,7 @@ offs: offs | ||
function multiMap(props) { | ||
var name = this.name; | ||
return builders[name].call((0, _objectSpread2.default)({}, this, { | ||
var fn = this.fn, | ||
state = this.state; | ||
return fn.call((0, _objectSpread2.default)({}, state, { | ||
args: undefined, | ||
fn: this.args[0][props], | ||
fn: state.args[0][props], | ||
props: props | ||
@@ -41,0 +44,0 @@ })); |
@@ -82,3 +82,3 @@ import { initState } from "./args" | ||
const state = initState({ args, options: this }) | ||
const multiOutput = multi(state) | ||
const multiOutput = multi({ fn: on, state }) | ||
@@ -95,3 +95,3 @@ if (multiOutput) { | ||
const state = initState({ args, options: this }) | ||
const multiOutput = multi(state) | ||
const multiOutput = multi({ fn: onEmitted, state }) | ||
@@ -114,3 +114,3 @@ if (multiOutput) { | ||
const state = initState({ args, options: this }) | ||
const multiOutput = multi(state) | ||
const multiOutput = multi({ fn: once, state }) | ||
@@ -127,3 +127,3 @@ if (multiOutput) { | ||
const state = initState({ args, options: this }) | ||
const multiOutput = multi(state) | ||
const multiOutput = multi({ fn: onceEmitted, state }) | ||
@@ -130,0 +130,0 @@ if (multiOutput) { |
@@ -54,16 +54,2 @@ import { opBase } from "./op" | ||
setOps: (...ops) => { | ||
for (const op of ops) { | ||
opBase({ op, options: opts }) | ||
} | ||
return this | ||
}, | ||
setSyncOps: (...ops) => { | ||
for (const op of ops) { | ||
opBase({ op, options: opts, sync: true }) | ||
} | ||
return this | ||
}, | ||
withOp: op => { | ||
@@ -70,0 +56,0 @@ opBase({ op, options: opts }) |
@@ -5,2 +5,3 @@ // Helpers | ||
import { debug } from "./debug" | ||
import { opBase } from "./op" | ||
import { isObject } from "./util" | ||
@@ -38,2 +39,16 @@ | ||
setOps(...ops) { | ||
for (const op of ops) { | ||
opBase({ op, options: { events: this } }) | ||
} | ||
return this | ||
} | ||
setSyncOps(...ops) { | ||
for (const op of ops) { | ||
opBase({ op, options: { events: this }, sync: true }) | ||
} | ||
return this | ||
} | ||
setName(newName) { | ||
@@ -40,0 +55,0 @@ this.name = newName |
@@ -1,14 +0,13 @@ | ||
import * as builders from "./build" | ||
import { isObject } from "./util" | ||
export function multi(options) { | ||
if ((options.props && options.fn) || !options.args) { | ||
export function multi({ fn, state }) { | ||
if ((state.props && state.fn) || !state.args) { | ||
return | ||
} | ||
const arg = options.args[0] | ||
const arg = state.args[0] | ||
if (isObject(arg)) { | ||
const offs = Object.keys(arg).map( | ||
multiMap.bind(options) | ||
multiMap.bind({ fn, state }) | ||
) | ||
@@ -20,8 +19,8 @@ return multiOff.bind({ offs }) | ||
function multiMap(props) { | ||
const { name } = this | ||
const { fn, state } = this | ||
return builders[name].call({ | ||
...this, | ||
return fn.call({ | ||
...state, | ||
args: undefined, | ||
fn: this.args[0][props], | ||
fn: state.args[0][props], | ||
props, | ||
@@ -28,0 +27,0 @@ }) |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "1.0.1", | ||
"version": "1.1.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
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
111238
2069