Socket
Socket
Sign inDemoInstall

effects-as-data

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

effects-as-data - npm Package Compare versions

Comparing version 2.14.5 to 2.14.6

4

es5/perf/effects/functions/index.js
'use strict';
var _marked = [eadBenchmark].map(regeneratorRuntime.mark);
var _marked = /*#__PURE__*/regeneratorRuntime.mark(eadBenchmark);

@@ -33,3 +33,3 @@ var cmds = require('../cmds');

}
}, _marked[0], this);
}, _marked, this);
}

@@ -36,0 +36,0 @@

@@ -1,12 +0,12 @@

'use strict';
"use strict";
var _require = require('../index'),
var _require = require("../index"),
call = _require.call;
var handlers = require('./effects/handlers');
var handlers = require("./effects/handlers");
var _require2 = require('./effects/functions'),
var _require2 = require("./effects/functions"),
eadBenchmark = _require2.eadBenchmark;
var _require3 = require('./standard'),
var _require3 = require("./standard"),
standardBenchmark = _require3.standardBenchmark;

@@ -17,3 +17,3 @@

var filePath = '/tmp/perf.txt';
var filePath = "/tmp/perf.txt";

@@ -39,3 +39,3 @@ async function testStandard() {

async function test() {
console.log('Please wait while operation runs ' + iterations + ' times...');
console.log("Please wait while operation runs " + iterations + " times...");
var eadLatencies = [];

@@ -46,3 +46,3 @@ var standardLatencies = [];

var percentComplete = percent(i, iterations, 0);
process.stdout.write('\r' + percentComplete + '% Complete');
process.stdout.write("\r" + percentComplete + "% Complete");
}

@@ -71,9 +71,9 @@ var startEad = Date.now();

var percentSlower = ((1 - standardTotal / eadTotal) * 100).toFixed(2);
console.log('\n');
console.log('Results');
console.log('=====================================');
console.log('Effects-as-data total: ' + eadTotal + 'ms');
console.log('Pure Javascript total: ' + standardTotal + 'ms');
console.log('Per transaction, effects-as-data was ' + microSecondsPerTransaction + '\u03BCs slower than pure Javascript.');
console.log('For ' + iterations + ' transactions, effects-as-data was ' + percentSlower + '% / ' + diff + 'ms slower than pure Javascript.');
console.log("\n");
console.log("Results");
console.log("=====================================");
console.log("Effects-as-data total: " + eadTotal + "ms");
console.log("Pure Javascript total: " + standardTotal + "ms");
console.log("Per transaction, effects-as-data was " + microSecondsPerTransaction + "\u03BCs slower than pure Javascript.");
console.log("For " + iterations + " transactions, effects-as-data was " + percentSlower + "% / " + diff + "ms slower than pure Javascript.");
}

@@ -80,0 +80,0 @@

@@ -1,7 +0,7 @@

'use strict';
"use strict";
var _require = require('../index'),
var _require = require("../index"),
call = _require.call;
var _require2 = require('./effects'),
var _require2 = require("./effects"),
functions = _require2.functions,

@@ -13,6 +13,6 @@ handlers = _require2.handlers;

var _require3 = require('./test-util'),
var _require3 = require("./test-util"),
sleep = _require3.sleep;
test('async', async function () {
test("async", async function () {
var called = false;

@@ -19,0 +19,0 @@ var testHandler = function testHandler() {

@@ -1,7 +0,7 @@

'use strict';
"use strict";
var _require = require('../index'),
var _require = require("../index"),
call = _require.call;
var _require2 = require('./effects'),
var _require2 = require("./effects"),
handlers = _require2.handlers,

@@ -18,4 +18,4 @@ functions = _require2.functions;

test('basic', async function () {
var expected = 'foo';
test("basic", async function () {
var expected = "foo";
var actual = await call({}, handlers, basic, expected);

@@ -25,4 +25,4 @@ expect(actual).toEqual(expected);

test('basic should be able to accept array arguments', async function () {
var expected = ['foo', 'bar'];
test("basic should be able to accept array arguments", async function () {
var expected = ["foo", "bar"];
var actual = await call({}, handlers, basic, expected);

@@ -32,26 +32,26 @@ expect(actual).toEqual(expected);

test('basicMultiArg', async function () {
var actual = await call({}, handlers, basicMultiArg, 'foo', 'bar');
expect(actual).toEqual('foobar');
test("basicMultiArg", async function () {
var actual = await call({}, handlers, basicMultiArg, "foo", "bar");
expect(actual).toEqual("foobar");
});
test('basicMultistep', async function () {
var actual = await call({}, handlers, basicMultistep, 'foo');
var expected = { s1: 'foo1', s2: 'foo2' };
test("basicMultistep", async function () {
var actual = await call({}, handlers, basicMultistep, "foo");
var expected = { s1: "foo1", s2: "foo2" };
expect(actual).toEqual(expected);
});
test('basicParallel', async function () {
var actual = await call({}, handlers, basicParallel, 'foo');
var expected = { s1: 'foo1', s2: 'foo2' };
test("basicParallel", async function () {
var actual = await call({}, handlers, basicParallel, "foo");
var expected = { s1: "foo1", s2: "foo2" };
expect(actual).toEqual(expected);
});
test('basicMultistepParallel', async function () {
var actual = await call({}, handlers, basicMultistepParallel, 'foo');
var expected = { s1: 'foo1', s2: 'foo2', s3: 'foo3', s4: 'foo4' };
test("basicMultistepParallel", async function () {
var actual = await call({}, handlers, basicMultistepParallel, "foo");
var expected = { s1: "foo1", s2: "foo2", s3: "foo3", s4: "foo4" };
expect(actual).toEqual(expected);
});
test('basicEmpty', async function () {
test("basicEmpty", async function () {
var expected = [];

@@ -58,0 +58,0 @@ var actual = await call({}, handlers, basicEmpty);

'use strict';
var _marked = [asyncTest].map(regeneratorRuntime.mark);
var _marked = /*#__PURE__*/regeneratorRuntime.mark(asyncTest);

@@ -23,3 +23,3 @@ var cmds = require('../commands');

}
}, _marked[0], this);
}, _marked, this);
}

@@ -26,0 +26,0 @@

@@ -1,8 +0,13 @@

"use strict";
'use strict';
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
var _marked = [basic, basicMultiArg, basicMultistep, basicParallel, basicMultistepParallel, basicEmpty].map(regeneratorRuntime.mark);
var _marked = /*#__PURE__*/regeneratorRuntime.mark(basic),
_marked2 = /*#__PURE__*/regeneratorRuntime.mark(basicMultiArg),
_marked3 = /*#__PURE__*/regeneratorRuntime.mark(basicMultistep),
_marked4 = /*#__PURE__*/regeneratorRuntime.mark(basicParallel),
_marked5 = /*#__PURE__*/regeneratorRuntime.mark(basicMultistepParallel),
_marked6 = /*#__PURE__*/regeneratorRuntime.mark(basicEmpty);
var cmds = require("../commands");
var cmds = require('../commands');

@@ -18,10 +23,10 @@ function basic(message) {

case 2:
return _context.abrupt("return", _context.sent);
return _context.abrupt('return', _context.sent);
case 3:
case "end":
case 'end':
return _context.stop();
}
}
}, _marked[0], this);
}, _marked, this);
}

@@ -38,10 +43,10 @@

case 2:
return _context2.abrupt("return", _context2.sent);
return _context2.abrupt('return', _context2.sent);
case 3:
case "end":
case 'end':
return _context2.stop();
}
}
}, _marked[1], this);
}, _marked2, this);
}

@@ -56,3 +61,3 @@

_context3.next = 2;
return cmds.echo(message + "1");
return cmds.echo(message + '1');

@@ -62,14 +67,14 @@ case 2:

_context3.next = 5;
return cmds.echo(message + "2");
return cmds.echo(message + '2');
case 5:
s2 = _context3.sent;
return _context3.abrupt("return", { s1: s1, s2: s2 });
return _context3.abrupt('return', { s1: s1, s2: s2 });
case 7:
case "end":
case 'end':
return _context3.stop();
}
}
}, _marked[2], this);
}, _marked3, this);
}

@@ -92,13 +97,13 @@

s2 = _ref2[1];
return _context4.abrupt("return", {
s1: s1 + "1",
s2: s2 + "2"
return _context4.abrupt('return', {
s1: s1 + '1',
s2: s2 + '2'
});
case 7:
case "end":
case 'end':
return _context4.stop();
}
}
}, _marked[3], this);
}, _marked4, this);
}

@@ -129,15 +134,15 @@

s4 = _ref6[1];
return _context5.abrupt("return", {
s1: s1 + "1",
s2: s2 + "2",
s3: s3 + "3",
s4: s4 + "4"
return _context5.abrupt('return', {
s1: s1 + '1',
s2: s2 + '2',
s3: s3 + '3',
s4: s4 + '4'
});
case 13:
case "end":
case 'end':
return _context5.stop();
}
}
}, _marked[4], this);
}, _marked5, this);
}

@@ -154,10 +159,10 @@

case 2:
return _context6.abrupt("return", _context6.sent);
return _context6.abrupt('return', _context6.sent);
case 3:
case "end":
case 'end':
return _context6.stop();
}
}
}, _marked[5], this);
}, _marked6, this);
}

@@ -164,0 +169,0 @@

'use strict';
var _marked = [eitherTestError, eitherTestEmpty].map(regeneratorRuntime.mark);
var _marked = /*#__PURE__*/regeneratorRuntime.mark(eitherTestError),
_marked2 = /*#__PURE__*/regeneratorRuntime.mark(eitherTestEmpty);

@@ -23,3 +24,3 @@ var cmds = require('../commands');

}
}, _marked[0], this);
}, _marked, this);
}

@@ -43,3 +44,3 @@

}
}, _marked[1], this);
}, _marked2, this);
}

@@ -46,0 +47,0 @@

'use strict';
var _marked = [functionErrorTest].map(regeneratorRuntime.mark);
var _marked = /*#__PURE__*/regeneratorRuntime.mark(functionErrorTest);

@@ -17,3 +17,3 @@ function functionErrorTest() {

}
}, _marked[0], this);
}, _marked, this);
}

@@ -20,0 +20,0 @@

'use strict';
var _marked = [badHandler, badHandlerRejection, promiseReturningHandler, valueReturningHandler].map(regeneratorRuntime.mark);
var _marked = /*#__PURE__*/regeneratorRuntime.mark(badHandler),
_marked2 = /*#__PURE__*/regeneratorRuntime.mark(badHandlerRejection),
_marked3 = /*#__PURE__*/regeneratorRuntime.mark(promiseReturningHandler),
_marked4 = /*#__PURE__*/regeneratorRuntime.mark(valueReturningHandler);

@@ -23,3 +26,3 @@ var cmds = require('../commands');

}
}, _marked[0], this);
}, _marked, this);
}

@@ -43,3 +46,3 @@

}
}, _marked[1], this);
}, _marked2, this);
}

@@ -63,3 +66,3 @@

}
}, _marked[2], this);
}, _marked3, this);
}

@@ -83,3 +86,3 @@

}
}, _marked[3], this);
}, _marked4, this);
}

@@ -86,0 +89,0 @@

'use strict';
var _marked = [throwAtYield, throwAtYieldRecovery].map(regeneratorRuntime.mark);
var _marked = /*#__PURE__*/regeneratorRuntime.mark(throwAtYield),
_marked2 = /*#__PURE__*/regeneratorRuntime.mark(throwAtYieldRecovery);

@@ -33,3 +34,3 @@ var cmds = require('../commands');

}
}, _marked[0], this, [[0, 5]]);
}, _marked, this, [[0, 5]]);
}

@@ -66,3 +67,3 @@

}
}, _marked[1], this, [[0, 5]]);
}, _marked2, this, [[0, 5]]);
}

@@ -69,0 +70,0 @@

@@ -16,3 +16,3 @@ "use strict";

delay(function () {
call(config, handlers, regeneratorRuntime.mark(function _callee() {
call(config, handlers, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -19,0 +19,0 @@ while (1) {

@@ -10,3 +10,3 @@ "use strict";

return call(config, handlers, regeneratorRuntime.mark(function _callee() {
return call(config, handlers, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var result;

@@ -13,0 +13,0 @@ return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -1,7 +0,7 @@

'use strict';
"use strict";
var _require = require('../index'),
var _require = require("../index"),
call = _require.call;
var _require2 = require('./effects'),
var _require2 = require("./effects"),
handlers = _require2.handlers,

@@ -14,13 +14,13 @@ functions = _require2.functions;

test('call should use either, handle error, and return default value', async function () {
test("call should use either, handle error, and return default value", async function () {
var actual = await call({}, handlers, eitherTestError);
var expected = 'foo';
var expected = "foo";
expect(actual).toEqual(expected);
});
test('call should use either, handle error, and return default value if return value is falsey', async function () {
test("call should use either, handle error, and return default value if return value is falsey", async function () {
var actual = await call({}, handlers, eitherTestEmpty);
var expected = 'foo';
var expected = "foo";
expect(actual).toEqual(expected);
});
//# sourceMappingURL=either.spec.js.map

@@ -51,3 +51,3 @@ "use strict";

test("call should throw error for unregistered handler", async function () {
var fn = regeneratorRuntime.mark(function fn() {
var fn = /*#__PURE__*/regeneratorRuntime.mark(function fn() {
return regeneratorRuntime.wrap(function fn$(_context) {

@@ -54,0 +54,0 @@ while (1) {

@@ -1,7 +0,7 @@

'use strict';
"use strict";
var _require = require('../index'),
var _require = require("../index"),
call = _require.call;
var _require2 = require('./effects'),
var _require2 = require("./effects"),
handlers = _require2.handlers,

@@ -16,39 +16,39 @@ functions = _require2.functions,

var _require3 = require('./test-util'),
var _require3 = require("./test-util"),
expectError = _require3.expectError;
test('handlers should be able to return non-promise values', async function () {
var actual = await call({}, handlers, valueReturningHandler, 'bar');
var expected = 'bar';
test("handlers should be able to return non-promise values", async function () {
var actual = await call({}, handlers, valueReturningHandler, "bar");
var expected = "bar";
expect(actual).toEqual(expected);
});
test('handlers should be able to return promises', async function () {
var actual = await call({}, handlers, promiseReturningHandler, 'bar');
var expected = 'bar';
test("handlers should be able to return promises", async function () {
var actual = await call({}, handlers, promiseReturningHandler, "bar");
var expected = "bar";
expect(actual).toEqual(expected);
});
test('call should reject when a handler throws and is not caught', async function () {
test("call should reject when a handler throws and is not caught", async function () {
try {
await call({}, handlers, badHandler);
} catch (actual) {
var message = 'oops';
var message = "oops";
return expectError(actual, message);
}
fail('Function did not reject.');
fail("Function did not reject.");
});
test('call should reject when a handler rejects and is not caught', async function () {
test("call should reject when a handler rejects and is not caught", async function () {
try {
await call({}, handlers, badHandlerRejection);
} catch (actual) {
var message = 'oops';
var message = "oops";
return expectError(actual, message);
}
fail('Function did not reject.');
fail("Function did not reject.");
});
test('handlers should be able to return an array of results', async function () {
var fn = regeneratorRuntime.mark(function fn(a, b) {
test("handlers should be able to return an array of results", async function () {
var fn = /*#__PURE__*/regeneratorRuntime.mark(function fn(a, b) {
var result;

@@ -64,6 +64,6 @@ return regeneratorRuntime.wrap(function fn$(_context) {

result = _context.sent;
return _context.abrupt('return', result);
return _context.abrupt("return", result);
case 4:
case 'end':
case "end":
return _context.stop();

@@ -74,6 +74,6 @@ }

});
var actual = await call({}, handlers, fn, ['foo', 'bar'], ['foo', 'baz']);
var expected = [['foo', 'bar'], ['foo', 'baz']];
var actual = await call({}, handlers, fn, ["foo", "bar"], ["foo", "baz"]);
var expected = [["foo", "bar"], ["foo", "baz"]];
expect(actual).toEqual(expected);
});
//# sourceMappingURL=handlers.spec.js.map

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,3 +6,3 @@ var assert = require("assert");

function errorToJson(e) {
var props = Object.getOwnPropertyNames(e).concat('name');
var props = Object.getOwnPropertyNames(e).concat("name");
return props.reduce(function (p, c) {

@@ -15,4 +15,4 @@ p[c] = e[c];

function expectError(e1, e2) {
var ne1 = typeof e1 === 'string' ? new Error(e1) : e1;
var ne2 = typeof e2 === 'string' ? new Error(e2) : e2;
var ne1 = typeof e1 === "string" ? new Error(e1) : e1;
var ne2 = typeof e2 === "string" ? new Error(e2) : e2;
var be1 = get(function () {

@@ -19,0 +19,0 @@ return e2.constructor.name;

@@ -1,6 +0,12 @@

'use strict';
"use strict";
var _marked = [singleLine, yieldArray, rethrow, throwFoo, throwImmediately, returnCmdResult, throwSemantic].map(regeneratorRuntime.mark);
var _marked = /*#__PURE__*/regeneratorRuntime.mark(singleLine),
_marked2 = /*#__PURE__*/regeneratorRuntime.mark(yieldArray),
_marked3 = /*#__PURE__*/regeneratorRuntime.mark(rethrow),
_marked4 = /*#__PURE__*/regeneratorRuntime.mark(throwFoo),
_marked5 = /*#__PURE__*/regeneratorRuntime.mark(throwImmediately),
_marked6 = /*#__PURE__*/regeneratorRuntime.mark(returnCmdResult),
_marked7 = /*#__PURE__*/regeneratorRuntime.mark(throwSemantic);
var _require = require('./effects'),
var _require = require("./effects"),
functions = _require.functions,

@@ -20,3 +26,3 @@ cmds = _require.cmds;

var _require2 = require('../test'),
var _require2 = require("../test"),
testFn = _require2.testFn,

@@ -26,3 +32,3 @@ testFnV2 = _require2.testFnV2,

var _require3 = require('./test-util'),
var _require3 = require("./test-util"),
deepEqual = _require3.deepEqual;

@@ -37,14 +43,14 @@

_context.next = 2;
return cmds.httpGet('http://example.com/api/v1/users/' + id);
return cmds.httpGet("http://example.com/api/v1/users/" + id);
case 2:
s1 = _context.sent;
return _context.abrupt('return', s1);
return _context.abrupt("return", s1);
case 4:
case 'end':
case "end":
return _context.stop();
}
}
}, _marked[0], this);
}, _marked, this);
}

@@ -59,14 +65,14 @@

_context2.next = 2;
return [{ type: 'test' }];
return [{ type: "test" }];
case 2:
s1 = _context2.sent;
return _context2.abrupt('return', s1);
return _context2.abrupt("return", s1);
case 4:
case 'end':
case "end":
return _context2.stop();
}
}
}, _marked[1], this);
}, _marked2, this);
}

@@ -84,21 +90,21 @@

_context3.next = 3;
return cmds.echo('foo');
return cmds.echo("foo");
case 3:
return _context3.abrupt('return', _context3.sent);
return _context3.abrupt("return", _context3.sent);
case 6:
_context3.prev = 6;
_context3.t0 = _context3['catch'](0);
throw new Error('bar');
_context3.t0 = _context3["catch"](0);
throw new Error("bar");
case 9:
case 'end':
case "end":
return _context3.stop();
}
}
}, _marked[2], this, [[0, 6]]);
}, _marked3, this, [[0, 6]]);
}
test('testFn should fail if tuples[0][0] is not an array', function () {
test("testFn should fail if tuples[0][0] is not an array", function () {
try {

@@ -110,6 +116,6 @@ testFn(throwFoo, function () {

} catch (e) {
deepEqual(e.message, 'The first argument of the first tuple must be an array representing the arguments of the function.');
deepEqual(e.message, "The first argument of the first tuple must be an array representing the arguments of the function.");
return;
}
throw new Error('Failed: Did not compare error messages');
throw new Error("Failed: Did not compare error messages");
});

@@ -122,13 +128,13 @@

case 0:
throw new Error('foo');
throw new Error("foo");
case 1:
case 'end':
case "end":
return _context4.stop();
}
}
}, _marked[3], this);
}, _marked4, this);
}
test('testFn should fail if the function error is different than the test error', function () {
test("testFn should fail if the function error is different than the test error", function () {
try {

@@ -140,9 +146,9 @@ testFn(throwFoo, function () {

} catch (e) {
deepEqual(e.name, 'Error on Step 1');
deepEqual(e.name, "Error on Step 1");
return;
}
throw new Error('Failed: Did not compare error messages');
throw new Error("Failed: Did not compare error messages");
});
test('should be able to rethrow errors', testFnV2(rethrow, function () {
test("should be able to rethrow errors", testFnV2(rethrow, function () {
// prettier-ignore

@@ -152,3 +158,3 @@ return [[], [cmds.echo('foo'), new Error("whatever")], new Error("bar")];

test('testFn should handle undefined returns for semantic test', testFn(regeneratorRuntime.mark(function _callee() {
test("testFn should handle undefined returns for semantic test", testFn( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context5) {

@@ -158,3 +164,3 @@ while (1) {

case 0:
case 'end':
case "end":
return _context5.stop();

@@ -168,3 +174,3 @@ }

test('testFn should curry', testFn(basic)(function () {
test("testFn should curry", testFn(basic)(function () {
// prettier-ignore

@@ -174,3 +180,3 @@ return [[['foo'], cmds.echo('foo')], ['foo', 'foo']];

test('testFn should pass (basic)', testFn(basic, function () {
test("testFn should pass (basic)", testFn(basic, function () {
// prettier-ignore

@@ -182,3 +188,3 @@ return [[['foo'], cmds.echo('foo')], ['foo', 'foo']];

test('testFn semantic should pass (basic)', testFn(basic, function () {
test("testFn semantic should pass (basic)", testFn(basic, function () {
// prettier-ignore

@@ -188,3 +194,3 @@ return args('foo').yieldCmd(cmds.echo('foo')).yieldReturns('foo').returns('foo');

test('testFnV2 should pass (basic)', testFnV2(basic, function () {
test("testFnV2 should pass (basic)", testFnV2(basic, function () {
// prettier-ignore

@@ -194,3 +200,3 @@ return [['foo'], [cmds.echo('foo'), 'foo'], 'foo'];

test('testFn should pass (basicMultiArg)', testFn(basicMultiArg, function () {
test("testFn should pass (basicMultiArg)", testFn(basicMultiArg, function () {
// prettier-ignore

@@ -202,3 +208,3 @@ return [[['foo', 'bar'], cmds.echo('foobar')], ['foobar', 'foobar']];

test('testFn should pass (basicMultiArg)', testFn(basicMultiArg, function () {
test("testFn should pass (basicMultiArg)", testFn(basicMultiArg, function () {
// prettier-ignore

@@ -208,3 +214,3 @@ return [[['foo', 'bar'], cmds.echo('foobar')], ['foobar', 'foobar']];

test('testFn semantic should pass (basicMultiArg)', testFn(basicMultiArg, function () {
test("testFn semantic should pass (basicMultiArg)", testFn(basicMultiArg, function () {
// prettier-ignore

@@ -214,3 +220,3 @@ return args('foo', 'bar').yieldCmd(cmds.echo('foobar')).yieldReturns('foobar').returns('foobar');

test('testFn semantic should pass (basicMultiArg)', testFnV2(basicMultiArg, function () {
test("testFn semantic should pass (basicMultiArg)", testFnV2(basicMultiArg, function () {
// prettier-ignore

@@ -222,3 +228,3 @@ return [['foo', 'bar'], [cmds.echo('foobar'), 'foobar'], 'foobar'];

test('testFn should pass (basicMultistep)', testFn(basicMultistep, function () {
test("testFn should pass (basicMultistep)", testFn(basicMultistep, function () {
// prettier-ignore

@@ -228,3 +234,3 @@ return [[['foo'], cmds.echo('foo1')], ['foo1', cmds.echo('foo2')], ['foo2', { s1: 'foo1', s2: 'foo2' }]];

test('testFn semantic should pass (basicMultistep)', testFn(basicMultistep, function () {
test("testFn semantic should pass (basicMultistep)", testFn(basicMultistep, function () {
// prettier-ignore

@@ -234,3 +240,3 @@ return args('foo').yieldCmd(cmds.echo('foo1')).yieldReturns('foo1').yieldCmd(cmds.echo('foo2')).yieldReturns('foo2').returns({ s1: 'foo1', s2: 'foo2' });

test('testFnV2 should pass (basicMultistep)', testFnV2(basicMultistep, function () {
test("testFnV2 should pass (basicMultistep)", testFnV2(basicMultistep, function () {
// prettier-ignore

@@ -242,4 +248,4 @@ return [['foo'], [cmds.echo('foo1'), 'foo1'], [cmds.echo('foo2'), 'foo2'], { s1: 'foo1', s2: 'foo2' }];

test('testFn should pass (basicParallel)', testFn(basicParallel, function () {
var c = [cmds.echo('foo'), cmds.echo('foo')];
test("testFn should pass (basicParallel)", testFn(basicParallel, function () {
var c = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -249,4 +255,4 @@ return [[['foo'], c], [['foo', 'foo'], { s1: 'foo1', s2: 'foo2' }]];

test('testFn semantic should pass (basicParallel)', testFn(basicParallel, function () {
var c = [cmds.echo('foo'), cmds.echo('foo')];
test("testFn semantic should pass (basicParallel)", testFn(basicParallel, function () {
var c = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -256,4 +262,4 @@ return args('foo').yieldCmd(c).yieldReturns(['foo', 'foo']).returns({ s1: 'foo1', s2: 'foo2' });

test('testFnV2 should pass (basicParallel)', testFnV2(basicParallel, function () {
var c = [cmds.echo('foo'), cmds.echo('foo')];
test("testFnV2 should pass (basicParallel)", testFnV2(basicParallel, function () {
var c = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -265,5 +271,5 @@ return [['foo'], [c, ['foo', 'foo']], { s1: 'foo1', s2: 'foo2' }];

test('testFn should pass (basicMultistepParallel)', testFn(basicMultistepParallel, function () {
var c1 = [cmds.echo('foo'), cmds.echo('foo')];
var c2 = [cmds.echo('foo'), cmds.echo('foo')];
test("testFn should pass (basicMultistepParallel)", testFn(basicMultistepParallel, function () {
var c1 = [cmds.echo("foo"), cmds.echo("foo")];
var c2 = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -273,5 +279,5 @@ return [[['foo'], c1], [['foo', 'foo'], c2], [['foo', 'foo'], { s1: 'foo1', s2: 'foo2', s3: 'foo3', s4: 'foo4' }]];

test('testFn semantic should pass (basicMultistepParallel)', testFn(basicMultistepParallel, function () {
var c1 = [cmds.echo('foo'), cmds.echo('foo')];
var c2 = [cmds.echo('foo'), cmds.echo('foo')];
test("testFn semantic should pass (basicMultistepParallel)", testFn(basicMultistepParallel, function () {
var c1 = [cmds.echo("foo"), cmds.echo("foo")];
var c2 = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -281,5 +287,5 @@ return args('foo').yieldCmd(c1).yieldReturns(['foo', 'foo']).yieldCmd(c2).yieldReturns(['foo', 'foo']).returns({ s1: 'foo1', s2: 'foo2', s3: 'foo3', s4: 'foo4' });

test('testFnV2 should pass (basicMultistepParallel)', testFnV2(basicMultistepParallel, function () {
var c1 = [cmds.echo('foo'), cmds.echo('foo')];
var c2 = [cmds.echo('foo'), cmds.echo('foo')];
test("testFnV2 should pass (basicMultistepParallel)", testFnV2(basicMultistepParallel, function () {
var c1 = [cmds.echo("foo"), cmds.echo("foo")];
var c2 = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -291,3 +297,3 @@ return [['foo'], [c1, ['foo', 'foo']], [c2, ['foo', 'foo']], { s1: 'foo1', s2: 'foo2', s3: 'foo3', s4: 'foo4' }];

test('testFn should pass (basicEmpty)', testFn(basicEmpty, function () {
test("testFn should pass (basicEmpty)", testFn(basicEmpty, function () {
// prettier-ignore

@@ -297,3 +303,3 @@ return [[[null], []], [[], []]];

test('testFn semantic should pass (basicEmpty)', testFn(basicEmpty, function () {
test("testFn semantic should pass (basicEmpty)", testFn(basicEmpty, function () {
// prettier-ignore

@@ -303,3 +309,3 @@ return args(null).yieldCmd([]).yieldReturns([]).returns([]);

test('testFnV2 should pass (basicEmpty)', testFnV2(basicEmpty, function () {
test("testFnV2 should pass (basicEmpty)", testFnV2(basicEmpty, function () {
// prettier-ignore

@@ -311,3 +317,3 @@ return [[null], [[], []], []];

test('testFn should pass (eitherTestError)', testFn(eitherTestError, function () {
test("testFn should pass (eitherTestError)", testFn(eitherTestError, function () {
// prettier-ignore

@@ -317,3 +323,3 @@ return [[[null], cmds.either(cmds.die('oops'), 'foo')], ['foo', 'foo']];

test('testFn semantic should pass (eitherTestError)', testFn(eitherTestError, function () {
test("testFn semantic should pass (eitherTestError)", testFn(eitherTestError, function () {
// prettier-ignore

@@ -323,3 +329,3 @@ return args(null).yieldCmd(cmds.either(cmds.die('oops'), 'foo')).yieldReturns('foo').returns('foo');

test('testFnV2 semantic should pass (eitherTestError)', testFnV2(eitherTestError, function () {
test("testFnV2 semantic should pass (eitherTestError)", testFnV2(eitherTestError, function () {
// prettier-ignore

@@ -331,3 +337,3 @@ return [[null], [cmds.either(cmds.die('oops'), 'foo'), 'foo'], 'foo'];

test('testFn should handle errors (badHandler)', testFn(badHandler, function () {
test("testFn should handle errors (badHandler)", testFn(badHandler, function () {
// prettier-ignore

@@ -337,3 +343,3 @@ return [[[null], cmds.die('oops')], [new Error('oops!'), new Error('oops!')]];

test('testFn semantic should handle errors (badHandler)', testFn(badHandler, function () {
test("testFn semantic should handle errors (badHandler)", testFn(badHandler, function () {
// prettier-ignore

@@ -343,3 +349,3 @@ return args([null]).yieldCmd(cmds.die('oops')).yieldReturns(new Error('oops!')).returns(new Error('oops!'));

test('testFn semantic should handle errors using yieldThrows and throws (badHandler)', testFn(badHandler, function () {
test("testFn semantic should handle errors using yieldThrows and throws (badHandler)", testFn(badHandler, function () {
// prettier-ignore

@@ -354,13 +360,13 @@ return args([null]).yieldCmd(cmds.die('oops')).yieldThrows(new Error('oops!')).throws(new Error('oops!'));

case 0:
throw new Error('oops!');
throw new Error("oops!");
case 1:
case 'end':
case "end":
return _context6.stop();
}
}
}, _marked[4], this);
}, _marked5, this);
}
test('testFn semantic should handle errors thrown immediately', testFn(throwImmediately, function () {
test("testFn semantic should handle errors thrown immediately", testFn(throwImmediately, function () {
// prettier-ignore

@@ -370,3 +376,3 @@ return args().throws(new Error('oops!'));

test('testFn semantic should handle errors without returns (badHandler)', testFn(badHandler, function () {
test("testFn semantic should handle errors without returns (badHandler)", testFn(badHandler, function () {
// prettier-ignore

@@ -376,3 +382,3 @@ return args([null]).yieldCmd(cmds.die('oops')).throws(new Error('oops!'));

test('testFnV2 should handle errors (badHandler)', testFnV2(badHandler, function () {
test("testFnV2 should handle errors (badHandler)", testFnV2(badHandler, function () {
// prettier-ignore

@@ -384,3 +390,3 @@ return [[null], [cmds.die('oops'), new Error('oops!')], new Error('oops!')];

test('testFn should pass (eitherTestEmpty)', testFn(eitherTestEmpty, function () {
test("testFn should pass (eitherTestEmpty)", testFn(eitherTestEmpty, function () {
// prettier-ignore

@@ -390,3 +396,3 @@ return [[[null], cmds.either(cmds.echo(null), 'foo')], ['foo', 'foo']];

test('testFn semantic should pass (eitherTestEmpty)', testFn(eitherTestEmpty, function () {
test("testFn semantic should pass (eitherTestEmpty)", testFn(eitherTestEmpty, function () {
// prettier-ignore

@@ -396,3 +402,3 @@ return args(null).yieldCmd(cmds.either(cmds.echo(null), 'foo')).yieldReturns('foo').returns('foo');

test('testFnV2 should pass (eitherTestEmpty)', testFnV2(eitherTestEmpty, function () {
test("testFnV2 should pass (eitherTestEmpty)", testFnV2(eitherTestEmpty, function () {
// prettier-ignore

@@ -404,3 +410,3 @@ return [[null], [cmds.either(cmds.echo(null), 'foo'), 'foo'], 'foo'];

test('testFn should pass (asyncTest)', testFn(asyncTest, function () {
test("testFn should pass (asyncTest)", testFn(asyncTest, function () {
// prettier-ignore

@@ -410,3 +416,3 @@ return [[[null], cmds.async({ type: 'test' })], [null, null]];

test('testFn semantic should pass (asyncTest)', testFn(asyncTest, function () {
test("testFn semantic should pass (asyncTest)", testFn(asyncTest, function () {
// prettier-ignore

@@ -416,3 +422,3 @@ return args(null).yieldCmd(cmds.async({ type: 'test' })).yieldReturns(null).returns(null);

test('testFnV2 should pass (asyncTest)', testFnV2(asyncTest, function () {
test("testFnV2 should pass (asyncTest)", testFnV2(asyncTest, function () {
// prettier-ignore

@@ -431,16 +437,16 @@ return [[null], [cmds.async({ type: 'test' }), null], null];

_context7.next = 2;
return cmds.echo('foo');
return cmds.echo("foo");
case 2:
return _context7.abrupt('return', _context7.sent);
return _context7.abrupt("return", _context7.sent);
case 3:
case 'end':
case "end":
return _context7.stop();
}
}
}, _marked[5], this);
}, _marked6, this);
}
test('testFn semantic should return cmd result', testFn(returnCmdResult, function () {
test("testFn semantic should return cmd result", testFn(returnCmdResult, function () {
// prettier-ignore

@@ -459,17 +465,17 @@ return args().yieldCmd(cmds.echo('foo')).returns("foo");

_context8.next = 2;
return cmds.echo('foo');
return cmds.echo("foo");
case 2:
value = _context8.sent;
throw new Error('oops');
throw new Error("oops");
case 4:
case 'end':
case "end":
return _context8.stop();
}
}
}, _marked[6], this);
}, _marked7, this);
}
test('testFn semantic should throw if .throws is used', testFn(throwSemantic, function () {
test("testFn semantic should throw if .throws is used", testFn(throwSemantic, function () {
// prettier-ignore

@@ -479,3 +485,3 @@ return args().yieldCmd(cmds.echo('foo')).yieldReturns('foo').throws(new Error("oops"));

test('testFn should throw proper error if function throws incorrect error', function () {
test("testFn should throw proper error if function throws incorrect error", function () {
try {

@@ -487,6 +493,6 @@ testFn(throwSemantic, function () {

} catch (e) {
deepEqual(e.name, 'Error on Step 2');
deepEqual(e.name, "Error on Step 2");
return;
}
throw new Error('Failed: Did not throw');
throw new Error("Failed: Did not throw");
});

@@ -496,3 +502,3 @@

test('single line should pass', testSingleLine(function () {
test("single line should pass", testSingleLine(function () {
// prettier-ignore

@@ -502,3 +508,3 @@ return [[['123'], cmds.httpGet('http://example.com/api/v1/users/123')], [{ foo: 'bar' }, { foo: 'bar' }]];

test('testFn semantic single line should not fail', testSingleLine(function () {
test("testFn semantic single line should not fail", testSingleLine(function () {
// prettier-ignore

@@ -508,3 +514,3 @@ return args('123').yieldCmd(cmds.httpGet('http://example.com/api/v1/users/123')).yieldReturns({ foo: 'bar' }).returns({ foo: 'bar' });

test('testFn should give proper error message if yielding array but no results', function () {
test("testFn should give proper error message if yielding array but no results", function () {
try {

@@ -516,7 +522,7 @@ testYieldArray(function () {

} catch (e) {
deepEqual(e.message, 'Your spec does not have as many steps as your function. Are you missing a return line?');
deepEqual(e.message, "Your spec does not have as many steps as your function. Are you missing a return line?");
}
});
test('testFn should give proper error message if spec is returning undefined', function () {
test("testFn should give proper error message if spec is returning undefined", function () {
try {

@@ -529,3 +535,3 @@ testYieldArray(function () {})();

test('testFn should give proper error message if spec is returning an object', function () {
test("testFn should give proper error message if spec is returning an object", function () {
try {

@@ -540,6 +546,6 @@ testYieldArray(function () {

test('testFn should give proper error message if spec is returning an string', function () {
test("testFn should give proper error message if spec is returning an string", function () {
try {
testYieldArray(function () {
return 'what?';
return "what?";
})();

@@ -546,0 +552,0 @@ } catch (e) {

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -7,7 +7,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var assert = require('assert');
var curry = require('lodash/curry');
var chunk = require('lodash/chunk');
var assert = require("assert");
var curry = require("lodash/curry");
var chunk = require("lodash/chunk");
var _require = require('./specs/test-util'),
var _require = require("./specs/test-util"),
deepEqual = _require.deepEqual;

@@ -21,3 +21,3 @@

assert(fn, 'The function you are trying to test is undefined.');
assert(fn, "The function you are trying to test is undefined.");

@@ -27,3 +27,3 @@ var step = expected[index];

if (step === undefined) {
throw new Error('Your spec does not have as many steps as your function. Are you missing a return line?');
throw new Error("Your spec does not have as many steps as your function. Are you missing a return line?");
}

@@ -36,3 +36,3 @@

if (index === 0 && !Array.isArray(input)) {
throw new Error('The first argument of the first tuple must be an array representing the arguments of the function.');
throw new Error("The first argument of the first tuple must be an array representing the arguments of the function.");
}

@@ -67,5 +67,5 @@ var g = void 0;

} catch (e) {
var stepError = 'Error on Step ' + (index + 1);
var stepError = "Error on Step " + (index + 1);
e.name = stepError;
e.stack = stepError + '\n\n' + e.stack;
e.stack = stepError + "\n\n" + e.stack;
throw e;

@@ -86,3 +86,3 @@ }

if (!Array.isArray(expected)) {
throw new Error('Your spec must return an array of tuples. It is currently returning a value of type "' + (typeof expected === 'undefined' ? 'undefined' : _typeof(expected)) + '".');
throw new Error("Your spec must return an array of tuples. It is currently returning a value of type \"" + (typeof expected === "undefined" ? "undefined" : _typeof(expected)) + "\".");
}

@@ -95,3 +95,3 @@ for (var i = 0; i < expected.length; i++) {

if (Array.isArray(output)) {
assert(Array.isArray(nextInput), 'If an array of actions is yielded, it should return an array of results.');
assert(Array.isArray(nextInput), "If an array of actions is yielded, it should return an array of results.");
}

@@ -98,0 +98,0 @@ }

{
"name": "effects-as-data",
"version": "2.14.5",
"version": "2.14.6",
"description":

@@ -16,3 +16,4 @@ "A micro abstraction layer for Javascript that makes writing, testing, and monitoring side-effects easy.",

"deploy": "npm run transpile && npm test && npm publish; rm -rf es5",
"perf": "node src/perf/fs"
"perf": "node src/perf/fs",
"prettier": "prettier --write {src/*.js,src/**/*.js}"
},

@@ -26,7 +27,8 @@ "author": "orourkedd",

"babel-cli": "^6.24.1",
"babel-jest": "^20.0.0",
"babel-jest": "^21.0.2",
"babel-preset-es2015": "^6.24.1",
"jest": "^21.0.2",
"jest-cli": "^20.0.0",
"mocha": "^3.5.0"
"jest-cli": "^21.1.0",
"mocha": "^3.5.0",
"prettier": "^1.6.1"
},

@@ -33,0 +35,0 @@ "jest": {

@@ -15,2 +15,3 @@ # Effects-as-data

* [Examples of How to Do Things](#examples-of-how-to-do-things)
* [Live Demo](#live-demo)
* [Pure Functions, Generators, and Effects-as-data](#pure-functions-generators-and-effects-as-data)

@@ -34,2 +35,7 @@ * [Usage in Node and the Browser](#usage-in-node-and-the-browser-es6-and-es5)

## Live Demo
An example of a React/Redux application using effects-as-data: [Open Live Demo](http://effects-as-data-todo-app.s3-website-us-west-2.amazonaws.com/)
The repo for this demo: [Open Repo](https://github.com/orourkedd/effects-as-data-examples/tree/master/todoapp)
## Pure Functions, Generators, and Effects-as-data

@@ -62,2 +68,5 @@

An example of a React/Redux application using effects-as-data: [Open Live Demo](http://effects-as-data-todo-app.s3-website-us-west-2.amazonaws.com/)
The repo for this demo: [Open Repo](https://github.com/orourkedd/effects-as-data-examples/tree/master/todoapp)
## Installation

@@ -64,0 +73,0 @@ ```

@@ -1,10 +0,10 @@

const { isGenerator, toArray, toPromise, delay, uuid } = require("./util")
const { isGenerator, toArray, toPromise, delay, uuid } = require("./util");
function call(config, handlers, fn, ...args) {
if (!fn) return Promise.reject(new Error("A function is required."))
const gen = fn.apply(null, args)
const el = newExecutionLog()
const childConfig = Object.assign({}, config)
childConfig.cid = childConfig.cid || uuid()
const stack = config.stack || []
if (!fn) return Promise.reject(new Error("A function is required."));
const gen = fn.apply(null, args);
const el = newExecutionLog();
const childConfig = Object.assign({}, config);
childConfig.cid = childConfig.cid || uuid();
const stack = config.stack || [];
childConfig.stack = stack.concat({

@@ -15,8 +15,8 @@ config: childConfig,

args
})
const start = Date.now()
onCall({ args, fn, config: childConfig })
});
const start = Date.now();
onCall({ args, fn, config: childConfig });
return run(childConfig, handlers, fn, gen, null, el)
.then(result => {
const end = Date.now()
const end = Date.now();
onCallComplete({

@@ -30,7 +30,7 @@ success: true,

latency: end - start
})
return result
});
return result;
})
.catch(e => {
const end = Date.now()
const end = Date.now();
onCallComplete({

@@ -44,5 +44,5 @@ success: false,

latency: end - start
})
throw e
})
});
throw e;
});
}

@@ -52,18 +52,18 @@

try {
const { output, done } = getNextOutput(gen, input, genOperation)
if (done) return toPromise(output)
const isList = Array.isArray(output)
const commandsList = toArray(output)
const { output, done } = getNextOutput(gen, input, genOperation);
if (done) return toPromise(output);
const isList = Array.isArray(output);
const commandsList = toArray(output);
return processCommands(config, handlers, fn, commandsList, el)
.then(results => {
const unwrappedResults = unwrapResults(isList, results)
el.step++
return run(config, handlers, fn, gen, unwrappedResults, el, "next")
const unwrappedResults = unwrapResults(isList, results);
el.step++;
return run(config, handlers, fn, gen, unwrappedResults, el, "next");
})
.catch(e => {
el.step++
return run(config, handlers, fn, gen, e, el, "throw")
})
el.step++;
return run(config, handlers, fn, gen, e, el, "throw");
});
} catch (e) {
return Promise.reject(e)
return Promise.reject(e);
}

@@ -75,12 +75,12 @@ }

step: 0
}
};
}
function unwrapResults(isList, results) {
return isList ? results : results[0]
return isList ? results : results[0];
}
function getNextOutput(fn, input, op = "next") {
const { value: output, done } = fn[op](input)
return { output, done }
const { value: output, done } = fn[op](input);
return { output, done };
}

@@ -90,7 +90,7 @@

try {
const pc = (c, index) => processCommand(config, handlers, fn, c, el, index)
const promises = commands.map(pc)
return Promise.all(promises)
const pc = (c, index) => processCommand(config, handlers, fn, c, el, index);
const promises = commands.map(pc);
return Promise.all(promises);
} catch (e) {
return Promise.reject(e)
return Promise.reject(e);
}

@@ -100,3 +100,3 @@ }

function processCommand(config, handlers, fn, command, el, index) {
const start = Date.now()
const start = Date.now();
onCommand({

@@ -109,15 +109,15 @@ command,

config
})
let result
});
let result;
try {
const handler = handlers[command.type]
const handler = handlers[command.type];
if (!handler)
throw new Error(`Handler of type "${command.type}" is not registered.`)
result = handler(command, { call, config, handlers })
throw new Error(`Handler of type "${command.type}" is not registered.`);
result = handler(command, { call, config, handlers });
} catch (e) {
result = Promise.reject(e)
result = Promise.reject(e);
}
return toPromise(result)
.then(r => {
const end = Date.now()
const end = Date.now();
onCommandComplete({

@@ -133,7 +133,7 @@ success: true,

end
})
return r
});
return r;
})
.catch(e => {
const end = Date.now()
const end = Date.now();
onCommandComplete({

@@ -149,9 +149,9 @@ success: false,

end
})
throw e
})
});
throw e;
});
}
function onCommand({ command, index, step, config, start, fn }) {
if (!config.onCommand || typeof config.onCommand !== "function") return
if (!config.onCommand || typeof config.onCommand !== "function") return;
const r = {

@@ -164,4 +164,4 @@ command,

fn
}
delay(() => config.onCommand(r))
};
delay(() => config.onCommand(r));
}

@@ -184,3 +184,3 @@

)
return
return;
const r = {

@@ -197,8 +197,8 @@ success,

fn
}
delay(() => config.onCommandComplete(r))
};
delay(() => config.onCommandComplete(r));
}
function onCall({ args, fn, config }) {
if (!config.onCall || typeof config.onCall !== "function") return
if (!config.onCall || typeof config.onCall !== "function") return;
const r = {

@@ -208,4 +208,4 @@ args,

config
}
delay(() => config.onCall(r))
};
delay(() => config.onCall(r));
}

@@ -215,3 +215,3 @@

if (!config.onCallComplete || typeof config.onCallComplete !== "function")
return
return;
const r = {

@@ -225,15 +225,15 @@ success,

start
}
delay(() => config.onCallComplete(r))
};
delay(() => config.onCallComplete(r));
}
function buildFunctions(config, handlers, functions) {
let promiseFunctions = {}
let promiseFunctions = {};
for (let i in functions) {
promiseFunctions[i] = function(...args) {
const localConfig = Object.assign({ name: i }, config)
return call(localConfig, handlers, functions[i], ...args)
}
const localConfig = Object.assign({ name: i }, config);
return call(localConfig, handlers, functions[i], ...args);
};
}
return promiseFunctions
return promiseFunctions;
}

@@ -244,2 +244,2 @@

buildFunctions
}
};

@@ -1,74 +0,76 @@

const { call } = require('../index')
const handlers = require('./effects/handlers')
const { eadBenchmark } = require('./effects/functions')
const { standardBenchmark } = require('./standard')
const { call } = require("../index");
const handlers = require("./effects/handlers");
const { eadBenchmark } = require("./effects/functions");
const { standardBenchmark } = require("./standard");
const iterations = 1000 * 30
const percentile = 0.99
const iterations = 1000 * 30;
const percentile = 0.99;
const filePath = '/tmp/perf.txt'
const filePath = "/tmp/perf.txt";
async function testStandard() {
const start = Date.now()
const start = Date.now();
for (let i = 0; i < iterations; i++) {
await standardBenchmark(filePath)
await standardBenchmark(filePath);
}
const end = Date.now()
return end - start
const end = Date.now();
return end - start;
}
async function testEAD() {
const start = Date.now()
const start = Date.now();
for (let i = 0; i < iterations; i++) {
await call({}, handlers, eadBenchmark, filePath)
await call({}, handlers, eadBenchmark, filePath);
}
const end = Date.now()
return end - start
const end = Date.now();
return end - start;
}
async function test() {
console.log(`Please wait while operation runs ${iterations} times...`)
const eadLatencies = []
const standardLatencies = []
console.log(`Please wait while operation runs ${iterations} times...`);
const eadLatencies = [];
const standardLatencies = [];
for (let i = 0; i < iterations; i++) {
if (i % 250 === 0) {
const percentComplete = percent(i, iterations, 0)
process.stdout.write(`\r${percentComplete}% Complete`)
const percentComplete = percent(i, iterations, 0);
process.stdout.write(`\r${percentComplete}% Complete`);
}
const startEad = Date.now()
await call({}, handlers, eadBenchmark, filePath)
const endEad = Date.now()
eadLatencies.push(endEad - startEad)
const startStandard = Date.now()
await standardBenchmark(filePath)
const endStandard = Date.now()
standardLatencies.push(endStandard - startStandard)
const startEad = Date.now();
await call({}, handlers, eadBenchmark, filePath);
const endEad = Date.now();
eadLatencies.push(endEad - startEad);
const startStandard = Date.now();
await standardBenchmark(filePath);
const endStandard = Date.now();
standardLatencies.push(endStandard - startStandard);
}
const ead99 = eadLatencies.sort().splice(0, iterations * percentile)
const standard99 = standardLatencies.sort().splice(0, iterations * percentile)
const ead99 = eadLatencies.sort().splice(0, iterations * percentile);
const standard99 = standardLatencies
.sort()
.splice(0, iterations * percentile);
const sum = (p, c) => p + c
const eadTotal = ead99.reduce(sum, 0)
const standardTotal = standard99.reduce(sum, 0)
const diff = eadTotal - standardTotal
const perTransaction = diff / iterations
const microSecondsPerTransaction = (perTransaction * 1000).toFixed(2)
const percentSlower = ((1 - standardTotal / eadTotal) * 100).toFixed(2)
console.log('\n')
console.log('Results')
console.log('=====================================')
console.log(`Effects-as-data total: ${eadTotal}ms`)
console.log(`Pure Javascript total: ${standardTotal}ms`)
const sum = (p, c) => p + c;
const eadTotal = ead99.reduce(sum, 0);
const standardTotal = standard99.reduce(sum, 0);
const diff = eadTotal - standardTotal;
const perTransaction = diff / iterations;
const microSecondsPerTransaction = (perTransaction * 1000).toFixed(2);
const percentSlower = ((1 - standardTotal / eadTotal) * 100).toFixed(2);
console.log("\n");
console.log("Results");
console.log("=====================================");
console.log(`Effects-as-data total: ${eadTotal}ms`);
console.log(`Pure Javascript total: ${standardTotal}ms`);
console.log(
`Per transaction, effects-as-data was ${microSecondsPerTransaction}μs slower than pure Javascript.`
)
);
console.log(
`For ${iterations} transactions, effects-as-data was ${percentSlower}% / ${diff}ms slower than pure Javascript.`
)
);
}
function percent(a, b, fixed = 2) {
return (a / b * 100).toFixed(fixed)
return (a / b * 100).toFixed(fixed);
}
test().catch(console.error)
test().catch(console.error);

@@ -1,16 +0,16 @@

const { call } = require('../index')
const { functions, handlers } = require('./effects')
const { async } = handlers
const { asyncTest } = functions
const { sleep } = require('./test-util')
const { call } = require("../index");
const { functions, handlers } = require("./effects");
const { async } = handlers;
const { asyncTest } = functions;
const { sleep } = require("./test-util");
test('async', async () => {
let called = false
test("async", async () => {
let called = false;
const testHandler = () => {
called = true
}
await call({}, { async, test: testHandler }, asyncTest)
expect(called).toEqual(false)
await sleep(50)
expect(called).toEqual(true)
})
called = true;
};
await call({}, { async, test: testHandler }, asyncTest);
expect(called).toEqual(false);
await sleep(50);
expect(called).toEqual(true);
});

@@ -1,3 +0,3 @@

const { call } = require('../index')
const { handlers, functions } = require('./effects')
const { call } = require("../index");
const { handlers, functions } = require("./effects");
const {

@@ -10,43 +10,43 @@ basic,

basicMultiArg
} = functions
} = functions;
test('basic', async () => {
const expected = 'foo'
const actual = await call({}, handlers, basic, expected)
expect(actual).toEqual(expected)
})
test("basic", async () => {
const expected = "foo";
const actual = await call({}, handlers, basic, expected);
expect(actual).toEqual(expected);
});
test('basic should be able to accept array arguments', async () => {
const expected = ['foo', 'bar']
const actual = await call({}, handlers, basic, expected)
expect(actual).toEqual(expected)
})
test("basic should be able to accept array arguments", async () => {
const expected = ["foo", "bar"];
const actual = await call({}, handlers, basic, expected);
expect(actual).toEqual(expected);
});
test('basicMultiArg', async () => {
const actual = await call({}, handlers, basicMultiArg, 'foo', 'bar')
expect(actual).toEqual('foobar')
})
test("basicMultiArg", async () => {
const actual = await call({}, handlers, basicMultiArg, "foo", "bar");
expect(actual).toEqual("foobar");
});
test('basicMultistep', async () => {
const actual = await call({}, handlers, basicMultistep, 'foo')
const expected = { s1: 'foo1', s2: 'foo2' }
expect(actual).toEqual(expected)
})
test("basicMultistep", async () => {
const actual = await call({}, handlers, basicMultistep, "foo");
const expected = { s1: "foo1", s2: "foo2" };
expect(actual).toEqual(expected);
});
test('basicParallel', async () => {
const actual = await call({}, handlers, basicParallel, 'foo')
const expected = { s1: 'foo1', s2: 'foo2' }
expect(actual).toEqual(expected)
})
test("basicParallel", async () => {
const actual = await call({}, handlers, basicParallel, "foo");
const expected = { s1: "foo1", s2: "foo2" };
expect(actual).toEqual(expected);
});
test('basicMultistepParallel', async () => {
const actual = await call({}, handlers, basicMultistepParallel, 'foo')
const expected = { s1: 'foo1', s2: 'foo2', s3: 'foo3', s4: 'foo4' }
expect(actual).toEqual(expected)
})
test("basicMultistepParallel", async () => {
const actual = await call({}, handlers, basicMultistepParallel, "foo");
const expected = { s1: "foo1", s2: "foo2", s3: "foo3", s4: "foo4" };
expect(actual).toEqual(expected);
});
test('basicEmpty', async () => {
const expected = []
const actual = await call({}, handlers, basicEmpty)
expect(actual).toEqual(expected)
})
test("basicEmpty", async () => {
const expected = [];
const actual = await call({}, handlers, basicEmpty);
expect(actual).toEqual(expected);
});

@@ -1,2 +0,2 @@

const cmds = require("../commands")
const cmds = require('../commands')

@@ -12,4 +12,4 @@ function* basic(message) {

function* basicMultistep(message) {
const s1 = yield cmds.echo(message + "1")
const s2 = yield cmds.echo(message + "2")
const s1 = yield cmds.echo(message + '1')
const s2 = yield cmds.echo(message + '2')
return { s1, s2 }

@@ -21,4 +21,4 @@ }

return {
s1: s1 + "1",
s2: s2 + "2"
s1: s1 + '1',
s2: s2 + '2'
}

@@ -31,6 +31,6 @@ }

return {
s1: s1 + "1",
s2: s2 + "2",
s3: s3 + "3",
s4: s4 + "4"
s1: s1 + '1',
s2: s2 + '2',
s3: s3 + '3',
s4: s4 + '4'
}

@@ -37,0 +37,0 @@ }

@@ -1,15 +0,15 @@

const { call } = require('../index')
const { handlers, functions } = require('./effects')
const { eitherTestError, eitherTestEmpty } = functions
const { call } = require("../index");
const { handlers, functions } = require("./effects");
const { eitherTestError, eitherTestEmpty } = functions;
test('call should use either, handle error, and return default value', async () => {
const actual = await call({}, handlers, eitherTestError)
const expected = 'foo'
expect(actual).toEqual(expected)
})
test("call should use either, handle error, and return default value", async () => {
const actual = await call({}, handlers, eitherTestError);
const expected = "foo";
expect(actual).toEqual(expected);
});
test('call should use either, handle error, and return default value if return value is falsey', async () => {
const actual = await call({}, handlers, eitherTestEmpty)
const expected = 'foo'
expect(actual).toEqual(expected)
})
test("call should use either, handle error, and return default value if return value is falsey", async () => {
const actual = await call({}, handlers, eitherTestEmpty);
const expected = "foo";
expect(actual).toEqual(expected);
});

@@ -1,3 +0,3 @@

const { call } = require("../index")
const { handlers, functions } = require("./effects")
const { call } = require("../index");
const { handlers, functions } = require("./effects");
const {

@@ -8,48 +8,48 @@ badHandler,

functionErrorTest
} = functions
const { expectError } = require("./test-util")
} = functions;
const { expectError } = require("./test-util");
test("call should reject for an undefined function", async () => {
try {
await call({}, handlers, undefined)
await call({}, handlers, undefined);
} catch (actual) {
const message = "A function is required."
return expectError(actual, message)
const message = "A function is required.";
return expectError(actual, message);
}
fail("Function did not reject.")
})
fail("Function did not reject.");
});
test("call should catch function errors", async () => {
try {
await call({}, handlers, functionErrorTest)
await call({}, handlers, functionErrorTest);
} catch (actual) {
const message = "oops!"
return expectError(actual, message)
const message = "oops!";
return expectError(actual, message);
}
fail("Function did not reject.")
})
fail("Function did not reject.");
});
test("call should throw error at the yield", async () => {
const actual = await call({}, handlers, throwAtYield)
const expected = "caught!"
expect(actual).toEqual(expected)
})
const actual = await call({}, handlers, throwAtYield);
const expected = "caught!";
expect(actual).toEqual(expected);
});
test("call should throw error at the yield and recover", async () => {
const actual = await call({}, handlers, throwAtYieldRecovery)
const expected = "foo"
expect(actual).toEqual(expected)
})
const actual = await call({}, handlers, throwAtYieldRecovery);
const expected = "foo";
expect(actual).toEqual(expected);
});
test("call should throw error for unregistered handler", async () => {
const fn = function*() {
yield { type: "dne" }
}
yield { type: "dne" };
};
try {
await call({}, handlers, fn)
await call({}, handlers, fn);
} catch (e) {
expect(e.message).toEqual('Handler of type "dne" is not registered.')
return
expect(e.message).toEqual('Handler of type "dne" is not registered.');
return;
}
fail("Did not throw.")
})
fail("Did not throw.");
});

@@ -1,3 +0,3 @@

const { call } = require('../index')
const { handlers, functions, cmds } = require('./effects')
const { call } = require("../index");
const { handlers, functions, cmds } = require("./effects");
const {

@@ -8,45 +8,45 @@ badHandler,

promiseReturningHandler
} = functions
const { expectError } = require('./test-util')
} = functions;
const { expectError } = require("./test-util");
test('handlers should be able to return non-promise values', async () => {
const actual = await call({}, handlers, valueReturningHandler, 'bar')
const expected = 'bar'
expect(actual).toEqual(expected)
})
test("handlers should be able to return non-promise values", async () => {
const actual = await call({}, handlers, valueReturningHandler, "bar");
const expected = "bar";
expect(actual).toEqual(expected);
});
test('handlers should be able to return promises', async () => {
const actual = await call({}, handlers, promiseReturningHandler, 'bar')
const expected = 'bar'
expect(actual).toEqual(expected)
})
test("handlers should be able to return promises", async () => {
const actual = await call({}, handlers, promiseReturningHandler, "bar");
const expected = "bar";
expect(actual).toEqual(expected);
});
test('call should reject when a handler throws and is not caught', async () => {
test("call should reject when a handler throws and is not caught", async () => {
try {
await call({}, handlers, badHandler)
await call({}, handlers, badHandler);
} catch (actual) {
const message = 'oops'
return expectError(actual, message)
const message = "oops";
return expectError(actual, message);
}
fail('Function did not reject.')
})
fail("Function did not reject.");
});
test('call should reject when a handler rejects and is not caught', async () => {
test("call should reject when a handler rejects and is not caught", async () => {
try {
await call({}, handlers, badHandlerRejection)
await call({}, handlers, badHandlerRejection);
} catch (actual) {
const message = 'oops'
return expectError(actual, message)
const message = "oops";
return expectError(actual, message);
}
fail('Function did not reject.')
})
fail("Function did not reject.");
});
test('handlers should be able to return an array of results', async () => {
test("handlers should be able to return an array of results", async () => {
const fn = function*(a, b) {
const result = yield [cmds.echo(a), cmds.echo(b)]
return result
}
const actual = await call({}, handlers, fn, ['foo', 'bar'], ['foo', 'baz'])
const expected = [['foo', 'bar'], ['foo', 'baz']]
expect(actual).toEqual(expected)
})
const result = yield [cmds.echo(a), cmds.echo(b)];
return result;
};
const actual = await call({}, handlers, fn, ["foo", "bar"], ["foo", "baz"]);
const expected = [["foo", "bar"], ["foo", "baz"]];
expect(actual).toEqual(expected);
});

@@ -1,186 +0,186 @@

const { call } = require("../index")
const { handlers, functions, cmds } = require("./effects")
const { basicMultistep, badHandler, basic } = functions
const { sleep } = require("./test-util")
const { call } = require("../index");
const { handlers, functions, cmds } = require("./effects");
const { basicMultistep, badHandler, basic } = functions;
const { sleep } = require("./test-util");
test("telemetry - should add a correlation id to the config", async () => {
let telemetry
let telemetry;
const onCommand = t => {
telemetry = t
}
const config = { onCommand, name: "telemetry" }
const now = Date.now()
await call(config, handlers, basic, "foo")
await sleep(10)
expect(telemetry.config.cid.length).toEqual(36)
})
telemetry = t;
};
const config = { onCommand, name: "telemetry" };
const now = Date.now();
await call(config, handlers, basic, "foo");
await sleep(10);
expect(telemetry.config.cid.length).toEqual(36);
});
test("telemetry - should use an existing correlation id if on the config", async () => {
let telemetry
let telemetry;
const onCommand = t => {
telemetry = t
}
const config = { onCommand, name: "telemetry", cid: "foo" }
const now = Date.now()
await call(config, handlers, basic, "bar")
await sleep(10)
expect(telemetry.config.cid).toEqual("foo")
})
telemetry = t;
};
const config = { onCommand, name: "telemetry", cid: "foo" };
const now = Date.now();
await call(config, handlers, basic, "bar");
await sleep(10);
expect(telemetry.config.cid).toEqual("foo");
});
test("telemetry - should add a stack to the config and push the current frame", async () => {
let telemetry
let telemetry;
const onCommand = t => {
telemetry = t
}
const config = { onCommand, name: "telemetry" }
const now = Date.now()
await call(config, handlers, basic, "foo")
await sleep(10)
expect(telemetry.config.stack[0].fn).toEqual(basic)
expect(telemetry.config.stack[0].handlers).toEqual(handlers)
expect(telemetry.config.stack[0].args).toEqual(["foo"])
expect(telemetry.config.stack[0].config.onCommand).toEqual(onCommand)
expect(telemetry.config.stack[0].config.name).toEqual("telemetry")
expect(telemetry.config.stack[0].config.cid.length).toEqual(36)
expect(telemetry.config.stack[0].config.stack[0].handlers).toEqual(handlers)
expect(telemetry.config.stack[0].config.stack[0].args).toEqual(["foo"])
expect(telemetry.config.stack[0].config.stack[0].fn).toEqual(basic)
telemetry = t;
};
const config = { onCommand, name: "telemetry" };
const now = Date.now();
await call(config, handlers, basic, "foo");
await sleep(10);
expect(telemetry.config.stack[0].fn).toEqual(basic);
expect(telemetry.config.stack[0].handlers).toEqual(handlers);
expect(telemetry.config.stack[0].args).toEqual(["foo"]);
expect(telemetry.config.stack[0].config.onCommand).toEqual(onCommand);
expect(telemetry.config.stack[0].config.name).toEqual("telemetry");
expect(telemetry.config.stack[0].config.cid.length).toEqual(36);
expect(telemetry.config.stack[0].config.stack[0].handlers).toEqual(handlers);
expect(telemetry.config.stack[0].config.stack[0].args).toEqual(["foo"]);
expect(telemetry.config.stack[0].config.stack[0].fn).toEqual(basic);
expect(telemetry.config.stack[0].config.stack[0].config.name).toEqual(
"telemetry"
)
})
);
});
test("telemetry - should add a stack to the config for child calls", async () => {
let telemetry
let telemetry;
const onCommand = t => {
telemetry = t
}
const config = { onCommand, name: "telemetry" }
const now = Date.now()
await call(config, handlers, basic, "foo")
await sleep(10)
expect(telemetry.config.stack[0].fn).toEqual(basic)
expect(telemetry.config.stack[0].handlers).toEqual(handlers)
expect(telemetry.config.stack[0].args).toEqual(["foo"])
expect(telemetry.config.stack[0].config.onCommand).toEqual(onCommand)
expect(telemetry.config.stack[0].config.name).toEqual("telemetry")
expect(telemetry.config.stack[0].config.cid.length).toEqual(36)
expect(telemetry.config.stack[0].config.stack[0].handlers).toEqual(handlers)
expect(telemetry.config.stack[0].config.stack[0].args).toEqual(["foo"])
expect(telemetry.config.stack[0].config.stack[0].fn).toEqual(basic)
telemetry = t;
};
const config = { onCommand, name: "telemetry" };
const now = Date.now();
await call(config, handlers, basic, "foo");
await sleep(10);
expect(telemetry.config.stack[0].fn).toEqual(basic);
expect(telemetry.config.stack[0].handlers).toEqual(handlers);
expect(telemetry.config.stack[0].args).toEqual(["foo"]);
expect(telemetry.config.stack[0].config.onCommand).toEqual(onCommand);
expect(telemetry.config.stack[0].config.name).toEqual("telemetry");
expect(telemetry.config.stack[0].config.cid.length).toEqual(36);
expect(telemetry.config.stack[0].config.stack[0].handlers).toEqual(handlers);
expect(telemetry.config.stack[0].config.stack[0].args).toEqual(["foo"]);
expect(telemetry.config.stack[0].config.stack[0].fn).toEqual(basic);
expect(telemetry.config.stack[0].config.stack[0].config.name).toEqual(
"telemetry"
)
})
);
});
test("telemetry - onCommand", async () => {
let telemetry = []
let telemetry = [];
const onCommand = t => {
telemetry.push(t)
}
const config = { onCommand, name: "telemetry" }
const now = Date.now()
await call(config, handlers, basicMultistep, "foo")
await sleep(10)
expect(telemetry.length).toEqual(2)
telemetry.push(t);
};
const config = { onCommand, name: "telemetry" };
const now = Date.now();
await call(config, handlers, basicMultistep, "foo");
await sleep(10);
expect(telemetry.length).toEqual(2);
telemetry.forEach((t, i) => {
const message = "foo" + (i + 1)
expect(t.command).toEqual(cmds.echo(message))
expect(t.fn).toEqual(basicMultistep)
expect(t.start).toBeGreaterThanOrEqual(now)
expect(t.index).toEqual(0)
expect(t.step).toEqual(i)
expect(t.config.name).toEqual("telemetry")
expect(t.config.stack[0].fn).toEqual(basicMultistep)
})
})
const message = "foo" + (i + 1);
expect(t.command).toEqual(cmds.echo(message));
expect(t.fn).toEqual(basicMultistep);
expect(t.start).toBeGreaterThanOrEqual(now);
expect(t.index).toEqual(0);
expect(t.step).toEqual(i);
expect(t.config.name).toEqual("telemetry");
expect(t.config.stack[0].fn).toEqual(basicMultistep);
});
});
test("telemetry - onCommandComplete", async () => {
let telemetry = []
let telemetry = [];
const onCommandComplete = t => {
telemetry.push(t)
}
const config = { onCommandComplete, name: "telemetry" }
const now = Date.now()
await call(config, handlers, basicMultistep, "foo")
await sleep(10)
expect(telemetry.length).toEqual(2)
telemetry.push(t);
};
const config = { onCommandComplete, name: "telemetry" };
const now = Date.now();
await call(config, handlers, basicMultistep, "foo");
await sleep(10);
expect(telemetry.length).toEqual(2);
telemetry.forEach((t, i) => {
const message = "foo" + (i + 1)
expect(t.success).toEqual(true)
expect(t.command).toEqual(cmds.echo(message))
expect(t.latency).toBeLessThan(5)
expect(t.start).toBeGreaterThanOrEqual(now)
expect(t.end).toBeGreaterThanOrEqual(t.start)
expect(t.index).toEqual(0)
expect(t.step).toEqual(i)
expect(t.result).toEqual(message)
expect(t.config.name).toEqual("telemetry")
expect(t.config.stack[0].fn).toEqual(basicMultistep)
expect(t.fn).toEqual(basicMultistep)
})
})
const message = "foo" + (i + 1);
expect(t.success).toEqual(true);
expect(t.command).toEqual(cmds.echo(message));
expect(t.latency).toBeLessThan(5);
expect(t.start).toBeGreaterThanOrEqual(now);
expect(t.end).toBeGreaterThanOrEqual(t.start);
expect(t.index).toEqual(0);
expect(t.step).toEqual(i);
expect(t.result).toEqual(message);
expect(t.config.name).toEqual("telemetry");
expect(t.config.stack[0].fn).toEqual(basicMultistep);
expect(t.fn).toEqual(basicMultistep);
});
});
test("telemetry on error - onCommandComplete", async () => {
let telemetry
let telemetry;
const onCommandComplete = t => {
telemetry = t
}
const config = { onCommandComplete, name: "badHandler" }
const now = Date.now()
const message = "oops"
telemetry = t;
};
const config = { onCommandComplete, name: "badHandler" };
const now = Date.now();
const message = "oops";
try {
await call(config, handlers, badHandler, message)
await call(config, handlers, badHandler, message);
} catch (e) {}
await sleep(10)
expect(telemetry.success).toEqual(false)
expect(telemetry.command).toEqual(cmds.die(message))
expect(telemetry.latency).toBeLessThan(5)
expect(telemetry.start).toBeGreaterThanOrEqual(now)
expect(telemetry.end).toBeGreaterThanOrEqual(telemetry.start)
expect(telemetry.index).toEqual(0)
expect(telemetry.step).toEqual(0)
expect(telemetry.result.message).toEqual("oops")
expect(telemetry.config.name).toEqual("badHandler")
expect(telemetry.config.stack[0].fn).toEqual(badHandler)
expect(telemetry.fn).toEqual(badHandler)
})
await sleep(10);
expect(telemetry.success).toEqual(false);
expect(telemetry.command).toEqual(cmds.die(message));
expect(telemetry.latency).toBeLessThan(5);
expect(telemetry.start).toBeGreaterThanOrEqual(now);
expect(telemetry.end).toBeGreaterThanOrEqual(telemetry.start);
expect(telemetry.index).toEqual(0);
expect(telemetry.step).toEqual(0);
expect(telemetry.result.message).toEqual("oops");
expect(telemetry.config.name).toEqual("badHandler");
expect(telemetry.config.stack[0].fn).toEqual(badHandler);
expect(telemetry.fn).toEqual(badHandler);
});
test("onCall", done => {
const onCall = called => {
expect(called.args).toEqual(["foo", "bar", "baz"])
done()
}
const config = { onCall }
call(config, handlers, basicMultistep, "foo", "bar", "baz")
})
expect(called.args).toEqual(["foo", "bar", "baz"]);
done();
};
const config = { onCall };
call(config, handlers, basicMultistep, "foo", "bar", "baz");
});
test("onCallComplete", done => {
const now = Date.now()
const now = Date.now();
const onCallComplete = complete => {
expect(complete.success).toEqual(true)
expect(complete.fn).toEqual(basic)
expect(complete.result).toEqual("foo")
expect(typeof complete.latency).toEqual("number")
expect(complete.start).toBeGreaterThanOrEqual(now)
expect(complete.end).toBeGreaterThanOrEqual(complete.start)
done()
}
const config = { onCallComplete, name: "telemetry" }
call(config, handlers, basic, "foo")
})
expect(complete.success).toEqual(true);
expect(complete.fn).toEqual(basic);
expect(complete.result).toEqual("foo");
expect(typeof complete.latency).toEqual("number");
expect(complete.start).toBeGreaterThanOrEqual(now);
expect(complete.end).toBeGreaterThanOrEqual(complete.start);
done();
};
const config = { onCallComplete, name: "telemetry" };
call(config, handlers, basic, "foo");
});
test("onCallComplete for errors", done => {
const now = Date.now()
const now = Date.now();
const onCallComplete = complete => {
expect(complete.success).toEqual(false)
expect(complete.fn).toEqual(badHandler)
expect(complete.result.message).toEqual("oops")
expect(typeof complete.latency).toEqual("number")
expect(complete.start).toBeGreaterThanOrEqual(now)
expect(complete.end).toBeGreaterThanOrEqual(complete.start)
done()
}
const config = { onCallComplete, name: "telemetry" }
call(config, handlers, badHandler, "foo").catch(e => e)
})
expect(complete.success).toEqual(false);
expect(complete.fn).toEqual(badHandler);
expect(complete.result.message).toEqual("oops");
expect(typeof complete.latency).toEqual("number");
expect(complete.start).toBeGreaterThanOrEqual(now);
expect(complete.end).toBeGreaterThanOrEqual(complete.start);
done();
};
const config = { onCallComplete, name: "telemetry" };
call(config, handlers, badHandler, "foo").catch(e => e);
});

@@ -1,24 +0,24 @@

const assert = require("assert")
const assert = require("assert");
function errorToJson(e) {
const props = Object.getOwnPropertyNames(e).concat('name')
const props = Object.getOwnPropertyNames(e).concat("name");
return props.reduce((p, c) => {
p[c] = e[c]
return p
}, {})
p[c] = e[c];
return p;
}, {});
}
function expectError(e1, e2) {
const ne1 = typeof e1 === 'string' ? new Error(e1) : e1
const ne2 = typeof e2 === 'string' ? new Error(e2) : e2
const be1 = get(() => e2.constructor.name) ? errorToJson(ne1) : ne1
const be2 = get(() => e1.constructor.name) ? errorToJson(ne2) : ne2
const oe1 = omitStack(be1)
const oe2 = omitStack(be2)
expect(oe1).toEqual(oe2)
const ne1 = typeof e1 === "string" ? new Error(e1) : e1;
const ne2 = typeof e2 === "string" ? new Error(e2) : e2;
const be1 = get(() => e2.constructor.name) ? errorToJson(ne1) : ne1;
const be2 = get(() => e1.constructor.name) ? errorToJson(ne2) : ne2;
const oe1 = omitStack(be1);
const oe2 = omitStack(be2);
expect(oe1).toEqual(oe2);
}
function omitStack(s) {
delete s.stack
return s
delete s.stack;
return s;
}

@@ -28,5 +28,5 @@

try {
return fn()
return fn();
} catch (e) {
return undefined
return undefined;
}

@@ -37,26 +37,26 @@ }

return new Promise(resolve => {
setTimeout(resolve, ms)
})
setTimeout(resolve, ms);
});
}
function deepEqual(actual, expected) {
const a = normalizeError(actual)
const e = normalizeError(expected)
if (usingJest()) expect(a).toEqual(e)
else assert.deepEqual(a, e)
const a = normalizeError(actual);
const e = normalizeError(expected);
if (usingJest()) expect(a).toEqual(e);
else assert.deepEqual(a, e);
}
function normalizeError(v) {
const isError = v instanceof Error
if (!isError) return v
const props = Object.getOwnPropertyNames(v).concat("name")
const isError = v instanceof Error;
if (!isError) return v;
const props = Object.getOwnPropertyNames(v).concat("name");
return props.reduce((p, c) => {
if (c === "stack") return p
p[c] = v[c]
return p
}, {})
if (c === "stack") return p;
p[c] = v[c];
return p;
}, {});
}
function usingJest() {
return typeof expect !== "undefined" && expect.extend && expect.anything
return typeof expect !== "undefined" && expect.extend && expect.anything;
}

@@ -68,2 +68,2 @@

deepEqual
}
};

@@ -1,2 +0,2 @@

const { functions, cmds } = require('./effects')
const { functions, cmds } = require("./effects");
const {

@@ -13,28 +13,28 @@ basic,

badHandler
} = functions
const { testFn, testFnV2, args } = require('../test')
const { deepEqual } = require('./test-util')
} = functions;
const { testFn, testFnV2, args } = require("../test");
const { deepEqual } = require("./test-util");
function* singleLine(id) {
const s1 = yield cmds.httpGet(`http://example.com/api/v1/users/${id}`)
return s1
const s1 = yield cmds.httpGet(`http://example.com/api/v1/users/${id}`);
return s1;
}
function* yieldArray() {
const s1 = yield [{ type: 'test' }]
return s1
const s1 = yield [{ type: "test" }];
return s1;
}
const testSingleLine = testFn(singleLine)
const testYieldArray = testFn(yieldArray)
const testSingleLine = testFn(singleLine);
const testYieldArray = testFn(yieldArray);
function* rethrow() {
try {
return yield cmds.echo('foo')
return yield cmds.echo("foo");
} catch (e) {
throw new Error('bar')
throw new Error("bar");
}
}
test('testFn should fail if tuples[0][0] is not an array', () => {
test("testFn should fail if tuples[0][0] is not an array", () => {
try {

@@ -46,18 +46,18 @@ testFn(throwFoo, () => {

]
})()
})();
} catch (e) {
deepEqual(
e.message,
'The first argument of the first tuple must be an array representing the arguments of the function.'
)
return
"The first argument of the first tuple must be an array representing the arguments of the function."
);
return;
}
throw new Error('Failed: Did not compare error messages')
})
throw new Error("Failed: Did not compare error messages");
});
function* throwFoo() {
throw new Error('foo')
throw new Error("foo");
}
test('testFn should fail if the function error is different than the test error', () => {
test("testFn should fail if the function error is different than the test error", () => {
try {

@@ -69,12 +69,12 @@ testFn(throwFoo, () => {

]
})()
})();
} catch (e) {
deepEqual(e.name, 'Error on Step 1')
return
deepEqual(e.name, "Error on Step 1");
return;
}
throw new Error('Failed: Did not compare error messages')
})
throw new Error("Failed: Did not compare error messages");
});
test(
'should be able to rethrow errors',
"should be able to rethrow errors",
testFnV2(rethrow, () => {

@@ -88,13 +88,13 @@ // prettier-ignore

})
)
);
test(
'testFn should handle undefined returns for semantic test',
"testFn should handle undefined returns for semantic test",
testFn(function*() {}, () => {
return args().returns()
return args().returns();
})
)
);
test(
'testFn should curry',
"testFn should curry",
testFn(basic)(() => {

@@ -107,6 +107,6 @@ // prettier-ignore

})
)
);
test(
'testFn should pass (basic)',
"testFn should pass (basic)",
testFn(basic, () => {

@@ -119,3 +119,3 @@ // prettier-ignore

})
)
);

@@ -125,3 +125,3 @@ // Basic

test(
'testFn semantic should pass (basic)',
"testFn semantic should pass (basic)",
testFn(basic, () => {

@@ -133,6 +133,6 @@ // prettier-ignore

})
)
);
test(
'testFnV2 should pass (basic)',
"testFnV2 should pass (basic)",
testFnV2(basic, () => {

@@ -146,6 +146,6 @@ // prettier-ignore

})
)
);
test(
'testFn should pass (basicMultiArg)',
"testFn should pass (basicMultiArg)",
testFn(basicMultiArg, () => {

@@ -158,3 +158,3 @@ // prettier-ignore

})
)
);

@@ -164,3 +164,3 @@ // Basic w multiple arguments

test(
'testFn should pass (basicMultiArg)',
"testFn should pass (basicMultiArg)",
testFn(basicMultiArg, () => {

@@ -173,6 +173,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should pass (basicMultiArg)',
"testFn semantic should pass (basicMultiArg)",
testFn(basicMultiArg, () => {

@@ -184,6 +184,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should pass (basicMultiArg)',
"testFn semantic should pass (basicMultiArg)",
testFnV2(basicMultiArg, () => {

@@ -197,3 +197,3 @@ // prettier-ignore

})
)
);

@@ -203,3 +203,3 @@ // Basic with multiple steps

test(
'testFn should pass (basicMultistep)',
"testFn should pass (basicMultistep)",
testFn(basicMultistep, () => {

@@ -213,6 +213,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should pass (basicMultistep)',
"testFn semantic should pass (basicMultistep)",
testFn(basicMultistep, () => {

@@ -225,6 +225,6 @@ // prettier-ignore

})
)
);
test(
'testFnV2 should pass (basicMultistep)',
"testFnV2 should pass (basicMultistep)",
testFnV2(basicMultistep, () => {

@@ -239,3 +239,3 @@ // prettier-ignore

})
)
);

@@ -245,5 +245,5 @@ // Basic with parallel commands

test(
'testFn should pass (basicParallel)',
"testFn should pass (basicParallel)",
testFn(basicParallel, () => {
const c = [cmds.echo('foo'), cmds.echo('foo')]
const c = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -255,8 +255,8 @@ return [

})
)
);
test(
'testFn semantic should pass (basicParallel)',
"testFn semantic should pass (basicParallel)",
testFn(basicParallel, () => {
const c = [cmds.echo('foo'), cmds.echo('foo')]
const c = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -267,8 +267,8 @@ return args('foo')

})
)
);
test(
'testFnV2 should pass (basicParallel)',
"testFnV2 should pass (basicParallel)",
testFnV2(basicParallel, () => {
const c = [cmds.echo('foo'), cmds.echo('foo')]
const c = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -281,3 +281,3 @@ return [

})
)
);

@@ -287,6 +287,6 @@ // Basic with multiple steps of parallel commands

test(
'testFn should pass (basicMultistepParallel)',
"testFn should pass (basicMultistepParallel)",
testFn(basicMultistepParallel, () => {
const c1 = [cmds.echo('foo'), cmds.echo('foo')]
const c2 = [cmds.echo('foo'), cmds.echo('foo')]
const c1 = [cmds.echo("foo"), cmds.echo("foo")];
const c2 = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -299,9 +299,9 @@ return [

})
)
);
test(
'testFn semantic should pass (basicMultistepParallel)',
"testFn semantic should pass (basicMultistepParallel)",
testFn(basicMultistepParallel, () => {
const c1 = [cmds.echo('foo'), cmds.echo('foo')]
const c2 = [cmds.echo('foo'), cmds.echo('foo')]
const c1 = [cmds.echo("foo"), cmds.echo("foo")];
const c2 = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -313,9 +313,9 @@ return args('foo')

})
)
);
test(
'testFnV2 should pass (basicMultistepParallel)',
"testFnV2 should pass (basicMultistepParallel)",
testFnV2(basicMultistepParallel, () => {
const c1 = [cmds.echo('foo'), cmds.echo('foo')]
const c2 = [cmds.echo('foo'), cmds.echo('foo')]
const c1 = [cmds.echo("foo"), cmds.echo("foo")];
const c2 = [cmds.echo("foo"), cmds.echo("foo")];
// prettier-ignore

@@ -329,3 +329,3 @@ return [

})
)
);

@@ -335,3 +335,3 @@ // Basic with empty args

test(
'testFn should pass (basicEmpty)',
"testFn should pass (basicEmpty)",
testFn(basicEmpty, () => {

@@ -344,6 +344,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should pass (basicEmpty)',
"testFn semantic should pass (basicEmpty)",
testFn(basicEmpty, () => {

@@ -355,6 +355,6 @@ // prettier-ignore

})
)
);
test(
'testFnV2 should pass (basicEmpty)',
"testFnV2 should pass (basicEmpty)",
testFnV2(basicEmpty, () => {

@@ -368,3 +368,3 @@ // prettier-ignore

})
)
);

@@ -374,3 +374,3 @@ // Either test with error

test(
'testFn should pass (eitherTestError)',
"testFn should pass (eitherTestError)",
testFn(eitherTestError, () => {

@@ -383,6 +383,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should pass (eitherTestError)',
"testFn semantic should pass (eitherTestError)",
testFn(eitherTestError, () => {

@@ -394,6 +394,6 @@ // prettier-ignore

})
)
);
test(
'testFnV2 semantic should pass (eitherTestError)',
"testFnV2 semantic should pass (eitherTestError)",
testFnV2(eitherTestError, () => {

@@ -407,3 +407,3 @@ // prettier-ignore

})
)
);

@@ -413,3 +413,3 @@ // Handler error handling

test(
'testFn should handle errors (badHandler)',
"testFn should handle errors (badHandler)",
testFn(badHandler, () => {

@@ -422,6 +422,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should handle errors (badHandler)',
"testFn semantic should handle errors (badHandler)",
testFn(badHandler, () => {

@@ -433,6 +433,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should handle errors using yieldThrows and throws (badHandler)',
"testFn semantic should handle errors using yieldThrows and throws (badHandler)",
testFn(badHandler, () => {

@@ -444,10 +444,10 @@ // prettier-ignore

})
)
);
function* throwImmediately() {
throw new Error('oops!')
throw new Error("oops!");
}
test(
'testFn semantic should handle errors thrown immediately',
"testFn semantic should handle errors thrown immediately",
testFn(throwImmediately, () => {

@@ -458,6 +458,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should handle errors without returns (badHandler)',
"testFn semantic should handle errors without returns (badHandler)",
testFn(badHandler, () => {

@@ -468,6 +468,6 @@ // prettier-ignore

})
)
);
test(
'testFnV2 should handle errors (badHandler)',
"testFnV2 should handle errors (badHandler)",
testFnV2(badHandler, () => {

@@ -481,3 +481,3 @@ // prettier-ignore

})
)
);

@@ -487,3 +487,3 @@ // Either test empty

test(
'testFn should pass (eitherTestEmpty)',
"testFn should pass (eitherTestEmpty)",
testFn(eitherTestEmpty, () => {

@@ -496,6 +496,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should pass (eitherTestEmpty)',
"testFn semantic should pass (eitherTestEmpty)",
testFn(eitherTestEmpty, () => {

@@ -507,6 +507,6 @@ // prettier-ignore

})
)
);
test(
'testFnV2 should pass (eitherTestEmpty)',
"testFnV2 should pass (eitherTestEmpty)",
testFnV2(eitherTestEmpty, () => {

@@ -520,3 +520,3 @@ // prettier-ignore

})
)
);

@@ -526,3 +526,3 @@ // Async cmd

test(
'testFn should pass (asyncTest)',
"testFn should pass (asyncTest)",
testFn(asyncTest, () => {

@@ -535,6 +535,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic should pass (asyncTest)',
"testFn semantic should pass (asyncTest)",
testFn(asyncTest, () => {

@@ -546,6 +546,6 @@ // prettier-ignore

})
)
);
test(
'testFnV2 should pass (asyncTest)',
"testFnV2 should pass (asyncTest)",
testFnV2(asyncTest, () => {

@@ -559,3 +559,3 @@ // prettier-ignore

})
)
);

@@ -566,7 +566,7 @@ // Return cmd result

function* returnCmdResult() {
return yield cmds.echo('foo')
return yield cmds.echo("foo");
}
test(
'testFn semantic should return cmd result',
"testFn semantic should return cmd result",
testFn(returnCmdResult, () => {

@@ -577,3 +577,3 @@ // prettier-ignore

})
)
);

@@ -583,8 +583,8 @@ // Throw from semantic test builder

function* throwSemantic() {
const value = yield cmds.echo('foo')
throw new Error('oops')
const value = yield cmds.echo("foo");
throw new Error("oops");
}
test(
'testFn semantic should throw if .throws is used',
"testFn semantic should throw if .throws is used",
testFn(throwSemantic, () => {

@@ -596,5 +596,5 @@ // prettier-ignore

})
)
);
test('testFn should throw proper error if function throws incorrect error', () => {
test("testFn should throw proper error if function throws incorrect error", () => {
try {

@@ -606,9 +606,9 @@ testFn(throwSemantic, () => {

.throws(new Error("wrong"))
})()
})();
} catch (e) {
deepEqual(e.name, 'Error on Step 2')
return
deepEqual(e.name, "Error on Step 2");
return;
}
throw new Error('Failed: Did not throw')
})
throw new Error("Failed: Did not throw");
});

@@ -618,3 +618,3 @@ // Single line

test(
'single line should pass',
"single line should pass",
testSingleLine(() => {

@@ -627,6 +627,6 @@ // prettier-ignore

})
)
);
test(
'testFn semantic single line should not fail',
"testFn semantic single line should not fail",
testSingleLine(() => {

@@ -638,5 +638,5 @@ // prettier-ignore

})
)
);
test('testFn should give proper error message if yielding array but no results', () => {
test("testFn should give proper error message if yielding array but no results", () => {
try {

@@ -648,14 +648,14 @@ testYieldArray(() => {

]
})()
})();
} catch (e) {
deepEqual(
e.message,
'Your spec does not have as many steps as your function. Are you missing a return line?'
)
"Your spec does not have as many steps as your function. Are you missing a return line?"
);
}
})
});
test('testFn should give proper error message if spec is returning undefined', () => {
test("testFn should give proper error message if spec is returning undefined", () => {
try {
testYieldArray(() => {})()
testYieldArray(() => {})();
} catch (e) {

@@ -665,11 +665,11 @@ deepEqual(

'Your spec must return an array of tuples. It is currently returning a value of type "undefined".'
)
);
}
})
});
test('testFn should give proper error message if spec is returning an object', () => {
test("testFn should give proper error message if spec is returning an object", () => {
try {
testYieldArray(() => {
return {}
})()
return {};
})();
} catch (e) {

@@ -679,11 +679,11 @@ deepEqual(

'Your spec must return an array of tuples. It is currently returning a value of type "object".'
)
);
}
})
});
test('testFn should give proper error message if spec is returning an string', () => {
test("testFn should give proper error message if spec is returning an string", () => {
try {
testYieldArray(() => {
return 'what?'
})()
return "what?";
})();
} catch (e) {

@@ -693,4 +693,4 @@ deepEqual(

'Your spec must return an array of tuples. It is currently returning a value of type "string".'
)
);
}
})
});

@@ -1,68 +0,68 @@

const assert = require('assert')
const curry = require('lodash/curry')
const chunk = require('lodash/chunk')
const { deepEqual } = require('./specs/test-util')
const assert = require("assert");
const curry = require("lodash/curry");
const chunk = require("lodash/chunk");
const { deepEqual } = require("./specs/test-util");
const testRunner = (fn, expected, index = 0, previousOutput = null) => {
checkForExpectedTypeMismatches(expected)
checkForExpectedTypeMismatches(expected);
assert(fn, 'The function you are trying to test is undefined.')
assert(fn, "The function you are trying to test is undefined.");
const step = expected[index]
const step = expected[index];
if (step === undefined) {
throw new Error(
'Your spec does not have as many steps as your function. Are you missing a return line?'
)
"Your spec does not have as many steps as your function. Are you missing a return line?"
);
}
const [input, expectedOutput] = step
const [input, expectedOutput] = step;
if (index === 0 && !Array.isArray(input)) {
throw new Error(
'The first argument of the first tuple must be an array representing the arguments of the function.'
)
"The first argument of the first tuple must be an array representing the arguments of the function."
);
}
let g
let g;
if (fn.next) {
g = fn
g = fn;
} else {
g = fn.apply(null, input)
g = fn.apply(null, input);
}
let output
let output;
if (isError(input)) {
try {
output = g.throw(input)
output = g.throw(input);
} catch (e) {
output = { value: e, done: true }
output = { value: e, done: true };
}
} else {
try {
output = g.next(input)
output = g.next(input);
} catch (e) {
output = { value: e, done: true }
output = { value: e, done: true };
}
}
const endOnError = isError(output.value)
const endOnError = isError(output.value);
try {
deepEqual(output.value, expectedOutput)
if (endOnError) return
deepEqual(output.value, expectedOutput);
if (endOnError) return;
} catch (e) {
const stepError = `Error on Step ${index + 1}`
e.name = stepError
e.stack = `${stepError}\n\n${e.stack}`
throw e
const stepError = `Error on Step ${index + 1}`;
e.name = stepError;
e.stack = `${stepError}\n\n${e.stack}`;
throw e;
}
if (!output.done || index + 1 < expected.length) {
testRunner(g, expected, index + 1, output.value)
testRunner(g, expected, index + 1, output.value);
}
}
};
function isError(e) {
if (!e) return false
return e instanceof Error
if (!e) return false;
return e instanceof Error;
}

@@ -74,8 +74,8 @@

`Your spec must return an array of tuples. It is currently returning a value of type "${typeof expected}".`
)
);
}
for (let i = 0; i < expected.length; i++) {
if (i + 1 >= expected.length) return
let output = expected[i][1]
let nextInput = expected[i + 1][0]
if (i + 1 >= expected.length) return;
let output = expected[i][1];
let nextInput = expected[i + 1][0];

@@ -85,36 +85,36 @@ if (Array.isArray(output)) {

Array.isArray(nextInput),
'If an array of actions is yielded, it should return an array of results.'
)
"If an array of actions is yielded, it should return an array of results."
);
}
}
}
};
const testFn = (fn, spec) => {
return function() {
let expectedLog = spec()
testRunner(fn, expectedLog)
}
}
let expectedLog = spec();
testRunner(fn, expectedLog);
};
};
const testFnV2 = (fn, spec) => {
return function() {
let expectedLog = spec()
let expectedLog = spec();
const flat = expectedLog.reduce((p, step, index, log) => {
if (index === 0 || index === log.length - 1) {
p.push(step)
return p
p.push(step);
return p;
}
p.push(step[0])
p.push(step[1])
return p
}, [])
const v1Log = chunk(flat, 2)
testRunner(fn, v1Log)
}
}
p.push(step[0]);
p.push(step[1]);
return p;
}, []);
const v1Log = chunk(flat, 2);
testRunner(fn, v1Log);
};
};
// Semantic test builder
const args = (...fnArgs) => {
const t = [[fnArgs]]
const t = [[fnArgs]];
return {

@@ -124,7 +124,7 @@ yieldCmd: yieldCmd(t),

returns: returns(t)
}
}
};
};
const yieldCmd = t => v => {
t[t.length - 1][1] = v
t[t.length - 1][1] = v;
return {

@@ -135,7 +135,7 @@ yieldReturns: yieldReturns(t),

returns: returnCmdResult(t)
}
}
};
};
const yieldReturns = t => v => {
t[t.length] = [v]
t[t.length] = [v];

@@ -146,24 +146,24 @@ return {

returns: returns(t)
}
}
};
};
const returnCmdResult = t => v => {
t[t.length] = [v, v]
return t
}
t[t.length] = [v, v];
return t;
};
const yieldReturnThrows = t => v => {
t[t.length] = [v, v]
return t
}
t[t.length] = [v, v];
return t;
};
const throwAfterCmdReturns = t => v => {
t[t.length - 1][1] = v
return t
}
t[t.length - 1][1] = v;
return t;
};
const returns = t => a => {
t[t.length - 1][1] = a
return t
}
t[t.length - 1][1] = a;
return t;
};

@@ -179,2 +179,2 @@ // Modified tuples

args
}
};
function isGenerator(fn) {
return fn && fn.constructor && fn.constructor.name === "GeneratorFunction"
return fn && fn.constructor && fn.constructor.name === "GeneratorFunction";
}
function toArray(a) {
return Array.isArray(a) ? a : [a]
return Array.isArray(a) ? a : [a];
}
const isPromise = v => v && v.then
const toPromise = v => (isPromise(v) ? v : Promise.resolve(v))
const isPromise = v => v && v.then;
const toPromise = v => (isPromise(v) ? v : Promise.resolve(v));
const delay =
typeof setImmediate === undefined ? fn => setTimeout(fn, 0) : setImmediate
typeof setImmediate === undefined ? fn => setTimeout(fn, 0) : setImmediate;

@@ -34,3 +34,3 @@ // @see https://gist.github.com/LeverOne/1308368

);
return b
return b;
}

@@ -44,2 +44,2 @@

uuid
}
};

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

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

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc