#!/usr/bin/env node
-node.mixin(require("/utils.js"));
+process.mixin(require("/utils.js"));
puts("Welcome to the Node.js REPL.");
puts("Enter ECMAScript at the prompt.");
puts("Tip 1: Use 'rlwrap node-repl' for a better interface");
=== The +process+ Object
-+process+ is the equivalent of +window+ in browser-side javascript. It is
-the global scope. +process+ is an instance of +process.EventEmitter+.
-
[cols="1,2,10",options="header"]
|=========================================================
| Event | Parameters | Notes
-node.mixin(require("../common.js"));
+process.mixin(require("../common.js"));
http = require("/http.js");
PORT = 8888;
var errors = 0;
var successes = 0;
-var promise = node.cat("http://localhost:"+PORT, "utf8");
+var promise = process.cat("http://localhost:"+PORT, "utf8");
promise.addCallback(function (content) {
assertEquals(body, content);
errors += 1;
});
-var dirname = node.path.dirname(__filename);
-var fixtures = node.path.join(dirname, "fixtures");
-var x = node.path.join(fixtures, "x.txt");
+var dirname = process.path.dirname(__filename);
+var fixtures = process.path.join(dirname, "fixtures");
+var x = process.path.join(fixtures, "x.txt");
-promise = node.cat(x, "utf8");
+promise = process.cat(x, "utf8");
promise.addCallback(function (content) {
assertEquals("xyz", content.replace(/[\r\n]/, ''));
-node.mixin(require('../common.js'));
+process.mixin(require('../common.js'));
var PORT = 8003;
var request_count = 1000;
var response_body = '{"ok": true}';
-var server = node.http.createServer(function(req, res) {
+var server = process.http.createServer(function(req, res) {
res.sendHeader(200, {'Content-Type': 'text/javascript'});
res.sendBody(response_body);
res.finish();
function onLoad () {
for (var i = 0; i < request_count; i++) {
- node.http.cat('http://localhost:'+PORT+'/', 'utf8')
+ process.http.cat('http://localhost:'+PORT+'/', 'utf8')
.addCallback(function (content) {
assertEquals(response_body, content)
print(".");
.addErrback(function() {
print("-");
requests_complete++;
- //node.debug("error " + i);
+ //process.debug("error " + i);
});
}
}
-function onExit () {
+process.addListener("exit", function () {
assertEquals(request_count, requests_complete);
assertEquals(request_count, requests_ok);
-}
+});
-var s = node.http.createServer(function (req, res) {
+var s = process.http.createServer(function (req, res) {
var body = "exports.A = function() { return 'A';}";
res.sendHeader(200, [
["Content-Length", body.length],
});
s.listen(8000);
-node.mixin(require("../common.js"));
+process.mixin(require("../common.js"));
var a = require("http://localhost:8000/")
assertInstanceof(a.A, Function);
-node.mixin(require("../common.js"));
+process.mixin(require("../common.js"));
var dns = require("/dns.js");
-for (var i = 2; i < ARGV.length; i++) {
- var name = ARGV[i]
+for (var i = 2; i < process.ARGV.length; i++) {
+ var name = process.ARGV[i]
puts("looking up " + name);
var resolution = dns.resolve4(name);