Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frando/smoosh-stream
Flatten an array and pass to a callback. Useful with e.g. bulk-write-stream.
https://github.com/frando/smoosh-stream
Last synced: about 1 month ago
JSON representation
Flatten an array and pass to a callback. Useful with e.g. bulk-write-stream.
- Host: GitHub
- URL: https://github.com/frando/smoosh-stream
- Owner: Frando
- License: mit
- Created: 2018-03-24T13:02:13.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-24T23:14:08.000Z (almost 7 years ago)
- Last Synced: 2024-10-16T13:07:10.245Z (3 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smoosh-stream
A function to flatten an array and call a passed-in callback. Useful e.g. with [bulk-write-stream](https://github.com/mafintosh/bulk-write-stream) to accept arrays and single objects likewise and always get a flattened array in the write callback.
# Installation
`npm install smoosh-stream`
## Usage
``` js
var smoosh = require('smoosh-stream')
var bulk = require('bulk-write-stream')var stream = bulk.obj(smoosh(write))
function write (batch, cb) {
batch.forEach(function (obj) {
console.log(obj)
})
cb(null)
}stream.write('first')
stream.write(['second', 'third'])
stream.write(['forth'])
stream.write('last')// Prints:
// first
// second
// third
// forth
// last```
## License
MIT