From 00c7da45c0a43fb285e217b1375482667bffadc5 Mon Sep 17 00:00:00 2001 From: eefano <77832+eefano@users.noreply.github.com> Date: Sun, 18 Feb 2024 18:55:05 +0100 Subject: [PATCH] Update signal.mjs now pickRestart() and pickReset() --- packages/core/signal.mjs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/core/signal.mjs b/packages/core/signal.mjs index 7bc97c7b..e468b0d1 100644 --- a/packages/core/signal.mjs +++ b/packages/core/signal.mjs @@ -249,22 +249,39 @@ export const pickmodF = register('pickmodF', function (lookup, funcs, pat) { * @param {*} xs * @returns {Pattern} */ -export const pickr = register('pickr', function (lookup, pat) { +export const pickRestart = register('pickRestart', function (lookup, pat) { return _pick(lookup, pat, false).trigzeroJoin(); }); /** * The same as `pickr`, but if you pick a number greater than the size of the list, * it wraps around, rather than sticking at the maximum value. - * For example, if you pick the fifth pattern of a list of three, you'll get the - * second one. * @param {Pattern} pat * @param {*} xs * @returns {Pattern} */ -export const pickrmod = register('pickrmod', function (lookup, pat) { +export const pickmodRestart = register('pickmodRestart', function (lookup, pat) { return _pick(lookup, pat, true).trigzeroJoin(); }); +/** * Similar to `pick`, but the choosen pattern is reset when its index is triggered. + * @param {Pattern} pat + * @param {*} xs + * @returns {Pattern} + */ +export const pickReset = register('pickReset', function (lookup, pat) { + return _pick(lookup, pat, false).trigJoin(); +}); + +/** * The same as `pickr`, but if you pick a number greater than the size of the list, + * it wraps around, rather than sticking at the maximum value. + * @param {Pattern} pat + * @param {*} xs + * @returns {Pattern} + */ +export const pickmodReset = register('pickmodReset', function (lookup, pat) { + return _pick(lookup, pat, true).trigJoin(); +}); + /** /** * Picks patterns (or plain values) either from a list (by index) or a lookup table (by name). * Similar to `pick`, but cycles are squeezed into the target ('inhabited') pattern.