Debian Codegraph @

example/fs.js

raw
1 var staticModule = require('../');
2 var quote = require('quote-stream');
3 var through = require('through2');
4 var fs = require('fs');
5
6 var sm = staticModule({
7 fs: {
8 readFileSync: function (file) {
9 return fs.createReadStream(file).pipe(quote());
10 },
11 readFile: function (file, cb) {
12 var stream = through(write, end);
13 stream.push('process.nextTick(function(){(' + cb + ')(null,');
14 return fs.createReadStream(file).pipe(quote()).pipe(stream);
15
16 function write (buf, enc, next) { this.push(buf); next() }
17 function end (next) { this.push(')})'); this.push(null); next() }
18 }
19 }
20 }, { vars: { __dirname: __dirname + '/fs' } });
21 process.stdin.pipe(sm).pipe(process.stdout);