Skip to content

Commit a5b6b5a

Browse files
author
Stephen Parente
committed
Ignored modules directory
1 parent d9155d7 commit a5b6b5a

File tree

612 files changed

+40
-43798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

612 files changed

+40
-43798
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

exporter.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var util = require('util');
22
var events = require('events');
33
var csv = require('csv');
44
var fs = require('fs');
5+
var stream = require('stream');
56

67
function Exporter(path) {
78
this.path = path;
@@ -10,6 +11,29 @@ function Exporter(path) {
1011

1112
util.inherits(Exporter, events.EventEmitter);
1213

14+
Exporter.prototype.toStream = function(data) {
15+
var s = new stream.Readable();
16+
17+
s._data = data.toString();
18+
19+
s._read = function(n) {
20+
var chunk;
21+
n = (n == null || n === -1) ? undefined : n;
22+
chunk = this._data.slice(0, n);
23+
24+
this._data = this._data.slice(n);
25+
if (chunk == "") {
26+
return this.emit('end');
27+
} else {
28+
this.push(chunk);
29+
this.emit('data', chunk);
30+
return chunk;
31+
}
32+
};
33+
34+
return s;
35+
}
36+
1337
Exporter.prototype.doWrite = function(data) {
1438
var $self = this;
1539
fs.writeFile(this.path, data, function(err) {

index.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var colors = require('colors');
44
var _ = require('./tools');
55
var Exporter = require('./exporter');
66

7-
function fetch(url, path, cb) {
7+
function fetch(url, cb, path) {
88
if (!cb) cb = function() {};
9-
path = path || './export.csv';
9+
path = path || false;
1010

1111
var firebase = new Firebase(firebaseUrl);
1212

@@ -16,6 +16,10 @@ function fetch(url, path, cb) {
1616
var data = _.prepareCSV(array);
1717

1818
var e = new Exporter(path);
19+
if (path === false) {
20+
return cb(e.toStream(data));
21+
}
22+
1923
e.writeToFile(data);
2024

2125
e.on('finished', cb);
@@ -50,10 +54,17 @@ if (require.main === module) {
5054
}
5155
});
5256

53-
fetch(firebaseUrl, false, function() {
54-
process.exit();
57+
fetch(firebaseUrl, function(stream) {
58+
stream
59+
.pipe(process.stdout);
60+
61+
stream.on('end', process.exit);
5562
});
5663

64+
/*fetch(firebaseUrl, function() {
65+
process.exit();
66+
}, './export.csv');*/
67+
5768
}
5869

5970
module.exports = fetch;

node_modules/colors/LICENSE

Lines changed: 0 additions & 23 deletions
This file was deleted.

node_modules/colors/ReadMe.md

Lines changed: 0 additions & 177 deletions
This file was deleted.

node_modules/colors/examples/normal-usage.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)