@dmail/action
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -14,4 +14,2 @@ "use strict"; | ||
var _passed = require("../passed/passed.js"); | ||
var _compose = require("../compose/compose.js"); | ||
@@ -67,6 +65,5 @@ | ||
var createPassedActionWithAllocatedMs = function createPassedActionWithAllocatedMs(allocatedMs) { | ||
var createActionWithAllocatedMs = function createActionWithAllocatedMs(allocatedMs) { | ||
var action = (0, _mixin.mixin)((0, _action.createAction)(), _allocableMsTalent.allocableMsTalent); | ||
action.allocateMs(allocatedMs); | ||
action.pass(); | ||
return action; | ||
@@ -82,4 +79,6 @@ }; | ||
var someHasFailed = false; | ||
var from = createActionWithAllocatedMs(allocatedMs); | ||
from.pass(); | ||
return (0, _compose.compose)({ | ||
from: createPassedActionWithAllocatedMs(allocatedMs), | ||
from: from, | ||
iterator: (0, _compose.createIterator)(iterable), | ||
@@ -132,5 +131,6 @@ composer: function composer(_ref4) { | ||
var nextActionWithAllocableMs = (0, _mixin.mixin)((0, _passed.passed)(nextValue), _allocableMsTalent.allocableMsTalent); | ||
nextActionWithAllocableMs.allocateMs(action.getRemainingMs()); | ||
return nextActionWithAllocableMs; | ||
var nextAction = createActionWithAllocatedMs(); | ||
nextAction.allocateMs(action.getRemainingMs()); | ||
nextAction.pass(nextValue); | ||
return nextAction; | ||
} | ||
@@ -137,0 +137,0 @@ }); |
@@ -85,2 +85,13 @@ "use strict"; | ||
}); | ||
ensure("with action already passed", function () { | ||
var collectAction = (0, _collect.collectSequenceWithAllocatedMs)([(0, _passed.passed)(1)], { | ||
allocatedMs: 10 | ||
}); | ||
(0, _assertions.assertPassed)(collectAction); | ||
_assertions.assert.deepEqual(collectAction.getResult(), [{ | ||
state: "passed", | ||
result: 1 | ||
}]); | ||
}); | ||
ensure("action passed in time", function () { | ||
@@ -87,0 +98,0 @@ var clock = (0, _lolex.install)(); |
{ | ||
"name": "@dmail/action", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -8,3 +8,2 @@ import { | ||
import { createAction } from "../action" | ||
import { passed } from "../passed/passed.js" | ||
import { createIterator, compose } from "../compose/compose.js" | ||
@@ -39,6 +38,5 @@ | ||
const createPassedActionWithAllocatedMs = (allocatedMs) => { | ||
const createActionWithAllocatedMs = (allocatedMs) => { | ||
const action = mixin(createAction(), allocableMsTalent) | ||
action.allocateMs(allocatedMs) | ||
action.pass() | ||
return action | ||
@@ -51,4 +49,7 @@ } | ||
const from = createActionWithAllocatedMs(allocatedMs) | ||
from.pass() | ||
return compose({ | ||
from: createPassedActionWithAllocatedMs(allocatedMs), | ||
from, | ||
iterator: createIterator(iterable), | ||
@@ -86,5 +87,7 @@ composer: ({ action, value, state, index, nextValue, done, fail, pass }) => { | ||
const nextActionWithAllocableMs = mixin(passed(nextValue), allocableMsTalent) | ||
nextActionWithAllocableMs.allocateMs(action.getRemainingMs()) | ||
return nextActionWithAllocableMs | ||
const nextAction = createActionWithAllocatedMs() | ||
nextAction.allocateMs(action.getRemainingMs()) | ||
nextAction.pass(nextValue) | ||
return nextAction | ||
}, | ||
@@ -91,0 +94,0 @@ }) |
@@ -62,2 +62,10 @@ import { collectSequence, collectSequenceWithAllocatedMs } from "./collect.js" | ||
ensure("with action already passed", () => { | ||
const collectAction = collectSequenceWithAllocatedMs([passed(1)], { | ||
allocatedMs: 10, | ||
}) | ||
assertPassed(collectAction) | ||
assert.deepEqual(collectAction.getResult(), [{ state: "passed", result: 1 }]) | ||
}) | ||
ensure("action passed in time", () => { | ||
@@ -64,0 +72,0 @@ const clock = install() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
243666
3889