aboutsummaryrefslogtreecommitdiffstats
path: root/lib/util.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-03-18 17:50:33 +0000
committers-ol <s-ol@users.noreply.github.com>2020-03-18 18:03:04 +0000
commita49382c7b46c7bdf1c105c0783c7bdcd0bb70e4a (patch)
treec1f800736e1905514aa913630ee31a720e770c9e /lib/util.moon
parentdocs/internal: add builtins and invoke modules (diff)
downloadalive-a49382c7b46c7bdf1c105c0783c7bdcd0bb70e4a.tar.gz
alive-a49382c7b46c7bdf1c105c0783c7bdcd0bb70e4a.zip
fork ops before eval cycle
Diffstat (limited to 'lib/util.moon')
-rw-r--r--lib/util.moon33
1 files changed, 2 insertions, 31 deletions
diff --git a/lib/util.moon b/lib/util.moon
index 79ee721..1fddca4 100644
--- a/lib/util.moon
+++ b/lib/util.moon
@@ -71,35 +71,6 @@ when i is a num, it is (floor)ed and the matching argument (starting from 0) is
if active and active\dirty!
@out\set active!
---class switch_pause extends Op
--- @doc: "(switch- i v0 [v1 v2...]) - switch and pause multiple inputs
---
---like (switch ...) except that the unused inputs are paused."
---
--- setup: (@i, ...) =>
--- @choices = { ... }
---
--- typ = @choices[1].type
--- for inp in *@choices[2,]
--- assert inp.type == typ, "not all values have the same type: #{typ} != #{inp.type}"
---
--- @out = Stream typ
--- @out
---
--- tick: =>
--- i = @i\unwrap!
--- active = switch i
--- when true
--- @choices[1]
--- when false
--- @choices[2]
--- else
--- i = 1 + (math.floor i) % #@choices
--- @choices[i]
---
--- @out\set if active
--- active\unwrap!
-
class edge extends Op
@doc: "(edge bool) - convert rising edges to bangs"
new: => super 'bang'
@@ -110,9 +81,9 @@ class edge extends Op
tick: =>
now = @inputs.value!
- if now and not @last
+ if now and not @state.last
@out\set true
- @last = now
+ @state.last = now
class default extends Op
@doc: "(default stream default) - provide a default value for an event stream