mirror of
https://codeberg.org/uzu/strudel
synced 2026-08-05 22:52:21 -04:00
squeezeBind itself + tidying
This commit is contained in:
@@ -583,7 +583,7 @@ class Pattern {
|
||||
return this.innerBind(id);
|
||||
}
|
||||
|
||||
squeezeJoin() {
|
||||
_squeezeJoin() {
|
||||
const pat_of_pats = this;
|
||||
function query(state) {
|
||||
const haps = pat_of_pats.query(state);
|
||||
@@ -616,6 +616,10 @@ class Pattern {
|
||||
return new Pattern(query);
|
||||
}
|
||||
|
||||
_squeezeBind(func) {
|
||||
return this.fmap(func).squeezeBind();
|
||||
}
|
||||
|
||||
_apply(func) {
|
||||
return func(this);
|
||||
}
|
||||
@@ -678,7 +682,7 @@ class Pattern {
|
||||
}
|
||||
|
||||
_ply(factor) {
|
||||
return this.fmap(x => pure(x)._fast(factor)).squeezeJoin()
|
||||
return this.fmap(x => pure(x)._fast(factor))._squeezeJoin()
|
||||
}
|
||||
|
||||
// cpm = cycles per minute
|
||||
|
||||
@@ -491,10 +491,10 @@ describe('Pattern', function() {
|
||||
)
|
||||
})
|
||||
})
|
||||
describe("squeezeJoin", () => {
|
||||
describe("_squeezeJoin", () => {
|
||||
it("Can squeeze", () => {
|
||||
assert.deepStrictEqual(
|
||||
sequence("a", ["a","a"]).fmap(a => fastcat("b", "c")).squeezeJoin().firstCycle(),
|
||||
sequence("a", ["a","a"]).fmap(a => fastcat("b", "c"))._squeezeJoin().firstCycle(),
|
||||
sequence(["b", "c"],[["b", "c"],["b", "c"]]).firstCycle()
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user