Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ class Composer {
return Array.prototype.map.call(arguments, x => this.task(x), this).reduce(chain)
}

seq() {
return this.sequence(...arguments)
}

if(test, consequent, alternate) {
if (test == null || consequent == null) throw new ComposerError('Missing arguments in composition', arguments)
const id = {}
Expand Down
9 changes: 7 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('composer', function () {
} catch (error) {
assert.equal(error, 'Error: Invalid composition argument')
}
})
})

it('42 must throw', function () {
try {
Expand All @@ -126,7 +126,7 @@ describe('composer', function () {
} catch (error) {
assert.equal(error, 'Error: Invalid composition argument')
}
})
})

it('{ foo: \'bar\' } must throw', function () {
try {
Expand Down Expand Up @@ -161,6 +161,11 @@ describe('composer', function () {
return invoke(composer.sequence(composer.sequence('TripleAndIncrement', 'DivideByTwo'), 'DivideByTwo'), { n: 5 })
.then(activation => assert.deepEqual(activation.response.result, { n: 4 }))
})

it('seq', function () {
return invoke(composer.seq('TripleAndIncrement', 'DivideByTwo', 'DivideByTwo'), { n: 5 })
.then(activation => assert.deepEqual(activation.response.result, { n: 4 }))
})
})

describe('if', function () {
Expand Down