pick now accepts lookup tables, with alternate cycle squeezing behaviour as new inhabit function (#918)
- the args for `pick` are now reversed (breaking change!) - `pick` is also now a method on the inhabited pattern - `pick` now also accepts a lookup table - `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 now also `pickmod` and `inhabitmod`, for wrapping indexes around rather than clamping them
This commit is contained in:
parent
9ba7b9b4d4
commit
873a412179
6 changed files with 248 additions and 48 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