add internals doc

This commit is contained in:
Felix Roos 2023-01-11 22:48:47 +01:00
parent a120a9895b
commit d5f37e2cbe
3 changed files with 202 additions and 4 deletions

View file

@ -39,8 +39,11 @@ export class Pattern {
/**
* Returns a new pattern, with the function applied to the value of
* each hap. It has the alias {@link Pattern#fmap}.
* @param {Function} func
* @synonyms fmap
* @param {Function} func to to apply to the value
* @returns Pattern
* @example
* "0 1 2".withValue(v => v + 10).log()
*/
withValue(func) {
return new Pattern((state) => this.query(state).map((hap) => hap.withValue(func)));
@ -53,10 +56,15 @@ export class Pattern {
return this.withValue(func);
}
/**
* Assumes 'this' is a pattern of functions, and given a function to
* resolve wholes, applies a given pattern of values to that
* pattern of functions.
* @param {Function} whole_func
* @param {Function} func
* @returns Pattern
*/
appWhole(whole_func, pat_val) {
// Assumes 'this' is a pattern of functions, and given a function to
// resolve wholes, applies a given pattern of values to that
// pattern of functions.
const pat_func = this;
const query = function (state) {
const hap_funcs = pat_func.query(state);