pick, pickmod, inhabit, inhabitmod (#921)
* the args for `pick` are now reversed as standard (old behaviour still supported to avoid breaking change) * `pick` is also now a pattern method * `pick` now also accepts a lookup table for pick-by-name as an alternative to pick-by-index from a list * `inhabit` added with same behaviour as `pick`, except cycles from source patterns are squeezed into events of inhabited patterns * Also some general doc tidying, sorry for the noise.. * There is also `pickmod` and `inhabitmod`, for wrapping indexes around rather than clamping them
This commit is contained in:
parent
a8db707440
commit
98b7859605
6 changed files with 263 additions and 46 deletions
|
|
@ -316,3 +316,10 @@ export function hash2code(hash) {
|
|||
return base64ToUnicode(decodeURIComponent(hash));
|
||||
//return atob(decodeURIComponent(codeParam || ''));
|
||||
}
|
||||
|
||||
export function objectMap(obj, fn) {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(fn);
|
||||
}
|
||||
return Object.fromEntries(Object.entries(obj).map(([k, v], i) => [k, fn(v, k, i)]));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue