mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 13:48:40 +00:00
add some module level curried aliases
This commit is contained in:
parent
d6c22d516b
commit
fa59334a46
12
strudel.mjs
12
strudel.mjs
@ -632,6 +632,14 @@ function pr(args) {
|
||||
polyrhythm(args)
|
||||
}
|
||||
|
||||
export {Fraction, TimeSpan, Hap, Pattern,
|
||||
pure, stack, slowcat, fastcat, cat, sequence, polymeter, pm, polyrhythm, pr, reify, silence}
|
||||
const fast = curry((a, pat) => pat.fast(a))
|
||||
const slow = curry((a, pat) => pat.slow(a))
|
||||
const early = curry((a, pat) => pat.early(a))
|
||||
const late = curry((a, pat) => pat.late(a))
|
||||
const rev = pat => pat.rev()
|
||||
|
||||
export {Fraction, TimeSpan, Hap, Pattern,
|
||||
pure, stack, slowcat, fastcat, cat, sequence, polymeter, pm, polyrhythm, pr, reify, silence,
|
||||
fast, slow, early, late, rev
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ import Fraction from 'fraction.js'
|
||||
|
||||
import { strict as assert } from 'assert';
|
||||
|
||||
import {TimeSpan, Hap, Pattern, pure, stack, fastcat, slowcat, cat, sequence, polyrhythm, silence} from "../strudel.mjs";
|
||||
import {TimeSpan, Hap, Pattern, pure, stack, fastcat, slowcat, cat, sequence, polyrhythm, silence, fast} from "../strudel.mjs";
|
||||
|
||||
const ts = (begin, end) => new TimeSpan(Fraction(begin), Fraction(end));
|
||||
const hap = (whole, part, value) => new Hap(whole, part, value)
|
||||
@ -104,6 +104,18 @@ describe('Pattern', function() {
|
||||
sequence(1,2,3).fast(1.5,2).firstCycle
|
||||
)
|
||||
})
|
||||
it("works as a static function", function () {
|
||||
assert.deepStrictEqual(
|
||||
sequence(1,2,3).fast(1,2).firstCycle,
|
||||
fast(sequence(1,2), sequence(1,2,3)).firstCycle
|
||||
)
|
||||
})
|
||||
it("works as a curried static function", function () {
|
||||
assert.deepStrictEqual(
|
||||
sequence(1,2,3).fast(1,2).firstCycle,
|
||||
fast(sequence(1,2))(sequence(1,2,3)).firstCycle
|
||||
)
|
||||
})
|
||||
})
|
||||
describe('_slow()', function () {
|
||||
it('Makes things slower', function () {
|
||||
@ -176,5 +188,11 @@ describe('Pattern', function() {
|
||||
sequence(sequence("a", "a"), "a", "a").firstCycle
|
||||
)
|
||||
})
|
||||
it("works with currying", () => {
|
||||
assert.deepStrictEqual(
|
||||
pure("a").every(3, fast(2))._fast(3).firstCycle,
|
||||
sequence(sequence("a", "a"), "a", "a").firstCycle
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user