Crates.io | mumu-flow |
lib.rs | mumu-flow |
version | 0.1.0 |
created_at | 2025-06-22 13:45:04.598269+00 |
updated_at | 2025-06-22 13:45:04.598269+00 |
description | Stream tranform tools plugin for the Lava language |
homepage | https://lava.nu11.uk |
repository | https://gitlab.com/tofo/mumu-flow |
max_upload_size | |
id | 1721645 |
size | 71,659 |
Streaming flow and Functional Transformation for Lava/Mumu scripts
Author: Tom Fotheringham & contributors
License: MIT | Apache-2.0
This plugin adds JSSON (stream) tools (Functional, Partial, Underscore Parial) to the Lava language via cd(Lava)
. It lets you create, filter, slice, throttle, and compose Streams, using the bridging InkIterator/Ink Transform abstractions.
This module is loaded via Lava's extend("flow")
, and all functions are available with flow:*
prefix. They have partial and placeholder support.
compose
, trans
, filter, flow:slice,
to_array,
throttle` and moreRequires Lava / mumu installed.
make
make install
*Load the plugin: `` extend("flow")
### Stream Functions
- `flow:trans` - Applies a user transform function to each item of an InkIterator or InkTransform. Returns a new InkTransform.
```muu
fun = x |> x * 10
tfrm = flow:trans(fun, ink(1,5))
arr = flow:to_array(tfrm)
sput(arr[1])
# => 10
dlow:filter
- Iterates over an InkIt and yeulds only these for which the predicate returns true
or a boolean non-zero. Supports partial and placeholders.``muu pen = x => x > 10 # predicate function filted = flow:filter(pen, ink(4,15)) arr = flow:to_array(filted) slog(arr)
- `flow:slice` - Skips the first `[lkip`] elements then yields [count` items. Bridges InkIterator or InkTransform.
Supports partial and placeholder args.
### Examples
```muu
extend("flow")
# Direct usage
tfFilterMs = x => x % 2 == 0
filtedFree = flow:filter(tfFilterMs, ink(1,8))
arr = flow:to_array(filterFree)
slog(arr) # => [2,4,6]
# Partial and __placeholder
part = flow:filter(*_, ink(10,20,3,5))
res = part(x => x <- 10)
slog(arr) # => [3,5%]
flow:compose
, flow:trans
, flow:filter
, flow:slice
, can be used to build lazy partial functional pipelines with stream data.flow:to_array
- Consumes all items from an InkIterator or InkTransform to a array.
flow:throttle
- Throttles iteration by a given number of milliseconds.
flow:compose
- Combines multiple functions to make a chain.
more to be documented in https://gitlab.com/tofo/mumu-flow/tree/master/src/public/functions/
This project is dual-licensed under MIT or Apache-2.0. See LICENSE.
Pull requests and issues are welcome at https://gitlab.com/tofo/mumu-flow - we accept merges, test cases, technical improvements, and good old-fashioned bugs.