This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("sys").puts("a is loaded"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
throw new Error("some error"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require.paths.push("."); | |
exports.test = { | |
get foo(){ | |
require("c"); | |
} | |
}; | |
require("a"); // a is just empty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var promise = new process.Promise(); | |
promise.then(function(){ | |
require("sys").puts("done"); | |
}); | |
promise.emit("success"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.name = "test"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require.paths.push("../folder2"); | |
require("b"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var posix = require("posix"); | |
var print = require("sys").puts; | |
var j = 0; | |
for(var i = 0;i < 100; i++){ | |
posix.stat("file" + i, process.O_RDONLY, 0666) // these files don't exist | |
.addErrback(function(e){ | |
j++; // only makes it to about 17 | |
print(j); | |
}) | |
.addCallback(function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var posix = require("posix"); | |
var print = require("sys").puts; | |
var j = 0; | |
for(var i = 0;i < 3; i++){ | |
findFile(i); | |
} | |
function findFile(i){ | |
posix.stat("file" + i, process.O_RDONLY, 0666) // these files don't exist | |
.addErrback(function(e){ | |
j++; // only makes it to about 17 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Takes an array of promises and returns a promise that that is fulfilled once all | |
* the promises in the array are fulfilled | |
* @param group The array of promises | |
* @return the promise that is fulfilled when all the array is fulfilled | |
*/exports.group = function(group){ | |
var deferred = defer(); // this function is assigned process.Promise | |
if(!(group instanceof Array)){ | |
group = Array.prototype.slice.call(arguments); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var setTimeout = require("browser/timeout").setTimeout; | |
var deferred = require("promise").defer(); | |
var queue = require("event-queue"); | |
deferred.promise.then(function(){ | |
print("done"); | |
}); | |
setTimeout(function(){ | |
deferred.resolve(10); | |
queue.shutdown(); | |
}, 500); |
OlderNewer