1
1
/*
2
2
3
- db.collection.find().stream().pipe(Streamify ()).pipe(res)
3
+ db.collection.find().stream().pipe(Stringify ()).pipe(res)
4
4
5
5
*/
6
6
var Transform = require ( 'stream' ) . Transform
7
7
var util = require ( 'util' )
8
8
9
- util . inherits ( Streamify , Transform )
9
+ util . inherits ( Stringify , Transform )
10
10
11
- module . exports = Streamify
11
+ module . exports = Stringify
12
12
13
- function Streamify ( options ) {
14
- if ( ! ( this instanceof Streamify ) )
15
- return new Streamify ( options || { } )
13
+ function Stringify ( options ) {
14
+ if ( ! ( this instanceof Stringify ) )
15
+ return new Stringify ( options || { } )
16
16
17
17
options = options || { }
18
18
options . objectMode = true
19
19
Transform . call ( this , options )
20
20
}
21
21
22
22
// Flags
23
- Streamify . prototype . destroyed = false
24
- Streamify . prototype . started = false
23
+ Stringify . prototype . destroyed = false
24
+ Stringify . prototype . started = false
25
25
26
26
// Array delimiters
27
- Streamify . prototype . open = new Buffer ( '[\n' , 'utf8' )
28
- Streamify . prototype . seperator = new Buffer ( '\n,\n' , 'utf8' )
29
- Streamify . prototype . close = new Buffer ( '\n]\n' , 'utf8' )
27
+ Stringify . prototype . open = new Buffer ( '[\n' , 'utf8' )
28
+ Stringify . prototype . seperator = new Buffer ( '\n,\n' , 'utf8' )
29
+ Stringify . prototype . close = new Buffer ( '\n]\n' , 'utf8' )
30
30
31
31
// JSON.stringify options
32
- Streamify . prototype . replacer = null
33
- Streamify . prototype . space = 0
32
+ Stringify . prototype . replacer = null
33
+ Stringify . prototype . space = 0
34
34
35
- Streamify . prototype . _transform = function ( doc , encoding , cb ) {
35
+ Stringify . prototype . _transform = function ( doc , encoding , cb ) {
36
36
if ( this . destroyed )
37
37
return
38
38
@@ -56,7 +56,7 @@ Streamify.prototype._transform = function (doc, encoding, cb) {
56
56
process . nextTick ( cb )
57
57
}
58
58
59
- Streamify . prototype . _flush = function ( cb ) {
59
+ Stringify . prototype . _flush = function ( cb ) {
60
60
if ( this . destroyed )
61
61
return
62
62
@@ -68,7 +68,7 @@ Streamify.prototype._flush = function (cb) {
68
68
process . nextTick ( cb )
69
69
}
70
70
71
- Streamify . prototype . destroy = function ( ) {
71
+ Stringify . prototype . destroy = function ( ) {
72
72
if ( ! this . destroyed ) {
73
73
this . emit ( 'close' )
74
74
this . destroyed = true
0 commit comments