Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move child examples to vfs-child repo

  • Loading branch information...
commit 22c7944df86c838e590fbd39772dad233f7ddcb4 1 parent d240d7b
@creationix creationix authored
View
40 example/test-child-extend.js
@@ -1,40 +0,0 @@
-var Parent = require('vfs-child').Parent;
-var fs = require('fs');
-
-var child = new Parent({root:__dirname + "/"});
-
-child.on("connect", function () {
- console.log(process.pid, "the socket connected");
-});
-
-child.on("disconnect", function (err) {
- console.error(process.pid, "The socket disconnected", err);
- if (err) throw err;
-});
-
-child.connect(function (err, vfs) {
- if (err) throw err;
-
- console.log(process.pid, "CONNECTED");
-
- // Extend the API
- var options = {
- stream: fs.createReadStream(__dirname + "/extension.js")
- };
-
- console.log(process.pid, "Calling extend");
- vfs.extend("math", options, onExtend);
-
- // Test the extension
- function onExtend(err, meta) {
- if (err) throw err;
- var math = meta.api;
- console.log("Calling add(3, 5, callback)");
- math.add(3, 5, function (err, result) {
- if (err) throw err;
- console.log("3 + 5 = %s", result);
- });
- }
-
-});
-
View
23 example/test-child-streams.js
@@ -1,23 +0,0 @@
-// var vfs = require('vfs-local')({root: __dirname + "/"});
-// test(vfs);
-
-var Parent = require('vfs-child').Parent;
-
-var parent = new Parent({root: __dirname + "/"});
-
-parent.connect(function (err, vfs) {
- if (err) throw err;
- test(vfs);
-});
-
-function test(vfs) {
- vfs.readfile("test-child-streams.js", {}, function (err, meta) {
- if (err) throw err;
- meta.stream.on("end", function () {
- vfs.mkfile("foobar.js", {stream: require('fs').createReadStream(__filename)}, function (err, meta) {
- if (err) throw err;
- console.log("META", meta);
- });
- });
- });
-}
View
20 example/vfs-child-example.js
@@ -1,20 +0,0 @@
-var Parent = require('vfs-child').Parent;
-
-var parent = new Parent({root: __dirname + "/"});
-parent.connect();
-parent.once("connect", function (vfs) {
- require('http').createServer(require('stack')(
- require('vfs-http-adapter')("/child/", vfs)
- )).listen(8080, function () {
- console.log("child filesystem listening at http://localhost:8080/child/");
- });
-});
-parent.on("connect", function () {
- console.log("Child spawned and connected");
-});
-parent.on("disconnect", function () {
- console.log("Child died, spawning new child in 500ms");
- setTimeout(function () {
- parent.connect();
- }, 500);
-});
Please sign in to comment.
Something went wrong with that request. Please try again.