1. from
Easy way to make a Readable Stream
from
Package: from
Created by: dominictarr
Last modified: Sat, 18 Jun 2022 03:43:06 GMT
Version: 0.1.7
License: MIT
Downloads: 14,371,742
Repository: https://github.com/dominictarr/from

Install

npm install from
yarn add from

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code