summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/duplexify/example.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/duplexify/example.js')
-rw-r--r--deps/npm/node_modules/duplexify/example.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/deps/npm/node_modules/duplexify/example.js b/deps/npm/node_modules/duplexify/example.js
new file mode 100644
index 0000000000..5585c19756
--- /dev/null
+++ b/deps/npm/node_modules/duplexify/example.js
@@ -0,0 +1,21 @@
+var duplexify = require('duplexify')
+var http = require('http')
+
+var request = function(opts) {
+ var req = http.request(opts)
+ var dup = duplexify()
+ dup.setWritable(req)
+ req.on('response', function(res) {
+ dup.setReadable(res)
+ })
+ return dup
+}
+
+var req = request({
+ method: 'GET',
+ host: 'www.google.com',
+ port: 80
+})
+
+req.end()
+req.pipe(process.stdout)