API: rename process.inherits to sys.inherits
This commit is contained in:
parent
d737a060c8
commit
43121c15be
@ -136,7 +136,7 @@ function IncomingMessage (connection) {
|
|||||||
this.statusCode = null;
|
this.statusCode = null;
|
||||||
this.client = this.connection;
|
this.client = this.connection;
|
||||||
}
|
}
|
||||||
process.inherits(IncomingMessage, process.EventEmitter);
|
sys.inherits(IncomingMessage, process.EventEmitter);
|
||||||
exports.IncomingMessage = IncomingMessage;
|
exports.IncomingMessage = IncomingMessage;
|
||||||
|
|
||||||
IncomingMessage.prototype._parseQueryString = function () {
|
IncomingMessage.prototype._parseQueryString = function () {
|
||||||
@ -192,7 +192,7 @@ function OutgoingMessage () {
|
|||||||
|
|
||||||
this.finished = false;
|
this.finished = false;
|
||||||
}
|
}
|
||||||
process.inherits(OutgoingMessage, process.EventEmitter);
|
sys.inherits(OutgoingMessage, process.EventEmitter);
|
||||||
exports.OutgoingMessage = OutgoingMessage;
|
exports.OutgoingMessage = OutgoingMessage;
|
||||||
|
|
||||||
OutgoingMessage.prototype.send = function (data, encoding) {
|
OutgoingMessage.prototype.send = function (data, encoding) {
|
||||||
@ -315,7 +315,7 @@ function ServerResponse () {
|
|||||||
this.should_keep_alive = true;
|
this.should_keep_alive = true;
|
||||||
this.use_chunked_encoding_by_default = true;
|
this.use_chunked_encoding_by_default = true;
|
||||||
}
|
}
|
||||||
process.inherits(ServerResponse, OutgoingMessage);
|
sys.inherits(ServerResponse, OutgoingMessage);
|
||||||
exports.ServerResponse = ServerResponse;
|
exports.ServerResponse = ServerResponse;
|
||||||
|
|
||||||
ServerResponse.prototype.sendHeader = function (statusCode, headers) {
|
ServerResponse.prototype.sendHeader = function (statusCode, headers) {
|
||||||
@ -338,7 +338,7 @@ function ClientRequest (method, uri, headers) {
|
|||||||
|
|
||||||
this.sendHeaderLines(method + " " + uri + " HTTP/1.1\r\n", headers);
|
this.sendHeaderLines(method + " " + uri + " HTTP/1.1\r\n", headers);
|
||||||
}
|
}
|
||||||
process.inherits(ClientRequest, OutgoingMessage);
|
sys.inherits(ClientRequest, OutgoingMessage);
|
||||||
exports.ClientRequest = ClientRequest;
|
exports.ClientRequest = ClientRequest;
|
||||||
|
|
||||||
ClientRequest.prototype.finish = function (responseListener) {
|
ClientRequest.prototype.finish = function (responseListener) {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
var sys = require("sys");
|
||||||
|
|
||||||
exports.parse = function(options) {
|
exports.parse = function(options) {
|
||||||
var stream = new exports.Stream(options);
|
var stream = new exports.Stream(options);
|
||||||
var promise = new process.Promise();
|
var promise = new process.Promise();
|
||||||
@ -28,7 +30,7 @@ exports.Stream = function(options) {
|
|||||||
|
|
||||||
this.init(options);
|
this.init(options);
|
||||||
};
|
};
|
||||||
process.inherits(exports.Stream, process.EventEmitter);
|
sys.inherits(exports.Stream, process.EventEmitter);
|
||||||
|
|
||||||
|
|
||||||
var proto = exports.Stream.prototype;
|
var proto = exports.Stream.prototype;
|
||||||
@ -109,7 +111,7 @@ function Part(stream) {
|
|||||||
|
|
||||||
this._headersComplete = false;
|
this._headersComplete = false;
|
||||||
}
|
}
|
||||||
process.inherits(Part, process.EventEmitter);
|
sys.inherits(Part, process.EventEmitter);
|
||||||
|
|
||||||
Part.prototype.parsedHeaders = function() {
|
Part.prototype.parsedHeaders = function() {
|
||||||
for (var header in this.headers) {
|
for (var header in this.headers) {
|
||||||
|
21
lib/sys.js
21
lib/sys.js
@ -67,3 +67,24 @@ exports.exec = function (command) {
|
|||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inherit the prototype methods from one constructor into another.
|
||||||
|
*
|
||||||
|
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
||||||
|
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
||||||
|
* during bootstrapping this function needs to be revritten using some native
|
||||||
|
* functions as prototype setup using normal JavaScript does not work as
|
||||||
|
* expected during bootstrapping (see mirror.js in r114903).
|
||||||
|
*
|
||||||
|
* @param {function} ctor Constructor function which needs to inherit the
|
||||||
|
* prototype
|
||||||
|
* @param {function} superCtor Constructor function to inherit prototype from
|
||||||
|
*/
|
||||||
|
exports.inherits = function (ctor, superCtor) {
|
||||||
|
var tempCtor = function(){};
|
||||||
|
tempCtor.prototype = superCtor.prototype;
|
||||||
|
ctor.super_ = superCtor.prototype;
|
||||||
|
ctor.prototype = new tempCtor();
|
||||||
|
ctor.prototype.constructor = ctor;
|
||||||
|
};
|
||||||
|
21
src/node.js
21
src/node.js
@ -120,27 +120,6 @@ process.fs.cat = function (path, encoding) {
|
|||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Inherit the prototype methods from one constructor into another.
|
|
||||||
*
|
|
||||||
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
|
||||||
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
|
||||||
* during bootstrapping this function needs to be revritten using some native
|
|
||||||
* functions as prototype setup using normal JavaScript does not work as
|
|
||||||
* expected during bootstrapping (see mirror.js in r114903).
|
|
||||||
*
|
|
||||||
* @param {function} ctor Constructor function which needs to inherit the
|
|
||||||
* prototype
|
|
||||||
* @param {function} superCtor Constructor function to inherit prototype from
|
|
||||||
*/
|
|
||||||
process.inherits = function (ctor, superCtor) {
|
|
||||||
var tempCtor = function(){};
|
|
||||||
tempCtor.prototype = superCtor.prototype;
|
|
||||||
ctor.super_ = superCtor.prototype;
|
|
||||||
ctor.prototype = new tempCtor();
|
|
||||||
ctor.prototype.constructor = ctor;
|
|
||||||
};
|
|
||||||
|
|
||||||
process.assert = function (x, msg) {
|
process.assert = function (x, msg) {
|
||||||
if (!(x)) throw new Error(msg || "assertion error");
|
if (!(x)) throw new Error(msg || "assertion error");
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user