Skip to content
This repository has been archived by the owner on Feb 7, 2021. It is now read-only.
/ pipelining Public archive

Chunked stream client for the browser and Node.js

License

Notifications You must be signed in to change notification settings

wanming/pipelining

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pipelining

Xhr chunked stream client for the browser and node.js

Install

$ npm install pipelining

Usage

Client (browser or node.js)

const pipelining = require('pipelining');

const reader = pipelining('/test');

function handle(data) {
  console.log(data);
}

function read() {
  reader.read().then(partial => {
    if (partial.done) {
      return;
    }

    handle(partial.data).then(read);
  });
}

read()

Server

const pipelining = require('pipelining');
// http handler
function (req, res) {
  res.write(pipelining.pack(1));
  // after several seconds..
  res.write(pipelining.pack({ tom: 'test' }));
  // after 1 min..
  res.end();
}

About

Chunked stream client for the browser and Node.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages