Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gobengo/stream-slice

slice streams (e.g. to make an infinite one N-finite)
https://github.com/gobengo/stream-slice

Last synced: 25 days ago
JSON representation

slice streams (e.g. to make an infinite one N-finite)

Awesome Lists containing this project

README

        

# stream-slice

Create a [stream](https://github.com/Livefyre/stream)/Transform that slices a stream piped into it. For example, take an infinite [stream-cycle](https://github.com/gobengo/stream-cycle) and limit it to N objects.

A lot like Python's [itertools.islice](https://docs.python.org/2/library/itertools.html#itertools.islice)

## Example

```javascript
var cycle = require('stream-cycle');
var slice = require('stream-slice');

var infinite = cycle([1,0]);
var only5 = infinite.pipe(slice(100));
only5
.on('end', function () {
console.log('ended after 5');
})
.on('data', console.log);

// 1
// 0
// 1
// 0
// 1
// ended after 5
```

## `make` commands

* `make build` - will `npm install` and `bower install`
* `make dist` - will use r.js optimizer to compile the source, UMD wrap, and place that and source maps in dist/
* `make clean`
* `make server` - serve the repo over http
* `make deploy [env={*prod,uat,qa}]` - Deploy to lfcdn, optionally specifying a bucket env