Skip to content

Commit 93071d5

Browse files
committed
Streamify -> Stringify
1 parent e8626d2 commit 93071d5

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
/*
22
3-
db.collection.find().stream().pipe(Streamify()).pipe(res)
3+
db.collection.find().stream().pipe(Stringify()).pipe(res)
44
55
*/
66
var Transform = require('stream').Transform
77
var util = require('util')
88

9-
util.inherits(Streamify, Transform)
9+
util.inherits(Stringify, Transform)
1010

11-
module.exports = Streamify
11+
module.exports = Stringify
1212

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 || {})
1616

1717
options = options || {}
1818
options.objectMode = true
1919
Transform.call(this, options)
2020
}
2121

2222
// Flags
23-
Streamify.prototype.destroyed = false
24-
Streamify.prototype.started = false
23+
Stringify.prototype.destroyed = false
24+
Stringify.prototype.started = false
2525

2626
// 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')
3030

3131
// JSON.stringify options
32-
Streamify.prototype.replacer = null
33-
Streamify.prototype.space = 0
32+
Stringify.prototype.replacer = null
33+
Stringify.prototype.space = 0
3434

35-
Streamify.prototype._transform = function (doc, encoding, cb) {
35+
Stringify.prototype._transform = function (doc, encoding, cb) {
3636
if (this.destroyed)
3737
return
3838

@@ -56,7 +56,7 @@ Streamify.prototype._transform = function (doc, encoding, cb) {
5656
process.nextTick(cb)
5757
}
5858

59-
Streamify.prototype._flush = function (cb) {
59+
Stringify.prototype._flush = function (cb) {
6060
if (this.destroyed)
6161
return
6262

@@ -68,7 +68,7 @@ Streamify.prototype._flush = function (cb) {
6868
process.nextTick(cb)
6969
}
7070

71-
Streamify.prototype.destroy = function () {
71+
Stringify.prototype.destroy = function () {
7272
if (!this.destroyed) {
7373
this.emit('close')
7474
this.destroyed = true

test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ var assert = require('assert')
22
var PassThrough = require('stream').PassThrough
33
var cat = require('cat-stream')
44

5-
var streamify = require('./')
5+
var Stringify = require('./')
66

77
describe('Streamify()', function () {
88
it('should work with an empty stream', function (done) {
99
var stream = new PassThrough({
1010
objectMode: true
1111
})
1212

13-
stream.pipe(streamify()).pipe(cat(function (err, buf) {
13+
stream.pipe(Stringify()).pipe(cat(function (err, buf) {
1414
assert.ifError(err)
1515
assert.equal(buf.toString('utf8'), '[\n\n]\n')
1616
done()
@@ -24,7 +24,7 @@ describe('Streamify()', function () {
2424
objectMode: true
2525
})
2626

27-
stream.pipe(streamify()).pipe(cat(function (err, buf) {
27+
stream.pipe(Stringify()).pipe(cat(function (err, buf) {
2828
assert.ifError(err)
2929
assert.equal(buf.toString('utf8'), '[\n{}\n]\n')
3030
done()
@@ -39,7 +39,7 @@ describe('Streamify()', function () {
3939
objectMode: true
4040
})
4141

42-
stream.pipe(streamify()).pipe(cat(function (err, buf) {
42+
stream.pipe(Stringify()).pipe(cat(function (err, buf) {
4343
assert.ifError(err)
4444
assert.equal(buf.toString('utf8'), '[\n{}\n,\n{}\n]\n')
4545
done()
@@ -55,7 +55,7 @@ describe('Streamify()', function () {
5555
objectMode: true
5656
})
5757

58-
stream.pipe(streamify()).pipe(cat(function (err, buf) {
58+
stream.pipe(Stringify()).pipe(cat(function (err, buf) {
5959
assert.ifError(err)
6060
assert.equal(buf.toString('utf8'), '[\n"hello"\n]\n')
6161
done()
@@ -70,7 +70,7 @@ describe('Streamify()', function () {
7070
objectMode: true
7171
})
7272

73-
stream.pipe(streamify({
73+
stream.pipe(Stringify({
7474
encoding: 'utf8'
7575
})).once('data', function (chunk) {
7676
assert.equal(typeof chunk, 'string')
@@ -86,7 +86,7 @@ describe('Streamify()', function () {
8686
objectMode: true
8787
})
8888

89-
var stringify = streamify()
89+
var stringify = Stringify()
9090
stringify.space = 2
9191

9292
var obj = {

0 commit comments

Comments
 (0)