Added note about pattern alignment

This commit is contained in:
tyow 2026-02-14 16:13:37 -05:00
parent 7cb8a151a4
commit 161d2ce056

View file

@ -1060,7 +1060,12 @@ const COMPOSERS = {
* When called on a pattern `a`, with a input pattern `b` (`a.set(b)`), * When called on a pattern `a`, with a input pattern `b` (`a.set(b)`),
* combines `a` and `b` such that anything defined in `b` * combines `a` and `b` such that anything defined in `b`
* and anything defined in `a` that is *not* defined in `b` * and anything defined in `a` that is *not* defined in `b`
* will be in the resulting pattern * will be in the resulting pattern.
*
* The structure is maintained from `a`,
* because the default pattern alignment is `in`,
* see the section on `Pattern Alignment`
* in the technical manual in the docs
* *
* This is the inverse of `keep` * This is the inverse of `keep`
* *
@ -1074,27 +1079,17 @@ const COMPOSERS = {
* // because input pattern has `s` set, * // because input pattern has `s` set,
* // it overrides the "sine" declared earlier * // it overrides the "sine" declared earlier
* note("c a f e").s("sine").set(s("triangle")) * note("c a f e").s("sine").set(s("triangle"))
* @example
* // Structure from original pattern is
* // maintained, even when explicitly set
* note("c a f e").s("sine").set(note("c a")
* .struct("x!8"))
* @example
* // Using something like `apply`, we can
* // invert which pattern overrides the other
* // Here, the struct will be "x!8", and the
* // notes will be c c a a f f e e
* note("c a f e").apply(x=>{
* // pure(0) here is used as a dummy pattern
* return pure(0).struct("x!8").set(x)
* })
*/
set: [(a, b) => b], set: [(a, b) => b],
/** /**
* When called on a pattern `a`, with a input pattern `b` (`a.keep(b)`), * When called on a pattern `a`, with a input pattern `b` (`a.keep(b)`),
* combines `a` and `b` such that anything defined in `a`, * combines `a` and `b` such that anything defined in `a`,
* and anything defined in `b` that is *not* defined in `a` * and anything defined in `b` that is *not* defined in `a`
* will be in the resulting pattern * will be in the resulting pattern
*
* The structure is maintained from `a`,
* because the default pattern alignment is `in`,
* see the section on `Pattern Alignment`
* in the technical manual in the docs
* *
* This is the inverse of `set` * This is the inverse of `set`
* *
@ -1105,10 +1100,9 @@ const COMPOSERS = {
* @returns {Pattern} * @returns {Pattern}
* @tags internal, combiners * @tags internal, combiners
* @example * @example
* // Struct, already defined in original pattern * // notes, already defined, will stay "c a f e",
* // Is combined with the input, such that we get * // while "s", not defined, will be set to "piano"
* // c c a a f f e e * note("c a f e").keep(note("e f a c").s("piano"))
* pure(0).struct("x!8").keep(note("c a f e"))
*/ */
keep: [(a) => a], keep: [(a) => a],
keepif: [(a, b) => (b ? a : undefined)], keepif: [(a, b) => (b ? a : undefined)],