Permalink
Browse files

refactor toArray to be a property. update docs

  • Loading branch information...
1 parent 3749552 commit e7ee02af5237b961ed77f61422a5f1b39c289d87 @Raynos committed Sep 21, 2012
Showing with 13 additions and 11 deletions.
  1. +4 −4 README.md
  2. +4 −4 examples/to.js
  3. +5 −3 index.js
View
@@ -5,9 +5,9 @@ Base class for writable streams
## Example array
```
-var to = require("write-stream")
+var toArray = require("write-stream").toArray
, array = []
- , stream = to(array, function end() {
+ , stream = toArray(array, function end() {
/* never called as process.stdin does not end */
})
@@ -22,8 +22,8 @@ setInterval(function () {
## Example function
```
-var to = require("write-stream")
- , stream = to(function write(chunk) {
+var WriteStream = require("write-stream")
+ , stream = WriteStream(function write(chunk) {
// chunks from stdin
})
View
@@ -1,5 +1,5 @@
-var to = require("..")
- , toArray = require("../array")
+var WriteStream = require("..")
+ , toArray = WriteStream.toArray
, Stream = require("readable-stream")
var out1 = toArray([], function (buffer1) {
@@ -9,7 +9,7 @@ var out1 = toArray([], function (buffer1) {
createInput().pipe(out1)
var buffer2 = []
-var out2 = to(function write(chunk) {
+var out2 = WriteStream(function write(chunk) {
buffer2.push(chunk)
}, function end() {
console.log("out", buffer2)
@@ -18,7 +18,7 @@ var out2 = to(function write(chunk) {
createInput().pipe(out2)
var buffer3 = []
-var out3 = to(function write(chunk) {
+var out3 = WriteStream(function write(chunk) {
var stream = this
buffer3.push(chunk)
setTimeout(function () {
View
@@ -1,10 +1,12 @@
var Stream = require("stream")
-to.end = defaultEnd
+WriteStream.end = defaultEnd
-module.exports = to
+module.exports = WriteStream
-function to(write, end) {
+WriteStream.toArray = require("./array")
+
+function WriteStream(write, end) {
var stream = new Stream()
, ended = false

0 comments on commit e7ee02a

Please sign in to comment.