effects-as-data
Advanced tools
Comparing version 3.0.13 to 3.0.14
@@ -60,2 +60,31 @@ "use strict"; | ||
function call(fn) { | ||
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
args[_key3 - 1] = arguments[_key3]; | ||
} | ||
return promisify(fn).apply(undefined, args); | ||
} | ||
function doCmd(cmd) { | ||
return promisify( /*#__PURE__*/regeneratorRuntime.mark(function doCmd() { | ||
return regeneratorRuntime.wrap(function doCmd$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return cmd; | ||
case 2: | ||
return _context.abrupt("return", _context.sent); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, doCmd, this); | ||
}))(); | ||
} | ||
function setContext(c) { | ||
@@ -95,6 +124,8 @@ context = c; | ||
module.exports = Object.assign({}, coreCmds, { | ||
module.exports = { | ||
cmds: coreCmds, | ||
interpreters: coreInterpreters, | ||
promisify: promisify, | ||
call: call, | ||
doCmd: doCmd, | ||
setContext: setContext, | ||
@@ -108,3 +139,3 @@ getContext: getContext, | ||
onError: onError | ||
}); | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -6,5 +6,5 @@ "use strict"; | ||
var _require = require("../index"), | ||
promisify = _require.promisify, | ||
call = _require.call, | ||
echo = _require.echo, | ||
promisify = _require.promisify, | ||
doCmd = _require.doCmd, | ||
setContext = _require.setContext, | ||
@@ -19,2 +19,5 @@ getContext = _require.getContext, | ||
var _require2 = require("../index"), | ||
cmds = _require2.cmds; | ||
test("promisify should tag function", async function () { | ||
@@ -29,3 +32,3 @@ var _marked = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
_context.next = 2; | ||
return echo(message); | ||
return cmds.echo(message); | ||
@@ -54,3 +57,3 @@ case 2: | ||
_context2.next = 2; | ||
return echo(message); | ||
return cmds.echo(message); | ||
@@ -79,3 +82,3 @@ case 2: | ||
_context3.next = 2; | ||
return echo(message); | ||
return cmds.echo(message); | ||
@@ -105,3 +108,3 @@ case 2: | ||
_context4.next = 2; | ||
return echo(message); | ||
return cmds.echo(message); | ||
@@ -150,5 +153,4 @@ case 2: | ||
test("call should call effects-as-data function", async function () { | ||
var _marked6 = /*#__PURE__*/regeneratorRuntime.mark(test1), | ||
_marked7 = /*#__PURE__*/regeneratorRuntime.mark(test2); | ||
test("call should call a function", async function () { | ||
var _marked6 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
@@ -161,3 +163,3 @@ function test1(message) { | ||
_context6.next = 2; | ||
return call(test2, message); | ||
return cmds.echo(message); | ||
@@ -175,4 +177,17 @@ case 2: | ||
function test2(message) { | ||
return regeneratorRuntime.wrap(function test2$(_context7) { | ||
var result = await call(test1, "foo"); | ||
expect(result).toEqual("foo"); | ||
}); | ||
test("doCmd should process a command", async function () { | ||
var result = await doCmd(cmds.echo("foo")); | ||
expect(result).toEqual("foo"); | ||
}); | ||
test("cmds.call should call effects-as-data function", async function () { | ||
var _marked7 = /*#__PURE__*/regeneratorRuntime.mark(test1), | ||
_marked8 = /*#__PURE__*/regeneratorRuntime.mark(test2); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context7) { | ||
while (1) { | ||
@@ -182,3 +197,3 @@ switch (_context7.prev = _context7.next) { | ||
_context7.next = 2; | ||
return echo(message); | ||
return cmds.call(test2, message); | ||
@@ -196,2 +211,21 @@ case 2: | ||
function test2(message) { | ||
return regeneratorRuntime.wrap(function test2$(_context8) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
_context8.next = 2; | ||
return cmds.echo(message); | ||
case 2: | ||
return _context8.abrupt("return", _context8.sent); | ||
case 3: | ||
case "end": | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _marked8, this); | ||
} | ||
var result = await promisify(test1)("foo"); | ||
@@ -201,29 +235,29 @@ expect(result).toEqual("foo"); | ||
test("[error handling] call should call effects-as-data function", async function () { | ||
var _marked8 = /*#__PURE__*/regeneratorRuntime.mark(test1), | ||
_marked9 = /*#__PURE__*/regeneratorRuntime.mark(test2); | ||
test("[error handling] cmds.call should call effects-as-data function", async function () { | ||
var _marked9 = /*#__PURE__*/regeneratorRuntime.mark(test1), | ||
_marked10 = /*#__PURE__*/regeneratorRuntime.mark(test2); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context8) { | ||
return regeneratorRuntime.wrap(function test1$(_context9) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
_context8.next = 2; | ||
return call(test2, message); | ||
_context9.next = 2; | ||
return cmds.call(test2, message); | ||
case 2: | ||
return _context8.abrupt("return", _context8.sent); | ||
return _context9.abrupt("return", _context9.sent); | ||
case 3: | ||
case "end": | ||
return _context8.stop(); | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _marked8, this); | ||
}, _marked9, this); | ||
} | ||
function test2(message) { | ||
return regeneratorRuntime.wrap(function test2$(_context9) { | ||
return regeneratorRuntime.wrap(function test2$(_context10) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
switch (_context10.prev = _context10.next) { | ||
case 0: | ||
@@ -234,6 +268,6 @@ throw new Error("oops"); | ||
case "end": | ||
return _context9.stop(); | ||
return _context10.stop(); | ||
} | ||
} | ||
}, _marked9, this); | ||
}, _marked10, this); | ||
} | ||
@@ -250,38 +284,38 @@ | ||
test("call should call promisified function", async function () { | ||
var _marked10 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("cmds.call should call promisified function", async function () { | ||
var _marked11 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context10) { | ||
return regeneratorRuntime.wrap(function test1$(_context11) { | ||
while (1) { | ||
switch (_context10.prev = _context10.next) { | ||
switch (_context11.prev = _context11.next) { | ||
case 0: | ||
_context10.next = 2; | ||
return call(test2, message); | ||
_context11.next = 2; | ||
return cmds.call(test2, message); | ||
case 2: | ||
return _context10.abrupt("return", _context10.sent); | ||
return _context11.abrupt("return", _context11.sent); | ||
case 3: | ||
case "end": | ||
return _context10.stop(); | ||
return _context11.stop(); | ||
} | ||
} | ||
}, _marked10, this); | ||
}, _marked11, this); | ||
} | ||
var test2 = promisify( /*#__PURE__*/regeneratorRuntime.mark(function _callee(message) { | ||
return regeneratorRuntime.wrap(function _callee$(_context11) { | ||
return regeneratorRuntime.wrap(function _callee$(_context12) { | ||
while (1) { | ||
switch (_context11.prev = _context11.next) { | ||
switch (_context12.prev = _context12.next) { | ||
case 0: | ||
_context11.next = 2; | ||
return echo(message); | ||
_context12.next = 2; | ||
return cmds.echo(message); | ||
case 2: | ||
return _context11.abrupt("return", _context11.sent); | ||
return _context12.abrupt("return", _context12.sent); | ||
case 3: | ||
case "end": | ||
return _context11.stop(); | ||
return _context12.stop(); | ||
} | ||
@@ -296,28 +330,28 @@ } | ||
test("[error handling] call should call promisified function", async function () { | ||
var _marked11 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("[error handling] cmds.call should call promisified function", async function () { | ||
var _marked12 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context12) { | ||
return regeneratorRuntime.wrap(function test1$(_context13) { | ||
while (1) { | ||
switch (_context12.prev = _context12.next) { | ||
switch (_context13.prev = _context13.next) { | ||
case 0: | ||
_context12.next = 2; | ||
return call(test2, message); | ||
_context13.next = 2; | ||
return cmds.call(test2, message); | ||
case 2: | ||
return _context12.abrupt("return", _context12.sent); | ||
return _context13.abrupt("return", _context13.sent); | ||
case 3: | ||
case "end": | ||
return _context12.stop(); | ||
return _context13.stop(); | ||
} | ||
} | ||
}, _marked11, this); | ||
}, _marked12, this); | ||
} | ||
var test2 = promisify( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(message) { | ||
return regeneratorRuntime.wrap(function _callee2$(_context13) { | ||
return regeneratorRuntime.wrap(function _callee2$(_context14) { | ||
while (1) { | ||
switch (_context13.prev = _context13.next) { | ||
switch (_context14.prev = _context14.next) { | ||
case 0: | ||
@@ -328,3 +362,3 @@ throw new Error("oops"); | ||
case "end": | ||
return _context13.stop(); | ||
return _context14.stop(); | ||
} | ||
@@ -344,38 +378,38 @@ } | ||
test("call.fn should call promisified function", async function () { | ||
var _marked12 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("cmds.call.fn should call promisified function", async function () { | ||
var _marked13 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context14) { | ||
return regeneratorRuntime.wrap(function test1$(_context15) { | ||
while (1) { | ||
switch (_context14.prev = _context14.next) { | ||
switch (_context15.prev = _context15.next) { | ||
case 0: | ||
_context14.next = 2; | ||
return call.fn(test2, message); | ||
_context15.next = 2; | ||
return cmds.call.fn(test2, message); | ||
case 2: | ||
return _context14.abrupt("return", _context14.sent); | ||
return _context15.abrupt("return", _context15.sent); | ||
case 3: | ||
case "end": | ||
return _context14.stop(); | ||
return _context15.stop(); | ||
} | ||
} | ||
}, _marked12, this); | ||
}, _marked13, this); | ||
} | ||
var test2 = promisify( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(message) { | ||
return regeneratorRuntime.wrap(function _callee3$(_context15) { | ||
return regeneratorRuntime.wrap(function _callee3$(_context16) { | ||
while (1) { | ||
switch (_context15.prev = _context15.next) { | ||
switch (_context16.prev = _context16.next) { | ||
case 0: | ||
_context15.next = 2; | ||
return echo(message); | ||
_context16.next = 2; | ||
return cmds.echo(message); | ||
case 2: | ||
return _context15.abrupt("return", _context15.sent); | ||
return _context16.abrupt("return", _context16.sent); | ||
case 3: | ||
case "end": | ||
return _context15.stop(); | ||
return _context16.stop(); | ||
} | ||
@@ -390,28 +424,28 @@ } | ||
test("[error handling] call.fn should call promisified function", async function () { | ||
var _marked13 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("[error handling] cmds.call.fn should call promisified function", async function () { | ||
var _marked14 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context16) { | ||
return regeneratorRuntime.wrap(function test1$(_context17) { | ||
while (1) { | ||
switch (_context16.prev = _context16.next) { | ||
switch (_context17.prev = _context17.next) { | ||
case 0: | ||
_context16.next = 2; | ||
return call.fn(test2, message); | ||
_context17.next = 2; | ||
return cmds.call.fn(test2, message); | ||
case 2: | ||
return _context16.abrupt("return", _context16.sent); | ||
return _context17.abrupt("return", _context17.sent); | ||
case 3: | ||
case "end": | ||
return _context16.stop(); | ||
return _context17.stop(); | ||
} | ||
} | ||
}, _marked13, this); | ||
}, _marked14, this); | ||
} | ||
var test2 = promisify( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(message) { | ||
return regeneratorRuntime.wrap(function _callee4$(_context17) { | ||
return regeneratorRuntime.wrap(function _callee4$(_context18) { | ||
while (1) { | ||
switch (_context17.prev = _context17.next) { | ||
switch (_context18.prev = _context18.next) { | ||
case 0: | ||
@@ -422,3 +456,3 @@ throw new Error("oops"); | ||
case "end": | ||
return _context17.stop(); | ||
return _context18.stop(); | ||
} | ||
@@ -438,22 +472,22 @@ } | ||
test("call.fn should call promise returning function", async function () { | ||
var _marked14 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("cmds.call.fn should call promise returning function", async function () { | ||
var _marked15 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context18) { | ||
return regeneratorRuntime.wrap(function test1$(_context19) { | ||
while (1) { | ||
switch (_context18.prev = _context18.next) { | ||
switch (_context19.prev = _context19.next) { | ||
case 0: | ||
_context18.next = 2; | ||
return call.fn(test2, message); | ||
_context19.next = 2; | ||
return cmds.call.fn(test2, message); | ||
case 2: | ||
return _context18.abrupt("return", _context18.sent); | ||
return _context19.abrupt("return", _context19.sent); | ||
case 3: | ||
case "end": | ||
return _context18.stop(); | ||
return _context19.stop(); | ||
} | ||
} | ||
}, _marked14, this); | ||
}, _marked15, this); | ||
} | ||
@@ -469,22 +503,22 @@ | ||
test("[error handling] call.fn should call promise returning function", async function () { | ||
var _marked15 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("[error handling] cmds.call.fn should call promise returning function", async function () { | ||
var _marked16 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context19) { | ||
return regeneratorRuntime.wrap(function test1$(_context20) { | ||
while (1) { | ||
switch (_context19.prev = _context19.next) { | ||
switch (_context20.prev = _context20.next) { | ||
case 0: | ||
_context19.next = 2; | ||
return call.fn(test2, message); | ||
_context20.next = 2; | ||
return cmds.call.fn(test2, message); | ||
case 2: | ||
return _context19.abrupt("return", _context19.sent); | ||
return _context20.abrupt("return", _context20.sent); | ||
case 3: | ||
case "end": | ||
return _context19.stop(); | ||
return _context20.stop(); | ||
} | ||
} | ||
}, _marked15, this); | ||
}, _marked16, this); | ||
} | ||
@@ -505,22 +539,22 @@ | ||
test("call.fnBound should call promise returning function", async function () { | ||
var _marked16 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("cmds.call.fnBound should call promise returning function", async function () { | ||
var _marked17 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context20) { | ||
return regeneratorRuntime.wrap(function test1$(_context21) { | ||
while (1) { | ||
switch (_context20.prev = _context20.next) { | ||
switch (_context21.prev = _context21.next) { | ||
case 0: | ||
_context20.next = 2; | ||
return call.fnBound(obj, obj.test2, message); | ||
_context21.next = 2; | ||
return cmds.call.fnBound(obj, obj.test2, message); | ||
case 2: | ||
return _context20.abrupt("return", _context20.sent); | ||
return _context21.abrupt("return", _context21.sent); | ||
case 3: | ||
case "end": | ||
return _context20.stop(); | ||
return _context21.stop(); | ||
} | ||
} | ||
}, _marked16, this); | ||
}, _marked17, this); | ||
} | ||
@@ -539,22 +573,22 @@ | ||
test("[error handling] call.fnBound should call promise returning function", async function () { | ||
var _marked17 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("[error handling] cmds.call.fnBound should call promise returning function", async function () { | ||
var _marked18 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context21) { | ||
return regeneratorRuntime.wrap(function test1$(_context22) { | ||
while (1) { | ||
switch (_context21.prev = _context21.next) { | ||
switch (_context22.prev = _context22.next) { | ||
case 0: | ||
_context21.next = 2; | ||
return call.fnBound(obj, obj.test2, message); | ||
_context22.next = 2; | ||
return cmds.call.fnBound(obj, obj.test2, message); | ||
case 2: | ||
return _context21.abrupt("return", _context21.sent); | ||
return _context22.abrupt("return", _context22.sent); | ||
case 3: | ||
case "end": | ||
return _context21.stop(); | ||
return _context22.stop(); | ||
} | ||
} | ||
}, _marked17, this); | ||
}, _marked18, this); | ||
} | ||
@@ -578,22 +612,22 @@ | ||
test("call.callback should call callback function", async function () { | ||
var _marked18 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("cmds.call.callback should call callback function", async function () { | ||
var _marked19 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context22) { | ||
return regeneratorRuntime.wrap(function test1$(_context23) { | ||
while (1) { | ||
switch (_context22.prev = _context22.next) { | ||
switch (_context23.prev = _context23.next) { | ||
case 0: | ||
_context22.next = 2; | ||
return call.callback(test2, message); | ||
_context23.next = 2; | ||
return cmds.call.callback(test2, message); | ||
case 2: | ||
return _context22.abrupt("return", _context22.sent); | ||
return _context23.abrupt("return", _context23.sent); | ||
case 3: | ||
case "end": | ||
return _context22.stop(); | ||
return _context23.stop(); | ||
} | ||
} | ||
}, _marked18, this); | ||
}, _marked19, this); | ||
} | ||
@@ -609,22 +643,22 @@ | ||
test("[error handling] call.callback should call callback function", async function () { | ||
var _marked19 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("[error handling] cmds.call.callback should call callback function", async function () { | ||
var _marked20 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context23) { | ||
return regeneratorRuntime.wrap(function test1$(_context24) { | ||
while (1) { | ||
switch (_context23.prev = _context23.next) { | ||
switch (_context24.prev = _context24.next) { | ||
case 0: | ||
_context23.next = 2; | ||
return call.callback(test2, message); | ||
_context24.next = 2; | ||
return cmds.call.callback(test2, message); | ||
case 2: | ||
return _context23.abrupt("return", _context23.sent); | ||
return _context24.abrupt("return", _context24.sent); | ||
case 3: | ||
case "end": | ||
return _context23.stop(); | ||
return _context24.stop(); | ||
} | ||
} | ||
}, _marked19, this); | ||
}, _marked20, this); | ||
} | ||
@@ -645,22 +679,22 @@ | ||
test("[error handling 2] call.callback should call callback function", async function () { | ||
var _marked20 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("[error handling 2] cmds.call.callback should call callback function", async function () { | ||
var _marked21 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context24) { | ||
return regeneratorRuntime.wrap(function test1$(_context25) { | ||
while (1) { | ||
switch (_context24.prev = _context24.next) { | ||
switch (_context25.prev = _context25.next) { | ||
case 0: | ||
_context24.next = 2; | ||
return call.callback(test2, message); | ||
_context25.next = 2; | ||
return cmds.call.callback(test2, message); | ||
case 2: | ||
return _context24.abrupt("return", _context24.sent); | ||
return _context25.abrupt("return", _context25.sent); | ||
case 3: | ||
case "end": | ||
return _context24.stop(); | ||
return _context25.stop(); | ||
} | ||
} | ||
}, _marked20, this); | ||
}, _marked21, this); | ||
} | ||
@@ -681,22 +715,22 @@ | ||
test("call.callbackBound should call callback function", async function () { | ||
var _marked21 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("cmds.call.callbackBound should call callback function", async function () { | ||
var _marked22 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context25) { | ||
return regeneratorRuntime.wrap(function test1$(_context26) { | ||
while (1) { | ||
switch (_context25.prev = _context25.next) { | ||
switch (_context26.prev = _context26.next) { | ||
case 0: | ||
_context25.next = 2; | ||
return call.callbackBound(obj, obj.test2, message); | ||
_context26.next = 2; | ||
return cmds.call.callbackBound(obj, obj.test2, message); | ||
case 2: | ||
return _context25.abrupt("return", _context25.sent); | ||
return _context26.abrupt("return", _context26.sent); | ||
case 3: | ||
case "end": | ||
return _context25.stop(); | ||
return _context26.stop(); | ||
} | ||
} | ||
}, _marked21, this); | ||
}, _marked22, this); | ||
} | ||
@@ -715,22 +749,22 @@ | ||
test("[error handling] call.callbackBound should call callback function", async function () { | ||
var _marked22 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("[error handling] cmds.call.callbackBound should call callback function", async function () { | ||
var _marked23 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context26) { | ||
return regeneratorRuntime.wrap(function test1$(_context27) { | ||
while (1) { | ||
switch (_context26.prev = _context26.next) { | ||
switch (_context27.prev = _context27.next) { | ||
case 0: | ||
_context26.next = 2; | ||
return call.callbackBound(obj, obj.test2, message); | ||
_context27.next = 2; | ||
return cmds.call.callbackBound(obj, obj.test2, message); | ||
case 2: | ||
return _context26.abrupt("return", _context26.sent); | ||
return _context27.abrupt("return", _context27.sent); | ||
case 3: | ||
case "end": | ||
return _context26.stop(); | ||
return _context27.stop(); | ||
} | ||
} | ||
}, _marked22, this); | ||
}, _marked23, this); | ||
} | ||
@@ -754,22 +788,22 @@ | ||
test("[error handling] call.callbackBound should call callback function", async function () { | ||
var _marked23 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
test("[error handling] cmds.call.callbackBound should call callback function", async function () { | ||
var _marked24 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
function test1(message) { | ||
return regeneratorRuntime.wrap(function test1$(_context27) { | ||
return regeneratorRuntime.wrap(function test1$(_context28) { | ||
while (1) { | ||
switch (_context27.prev = _context27.next) { | ||
switch (_context28.prev = _context28.next) { | ||
case 0: | ||
_context27.next = 2; | ||
return call.callbackBound(obj, obj.test2, message); | ||
_context28.next = 2; | ||
return cmds.call.callbackBound(obj, obj.test2, message); | ||
case 2: | ||
return _context27.abrupt("return", _context27.sent); | ||
return _context28.abrupt("return", _context28.sent); | ||
case 3: | ||
case "end": | ||
return _context27.stop(); | ||
return _context28.stop(); | ||
} | ||
} | ||
}, _marked23, this); | ||
}, _marked24, this); | ||
} | ||
@@ -794,3 +828,3 @@ | ||
test("promisify(fn).callWithContext({...}) should call function with context patch", async function () { | ||
var _marked24 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
var _marked25 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
@@ -809,19 +843,19 @@ setContext({ configProperty: "foo" }); | ||
var result; | ||
return regeneratorRuntime.wrap(function test1$(_context28) { | ||
return regeneratorRuntime.wrap(function test1$(_context29) { | ||
while (1) { | ||
switch (_context28.prev = _context28.next) { | ||
switch (_context29.prev = _context29.next) { | ||
case 0: | ||
_context28.next = 2; | ||
_context29.next = 2; | ||
return { type: "testEffect" }; | ||
case 2: | ||
result = _context28.sent; | ||
return _context28.abrupt("return", "" + result + message); | ||
result = _context29.sent; | ||
return _context29.abrupt("return", "" + result + message); | ||
case 4: | ||
case "end": | ||
return _context28.stop(); | ||
return _context29.stop(); | ||
} | ||
} | ||
}, _marked24, this); | ||
}, _marked25, this); | ||
} | ||
@@ -839,3 +873,3 @@ | ||
test("promisify(fn).callWithContext({...}) should call function with context patch and call validator", async function () { | ||
var _marked25 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
var _marked26 = /*#__PURE__*/regeneratorRuntime.mark(test1); | ||
@@ -854,19 +888,19 @@ setContext({ configProperty: "foo" }); | ||
var result; | ||
return regeneratorRuntime.wrap(function test1$(_context29) { | ||
return regeneratorRuntime.wrap(function test1$(_context30) { | ||
while (1) { | ||
switch (_context29.prev = _context29.next) { | ||
switch (_context30.prev = _context30.next) { | ||
case 0: | ||
_context29.next = 2; | ||
_context30.next = 2; | ||
return { type: "testEffect" }; | ||
case 2: | ||
result = _context29.sent; | ||
return _context29.abrupt("return", "" + result + message); | ||
result = _context30.sent; | ||
return _context30.abrupt("return", "" + result + message); | ||
case 4: | ||
case "end": | ||
return _context29.stop(); | ||
return _context30.stop(); | ||
} | ||
} | ||
}, _marked25, this); | ||
}, _marked26, this); | ||
} | ||
@@ -873,0 +907,0 @@ |
@@ -8,5 +8,6 @@ "use strict"; | ||
var _require2 = require("../index"), | ||
call = _require2.call, | ||
promisify = _require2.promisify; | ||
var call = require("../index").cmds.call; | ||
test("validator get called during unit test", function () { | ||
@@ -13,0 +14,0 @@ var _marked = /*#__PURE__*/regeneratorRuntime.mark(subject); |
{ | ||
"name": "effects-as-data", | ||
"version": "3.0.13", | ||
"version": "3.0.14", | ||
"description": | ||
@@ -5,0 +5,0 @@ "A micro abstraction layer for Javascript that makes writing, testing, and monitoring side-effects easy.", |
@@ -50,2 +50,12 @@ const core = require("./core"); | ||
function call(fn, ...args) { | ||
return promisify(fn)(...args); | ||
} | ||
function doCmd(cmd) { | ||
return promisify(function* doCmd() { | ||
return yield cmd; | ||
})(); | ||
} | ||
function setContext(c) { | ||
@@ -85,6 +95,8 @@ context = c; | ||
module.exports = Object.assign({}, coreCmds, { | ||
module.exports = { | ||
cmds: coreCmds, | ||
interpreters: coreInterpreters, | ||
promisify, | ||
call, | ||
doCmd, | ||
setContext, | ||
@@ -98,2 +110,2 @@ getContext, | ||
onError | ||
}); | ||
}; |
const assert = require("assert"); | ||
const { | ||
promisify, | ||
call, | ||
echo, | ||
promisify, | ||
doCmd, | ||
setContext, | ||
@@ -15,6 +15,7 @@ getContext, | ||
} = require("../index"); | ||
const { cmds } = require("../index"); | ||
test("promisify should tag function", async () => { | ||
function* test1(message) { | ||
return yield echo(message); | ||
return yield cmds.echo(message); | ||
} | ||
@@ -26,3 +27,3 @@ expect(promisify(test1).eadPromisified).toEqual(true); | ||
function* testName(message) { | ||
return yield echo(message); | ||
return yield cmds.echo(message); | ||
} | ||
@@ -34,3 +35,3 @@ expect(promisify(testName).name).toEqual("testName"); | ||
function* test1(message) { | ||
return yield echo(message); | ||
return yield cmds.echo(message); | ||
} | ||
@@ -43,3 +44,3 @@ const p = promisify(test1); | ||
function* test1(message) { | ||
return yield echo(message); | ||
return yield cmds.echo(message); | ||
} | ||
@@ -65,9 +66,23 @@ | ||
test("call should call effects-as-data function", async () => { | ||
test("call should call a function", async () => { | ||
function* test1(message) { | ||
return yield call(test2, message); | ||
return yield cmds.echo(message); | ||
} | ||
const result = await call(test1, "foo"); | ||
expect(result).toEqual("foo"); | ||
}); | ||
test("doCmd should process a command", async () => { | ||
const result = await doCmd(cmds.echo("foo")); | ||
expect(result).toEqual("foo"); | ||
}); | ||
test("cmds.call should call effects-as-data function", async () => { | ||
function* test1(message) { | ||
return yield cmds.call(test2, message); | ||
} | ||
function* test2(message) { | ||
return yield echo(message); | ||
return yield cmds.echo(message); | ||
} | ||
@@ -79,5 +94,5 @@ | ||
test("[error handling] call should call effects-as-data function", async () => { | ||
test("[error handling] cmds.call should call effects-as-data function", async () => { | ||
function* test1(message) { | ||
return yield call(test2, message); | ||
return yield cmds.call(test2, message); | ||
} | ||
@@ -98,9 +113,9 @@ | ||
test("call should call promisified function", async () => { | ||
test("cmds.call should call promisified function", async () => { | ||
function* test1(message) { | ||
return yield call(test2, message); | ||
return yield cmds.call(test2, message); | ||
} | ||
const test2 = promisify(function*(message) { | ||
return yield echo(message); | ||
return yield cmds.echo(message); | ||
}); | ||
@@ -112,5 +127,5 @@ | ||
test("[error handling] call should call promisified function", async () => { | ||
test("[error handling] cmds.call should call promisified function", async () => { | ||
function* test1(message) { | ||
return yield call(test2, message); | ||
return yield cmds.call(test2, message); | ||
} | ||
@@ -131,9 +146,9 @@ | ||
test("call.fn should call promisified function", async () => { | ||
test("cmds.call.fn should call promisified function", async () => { | ||
function* test1(message) { | ||
return yield call.fn(test2, message); | ||
return yield cmds.call.fn(test2, message); | ||
} | ||
const test2 = promisify(function*(message) { | ||
return yield echo(message); | ||
return yield cmds.echo(message); | ||
}); | ||
@@ -145,5 +160,5 @@ | ||
test("[error handling] call.fn should call promisified function", async () => { | ||
test("[error handling] cmds.call.fn should call promisified function", async () => { | ||
function* test1(message) { | ||
return yield call.fn(test2, message); | ||
return yield cmds.call.fn(test2, message); | ||
} | ||
@@ -164,5 +179,5 @@ | ||
test("call.fn should call promise returning function", async () => { | ||
test("cmds.call.fn should call promise returning function", async () => { | ||
function* test1(message) { | ||
return yield call.fn(test2, message); | ||
return yield cmds.call.fn(test2, message); | ||
} | ||
@@ -178,5 +193,5 @@ | ||
test("[error handling] call.fn should call promise returning function", async () => { | ||
test("[error handling] cmds.call.fn should call promise returning function", async () => { | ||
function* test1(message) { | ||
return yield call.fn(test2, message); | ||
return yield cmds.call.fn(test2, message); | ||
} | ||
@@ -197,5 +212,5 @@ | ||
test("call.fnBound should call promise returning function", async () => { | ||
test("cmds.call.fnBound should call promise returning function", async () => { | ||
function* test1(message) { | ||
return yield call.fnBound(obj, obj.test2, message); | ||
return yield cmds.call.fnBound(obj, obj.test2, message); | ||
} | ||
@@ -214,5 +229,5 @@ | ||
test("[error handling] call.fnBound should call promise returning function", async () => { | ||
test("[error handling] cmds.call.fnBound should call promise returning function", async () => { | ||
function* test1(message) { | ||
return yield call.fnBound(obj, obj.test2, message); | ||
return yield cmds.call.fnBound(obj, obj.test2, message); | ||
} | ||
@@ -236,5 +251,5 @@ | ||
test("call.callback should call callback function", async () => { | ||
test("cmds.call.callback should call callback function", async () => { | ||
function* test1(message) { | ||
return yield call.callback(test2, message); | ||
return yield cmds.call.callback(test2, message); | ||
} | ||
@@ -250,5 +265,5 @@ | ||
test("[error handling] call.callback should call callback function", async () => { | ||
test("[error handling] cmds.call.callback should call callback function", async () => { | ||
function* test1(message) { | ||
return yield call.callback(test2, message); | ||
return yield cmds.call.callback(test2, message); | ||
} | ||
@@ -269,5 +284,5 @@ | ||
test("[error handling 2] call.callback should call callback function", async () => { | ||
test("[error handling 2] cmds.call.callback should call callback function", async () => { | ||
function* test1(message) { | ||
return yield call.callback(test2, message); | ||
return yield cmds.call.callback(test2, message); | ||
} | ||
@@ -288,5 +303,5 @@ | ||
test("call.callbackBound should call callback function", async () => { | ||
test("cmds.call.callbackBound should call callback function", async () => { | ||
function* test1(message) { | ||
return yield call.callbackBound(obj, obj.test2, message); | ||
return yield cmds.call.callbackBound(obj, obj.test2, message); | ||
} | ||
@@ -305,5 +320,5 @@ | ||
test("[error handling] call.callbackBound should call callback function", async () => { | ||
test("[error handling] cmds.call.callbackBound should call callback function", async () => { | ||
function* test1(message) { | ||
return yield call.callbackBound(obj, obj.test2, message); | ||
return yield cmds.call.callbackBound(obj, obj.test2, message); | ||
} | ||
@@ -327,5 +342,5 @@ | ||
test("[error handling] call.callbackBound should call callback function", async () => { | ||
test("[error handling] cmds.call.callbackBound should call callback function", async () => { | ||
function* test1(message) { | ||
return yield call.callbackBound(obj, obj.test2, message); | ||
return yield cmds.call.callbackBound(obj, obj.test2, message); | ||
} | ||
@@ -332,0 +347,0 @@ |
const { testFn, args } = require("../test"); | ||
const { call, promisify } = require("../index"); | ||
const { promisify } = require("../index"); | ||
const { call } = require("../index").cmds; | ||
@@ -4,0 +5,0 @@ test("validator get called during unit test", () => { |
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
708140
8945