length-prefixed-stream
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -42,3 +42,3 @@ var varint = require('varint') | ||
if (missing <= free) { // fast track - no copy | ||
this._push(data.slice(offset, missing)) | ||
this._push(data.slice(offset, offset+missing)) | ||
return offset+missing | ||
@@ -45,0 +45,0 @@ } |
{ | ||
"name": "length-prefixed-stream", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Streaming length prefixed buffers", | ||
@@ -10,2 +10,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"concat-stream": "^1.4.6", | ||
"tape": "^2.14.0", | ||
@@ -12,0 +13,0 @@ "through2": "^0.6.1" |
@@ -10,2 +10,4 @@ # length-prefixed-stream | ||
[![build status](http://img.shields.io/travis/mafintosh/length-prefixed-stream.svg?style=flat)](http://travis-ci.org/mafintosh/length-prefixed-stream) | ||
## Usage | ||
@@ -12,0 +14,0 @@ |
18
test.js
var tape = require('tape') | ||
var through = require('through2') | ||
var concat = require('concat-stream') | ||
var lpstream = require('./') | ||
@@ -30,2 +31,19 @@ | ||
tape('buffered encode -> buffered decode', function(t) { | ||
var e = lpstream.encode() | ||
var d = lpstream.decode() | ||
d.on('data', function(data) { | ||
t.same(data.toString(), 'hello world') | ||
t.end() | ||
}) | ||
e.write('hello world') | ||
e.end() | ||
e.pipe(concat(function(data) { | ||
d.end(data) | ||
})) | ||
}) | ||
tape('encode -> decode twice', function(t) { | ||
@@ -32,0 +50,0 @@ t.plan(2) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8511
9
214
31
3