https://github.com/theleoborges/lazy-stream
Stream library for Node.js with lazy evaluation
https://github.com/theleoborges/lazy-stream
Last synced: 10 months ago
JSON representation
Stream library for Node.js with lazy evaluation
- Host: GitHub
- URL: https://github.com/theleoborges/lazy-stream
- Owner: theleoborges
- Created: 2012-08-16T22:12:20.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-08-16T22:14:35.000Z (over 13 years ago)
- Last Synced: 2025-01-29T06:49:23.648Z (12 months ago)
- Language: CoffeeScript
- Size: 387 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# lazy-stream
A library for lazy evaluation in Node.js, with support for infinite sequences.
## Creating a stream
stream = require 'stream'
stream.range 9 # naturals from 9 to infinity
stream.cycle [1, 2, 3] # repeats 1, 2, 3 forever
stream.create (-> 2), ((i) -> i*2) # all powers of 2
## Stream operations
myStream.filter (i) -> i%2 == 0 # a new stream with even numbers only
myStream.map (i) -> i*2 # doubles every number in the stream
myStream.take 5 # get the first 5 elements (javascript array)
stream.zip s1, s2, s3 # creates a new steam pairing all streams 1 to 1
## Try the sample code
# in the project folder
> npm install
> npm install -g mocha
> mocha
# all the tests should pass
> coffee src/main.coffee
# lots of prime numbers!
## See the unit tests for more examples...