Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5aa635a
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/build/* | ||
node_modules | ||
*.node | ||
*.sh | ||
*.swp | ||
.lock* | ||
npm-debug.log | ||
.idea |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "pullstream", | ||
"version": "0.0.1", | ||
"description": "A stream you can pull data from.", | ||
"main": "pullstream.js", | ||
"scripts": { | ||
"test": "./node_modules/.bin/tap --stderr ./test/" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"tap": "~0.3.0", | ||
"stream-buffers": "~0.2.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
module.exports = PullStream; | ||
|
||
var inherits = require("util").inherits; | ||
var Stream = require('stream').Stream; | ||
|
||
function PullStream() { | ||
Stream.apply(this); | ||
this.readable = false; | ||
this.writable = true; | ||
} | ||
inherits(PullStream, Stream); | ||
|
||
PullStream.prototype.write = function (data) { | ||
this.process(data, false); | ||
}; | ||
|
||
PullStream.prototype.end = function (data) { | ||
this.process(data, true); | ||
}; | ||
|
||
PullStream.prototype.process = function (data, end) { | ||
if (end) { | ||
this.emit('end'); | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
var test = require('tap').test; | ||
var streamBuffers = require("stream-buffers"); | ||
var PullStream = require('../'); | ||
|
||
test("source sending 1-byte at a time", function (t) { | ||
var ps = new PullStream(); | ||
ps.on('end', function () { | ||
t.end(); | ||
}); | ||
|
||
var sourceStream = new streamBuffers.ReadableStreamBuffer({ | ||
frequency: 0, | ||
chunkSize: 1 | ||
}); | ||
|
||
sourceStream.pipe(ps); | ||
}); | ||
|