Skip to content

cPu1/streaming-bencoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

streaming-bencode

A streaming bencode decoder for Node.js written using ECMAScript 6 generators. Can parse any bencoded value in a stream of bencoded values.

Installation

npm install streaming-bencode

Examples:

var bencoder = require('streaming-bencode'),
  ReadableStream = require('stream').Readable;
  
var source = new Readable();

source._read = function () {};

source.push('d5:elistle6:elist2l0:0:0:0:1:12:22e0:0:6:string11:Hello World7:integeri12345e10:dictionaryd3:key36:This is a string within a dictionarye4:listli1ei2ei3ei4e6:stringi5edeee');

source.pipe(bencoder.transformer()).on('data', console.log);

{ elist: [],
  elist2: [ '', '', '', '', '1', '22' ],
  '': '',
  string: 'Hello World',
  integer: 12345,
  dictionary: { key: 'This is a string within a dictionary' },
  list: [ 1, 2, 3, 4, 'string', 5, {} ] }

Example (Decode as you type):

var bencoder = require('streaming-bencode');

process.stdin.setRawMode(true); // override default cooked mode
process.stdin.pipe(bencoder.transformer()).on('data', console.log.bind(console, 'Parsed'));


  

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published