Socket
Socket
Sign inDemoInstall

from

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    from

Easy way to make a Readable Stream


Version published
Weekly downloads
3.6M
increased by3.33%
Maintainers
1
Install size
9.11 kB
Created
Weekly downloads
 

Readme

Source

TravisCI Build Status

from

An easy way to create a readable Stream.

from(function getChunk(count, next))

from takes a getChunk function and returns a stream.

getChunk is called again and again, after each time the user calls next(), until the user emits 'end'

if pause() is called, the getChunk won't be called again untill resume() is called.

var from = require('from')

var stream = 
  from(function getChunk(count, next) {
    //do some sort of data
    this.emit('data', whatever)
    
    if(itsOver)
      this.emit('end')

    //ready to handle the next chunk
    next()
    //or, if it's sync:
    return true 
  })

from(array)

from also takes an Array whose elements it emits one after another.

License

MIT / Apache2

Keywords

FAQs

Last updated on 11 Mar 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc