Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix few things that break on nighties.

  • Loading branch information...
commit 2c84fd0e9513df589a2214b29beae2b3d78606e0 1 parent 5e919ff
@Gozala authored
Showing with 32 additions and 27 deletions.
  1. +20 −16 fs.js
  2. +11 −10 net.js
  3. +1 −1  stream.js
View
36 fs.js
@@ -23,8 +23,8 @@ const StreamPump = CC('@mozilla.org/network/input-stream-pump;1',
'nsIInputStreamPump', 'init');
const { createOutputTransport, createInputTransport } =
- CC('@mozilla.org/network/stream-transport-service;1',
- 'nsIStreamTransportService')();
+ Cc['@mozilla.org/network/stream-transport-service;1'].
+ getService(Ci.nsIStreamTransportService);
const { REOPEN_ON_REWIND, DEFER_OPEN } = Ci.nsIFileInputStream;
@@ -87,7 +87,7 @@ function Mode(mode, fallback) {
}
function Flags(flag) {
return !isString(flag) ? flag :
- FLAGS[flag] || new Error('Unknown file open flag: ' + flag);
+ FLAGS[flag] || Error('Unknown file open flag: ' + flag);
}
const ReadStream = InputStream.extend({
@@ -299,7 +299,7 @@ exports.truncate = Async(exports.truncateSync);
* Synchronous chmod(2).
*/
exports.chmodSync = function chmodSync (path, mode) {
- throw new Error('Not implemented yet!!');
+ throw Error('Not implemented yet!!');
};
/**
* Asynchronous chmod(2). No arguments other than a possible exception are
@@ -349,7 +349,7 @@ exports.fstat = Async(exports.fstatSync);
* Synchronous link(2).
*/
exports.linkSync = function linkSync(source, target) {
- throw new Error('Not implemented yet!!');
+ throw Error('Not implemented yet!!');
};
/**
* Asynchronous link(2). No arguments other than a possible exception are given
@@ -361,7 +361,7 @@ exports.link = Async(exports.linkSync);
* Synchronous symlink(2).
*/
exports.symlinkSync = function symlinkSync(source, target) {
- throw new Error('Not implemented yet!!');
+ throw Error('Not implemented yet!!');
};
/**
* Asynchronous symlink(2). No arguments other than a possible exception are
@@ -489,7 +489,7 @@ exports.open = Async(exports.openSync);
* written.
*/
exports.writeSync = function writeSync(fd, buffer, offset, length, position) {
- throw new Error('Not implemented');
+ throw Error('Not implemented');
};
/**
* Write buffer to the file specified by fd.
@@ -514,7 +514,7 @@ exports.write = function write(fd, buffer, offset, length, position, callback) {
buffer = new Buffer(String(buffer), encoding);
offset = 0;
} else if (length + offset > buffer.length) {
- throw new Error('Length is extends beyond buffer');
+ throw Error('Length is extends beyond buffer');
} else if (length + offset !== buffer.length) {
buffer = buffer.slice(offset, offset + length);
}
@@ -533,7 +533,7 @@ exports.write = function write(fd, buffer, offset, length, position, callback) {
* bytes read.
*/
exports.readSync = function readSync(fd, buffer, offset, length, position) {
- throw new Error('Not implemented');
+ throw Error('Not implemented');
};
/**
* Read data from the file specified by `fd`.
@@ -571,8 +571,10 @@ exports.read = function read(fd, buffer, offset, length, position, callback) {
* contents of the file.
*/
exports.readFile = function readFile(path, encoding, callback) {
- if (isFunction(encoding))
- [ callback, encoding ] = [ encoding, null ];
+ if (isFunction(encoding)) {
+ callback = encoding
+ encoding = null
+ }
let buffer = new Buffer();
let readStream = new ReadStream(path);
@@ -595,7 +597,7 @@ exports.readFile = function readFile(path, encoding, callback) {
* Otherwise it returns a buffer.
*/
exports.readFileSync = function readFileSync(path, encoding) {
- throw new Error('Not implemented');
+ throw Error('Not implemented');
};
/**
@@ -604,8 +606,10 @@ exports.readFileSync = function readFileSync(path, encoding) {
*/
exports.writeFile = function writeFile(path, content, encoding, callback) {
try {
- if (isFunction(encoding))
- [ callback, encoding ] = [ encoding, null ];
+ if (isFunction(encoding)) {
+ callback = encoding
+ encoding = callback
+ }
if (isString(content))
content = new Buffer(content, encoding);
@@ -626,7 +630,7 @@ exports.writeFile = function writeFile(path, content, encoding, callback) {
* The synchronous version of `fs.writeFile`.
*/
exports.writeFileSync = function writeFileSync(filename, data, encoding) {
- throw new Error('Not implemented');
+ throw Error('Not implemented');
};
/**
@@ -638,5 +642,5 @@ exports.writeFileSync = function writeFileSync(filename, data, encoding) {
* in milliseconds. The default is { persistent: true, interval: 0 }.
*/
exports.watchFile = function watchFile(path, options, listener) {
- throw new Error('Not implemented');
+ throw Error('Not implemented');
};
View
21 net.js
@@ -1,6 +1,6 @@
'use strict';
-const { Cc, Ci, components: { Constructor: CC } } = require('chrome');
+const { Cc, Ci, CC } = require('chrome');
const { DuplexStream, InputStream, OutputStream } = require('./stream');
const { EventEmitter } = require('raw.github.com/Gozala/events/v0.5.0/events');
@@ -9,11 +9,10 @@ const { ns } = require('api-utils/namespace');
const _ = ns();
+const { createTransport } = Cc['@mozilla.org/network/socket-transport-service;1'].
+ getService(Ci.nsISocketTransportService);
const RawSocketServer = CC('@mozilla.org/network/server-socket;1',
'nsIServerSocket');
-
-const { createTransport } = CC('@mozilla.org/network/socket-transport-service;1',
- 'nsISocketTransportService')();
const StreamPump = CC('@mozilla.org/network/input-stream-pump;1',
'nsIInputStreamPump', 'init');
const StreamCopier = CC('@mozilla.org/network/async-stream-copier;1',
@@ -149,7 +148,7 @@ const Socket = DuplexStream.extend({
_(this).transport.setTimeout(time, TIMEOUT_READ_WRITE);
},
open: function open(fd, type) {
- throw new Error('Not yet implemented');
+ throw Error('Not yet implemented');
},
connect: function connect (port, host) {
try {
@@ -216,17 +215,19 @@ const Server = EventEmitter.extend({
return this.host + ':' + this.port;
},
listenFD: function listenFD(fd, type) {
- throw new Error('Not implemented');
+ throw Error('Not implemented');
},
listen: function listen(port, host, callback) {
let server = this;
let connections = 0;
if (this.fd)
- throw new Error('Server already opened');
+ throw Error('Server already opened');
- if (!callback)
- [ host, callback ] = [ 'localhost', callback ]
+ if (!callback) {
+ callback = host
+ host = 'localhost'
+ }
if (callback)
this.on('listening', callback)
@@ -262,7 +263,7 @@ const Server = EventEmitter.extend({
}
},
pause: function pause(time) {
- throw new Error('Net implemented');
+ throw Error('Net implemented');
},
/**
* Stops the server from accepting new connections. This function is
View
2  stream.js
@@ -205,7 +205,7 @@ const OutputStream = Stream.extend({
let isWritten = false;
// If stream is not writable we throw an error.
if (!stream.writable)
- throw new Error('stream not writable');
+ throw Error('stream not writable');
try {
// If content is not a buffer then we create one out of it.
Please sign in to comment.
Something went wrong with that request. Please try again.