brak() fix

This commit is contained in:
alex 2022-05-09 17:24:49 +02:00
parent 4fd843f8cf
commit a8d676641b

View File

@ -67,7 +67,7 @@ export class Pattern {
* @param {Function} func the function to apply * @param {Function} func the function to apply
* @returns Pattern * @returns Pattern
*/ */
withQueryTime(func) { withQueryTime(func) {
return new Pattern((state) => this.query(state.withSpan((span) => span.withTime(func)))); return new Pattern((state) => this.query(state.withSpan((span) => span.withTime(func))));
} }
@ -88,7 +88,7 @@ export class Pattern {
* @param {Function} func the function to apply * @param {Function} func the function to apply
* @returns Pattern * @returns Pattern
*/ */
withHapTime(func) { withHapTime(func) {
return this.withHapSpan((span) => span.withTime(func)); return this.withHapSpan((span) => span.withTime(func));
} }
@ -97,7 +97,7 @@ export class Pattern {
* @param {Function} func * @param {Function} func
* @returns Pattern * @returns Pattern
*/ */
_withHaps(func) { _withHaps(func) {
return new Pattern((state) => func(this.query(state))); return new Pattern((state) => func(this.query(state)));
} }
@ -106,7 +106,7 @@ export class Pattern {
* @param {Function} func * @param {Function} func
* @returns Pattern * @returns Pattern
*/ */
_withHap(func) { _withHap(func) {
return this._withHaps((haps) => haps.map(func)); return this._withHaps((haps) => haps.map(func));
} }
@ -193,7 +193,7 @@ export class Pattern {
/** /**
* see {@link Pattern#withValue|withValue} * see {@link Pattern#withValue|withValue}
*/ */
fmap(func) { fmap(func) {
return this.withValue(func); return this.withValue(func);
} }
@ -231,7 +231,7 @@ export class Pattern {
* as its `part` timespan. * as its `part` timespan.
* @returns Pattern * @returns Pattern
*/ */
onsetsOnly() { onsetsOnly() {
// Returns a new pattern that will only return haps where the start // Returns a new pattern that will only return haps where the start
// of the 'whole' timespan matches the start of the 'part' // of the 'whole' timespan matches the start of the 'part'
// timespan, i.e. the haps that include their 'onset'. // timespan, i.e. the haps that include their 'onset'.
@ -829,7 +829,7 @@ export class Pattern {
* @returns Pattern * @returns Pattern
*/ */
brak() { brak() {
return this.every(2, x => fastcat(x, silence)._late(0.25)) return this.when(slowcat(false, true), (x) => fastcat(x, silence)._late(0.25));
} }
rev() { rev() {
@ -989,7 +989,7 @@ function _composeOp(a, b, func) {
} }
// Make composers // Make composers
(function() { (function () {
const num = (pat) => pat._asNumber(); const num = (pat) => pat._asNumber();
const numOrString = (pat) => pat._asNumber(false, true); const numOrString = (pat) => pat._asNumber(false, true);