Skip to content

Instantly share code, notes, and snippets.

@tpot
Created August 5, 2022 05:28
Show Gist options
  • Save tpot/8abdc7e0364d5f9c8123840e63b0edeb to your computer and use it in GitHub Desktop.
Save tpot/8abdc7e0364d5f9c8123840e63b0edeb to your computer and use it in GitHub Desktop.
Test stream creation in nbb
(ns stream-test
(:require [cljs.pprint :refer [pprint]]
["readable-stream" :as stream]))
(def number-stream
(new stream.Readable
#js{:objectMode true
:read (fn [count] (.push js/this 42))}))
(-> number-stream
(.on "data" (fn [chunk] (pprint (list "got" chunk))))
(.on "error" (fn [err] (pprint (list "err" err)))))
;; ("err" #object[TypeError TypeError: Cannot read property 'push' of undefined])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment