[Pkg-javascript-commits] [node-mocks-http] 108/296: fixed lint errors in lib/*
Thorsten Alteholz
alteholz at moszumanska.debian.org
Mon Feb 8 18:13:26 UTC 2016
This is an automated email from the git hooks/post-receive script.
alteholz pushed a commit to branch master
in repository node-mocks-http.
commit 4c04ad3622e2bbf3abd836b5fe824458aa27b496
Author: Johnny Estilles <johnny.estilles at agentia.asia>
Date: Wed Mar 11 14:48:48 2015 +0800
fixed lint errors in lib/*
---
lib/http-mock.js | 6 ++++--
lib/mockEventEmitter.js | 20 ++++++++++--------
lib/mockRequest.js | 16 ++++++--------
lib/mockResponse.js | 54 ++++++++++++++++++++++++++---------------------
lib/mockWritableStream.js | 4 +++-
5 files changed, 55 insertions(+), 45 deletions(-)
diff --git a/lib/http-mock.js b/lib/http-mock.js
index e7b28f4..196d794 100644
--- a/lib/http-mock.js
+++ b/lib/http-mock.js
@@ -1,3 +1,5 @@
+'use strict';
+
/**
* Module: http-mock
*
@@ -5,8 +7,8 @@
* functions from the other libraries.
*/
-var request = require('./mockRequest');
+var request = require('./mockRequest');
var response = require('./mockResponse');
exports.createRequest = request.createRequest;
-exports.createResponse= response.createResponse;
\ No newline at end of file
+exports.createResponse = response.createResponse;
diff --git a/lib/mockEventEmitter.js b/lib/mockEventEmitter.js
index 9662692..52075c9 100644
--- a/lib/mockEventEmitter.js
+++ b/lib/mockEventEmitter.js
@@ -1,18 +1,20 @@
+'use strict';
+
/*
* http://nodejs.org/api/events.html
*/
function EventEmitter() {}
-EventEmitter.prototype.addListener = function (event, listener) {};
-EventEmitter.prototype.on = function (event, listener) {};
-EventEmitter.prototype.once = function (event, listener) {};
-EventEmitter.prototype.removeListener = function (event, listener) {};
-EventEmitter.prototype.removeAllListeners = function (event) {};
+EventEmitter.prototype.addListener = function () {};
+EventEmitter.prototype.on = function () {};
+EventEmitter.prototype.once = function () {};
+EventEmitter.prototype.removeListener = function () {};
+EventEmitter.prototype.removeAllListeners = function () {};
// EventEmitter.prototype.removeAllListeners = function([event])
-EventEmitter.prototype.setMaxListeners = function (n) {};
-EventEmitter.prototype.listeners = function (event) {};
-EventEmitter.prototype.emit = function (event) {};
+EventEmitter.prototype.setMaxListeners = function () {};
+EventEmitter.prototype.listeners = function () {};
+EventEmitter.prototype.emit = function () {};
// EventEmitter.prototype.emit = function(event, [arg1], [arg2], [...]){}
-module.exports = EventEmitter;
\ No newline at end of file
+module.exports = EventEmitter;
diff --git a/lib/mockRequest.js b/lib/mockRequest.js
index 1ddc122..3108a8c 100644
--- a/lib/mockRequest.js
+++ b/lib/mockRequest.js
@@ -95,9 +95,7 @@ function createRequest(options) {
else if (mockRequest.query[parameterName]) {
return mockRequest.query[parameterName];
}
- else {
- return null;
- }
+ return null;
};
/**
@@ -179,13 +177,13 @@ function createRequest(options) {
*
* Parameters:
*
- * url - The request path, e.g. /my-route/452
+ * value - The request path, e.g. /my-route/452
*
* Note: We don't validate the string. We just return it. Typically, these
* do not include hostname, port or that part of the URL.
*/
- mockRequest._setURL = function(url) {
- mockRequest.url = url;
+ mockRequest._setURL = function(value) {
+ mockRequest.url = value;
};
/**
@@ -196,13 +194,13 @@ function createRequest(options) {
*
* Parameters:
*
- * url - The request path, e.g. /my-route/452
+ * value - The request path, e.g. /my-route/452
*
* Note: We don't validate the string. We just return it. Typically, these
* do not include hostname, port or that part of the URL.
*/
- mockRequest._setOriginalUrl = function(url) {
- mockRequest.originalUrl = url;
+ mockRequest._setOriginalUrl = function(value) {
+ mockRequest.originalUrl = value;
};
/**
diff --git a/lib/mockResponse.js b/lib/mockResponse.js
index 7ea5eaa..4dabfe5 100644
--- a/lib/mockResponse.js
+++ b/lib/mockResponse.js
@@ -44,8 +44,14 @@ function createResponse(options) {
var _renderView = '';
var _renderData = {};
- var writableStream = options.writableStream ? new options.writableStream() : new WritableStream();
- var eventEmitter = options.eventEmitter ? new options.eventEmitter() : new EventEmitter();
+ if (options.writableStream) {
+ WritableStream = options.writableStream;
+ }
+ if (options.eventEmitter) {
+ EventEmitter = options.eventEmitter;
+ }
+ var writableStream = new WritableStream();
+ var eventEmitter = new EventEmitter();
// create mockResponse
@@ -54,11 +60,11 @@ function createResponse(options) {
mockResponse.statusCode = 200;
mockResponse.cookies = {};
- mockResponse.cookie = function(name, value, options) {
+ mockResponse.cookie = function(name, value, opt) {
mockResponse.cookies[name] = {
value: value,
- options: options
+ options: opt
};
};
@@ -109,24 +115,24 @@ function createResponse(options) {
*/
mockResponse.send = function(a, b, c) {
- var _formatData = function(a) {
+ var _formatData = function(data) {
- if (typeof a === 'object') {
+ if (typeof data === 'object') {
- if (a.statusCode) {
- mockResponse.statusCode = a.statusCode;
- } else if (a.httpCode) {
- mockResponse.statusCode = a.statusCode;
+ if (data.statusCode) {
+ mockResponse.statusCode = data.statusCode;
+ } else if (data.httpCode) {
+ mockResponse.statusCode = data.statusCode;
}
- if (a.body) {
- _data = a.body;
+ if (data.body) {
+ _data = data.body;
} else {
- _data = a;
+ _data = data;
}
} else {
- _data += a;
+ _data += data;
}
};
@@ -229,7 +235,7 @@ function createResponse(options) {
*/
mockResponse.contentType = mockResponse.type = function(type){
return mockResponse.set('Content-Type', type.indexOf('/') >= 0 ? type : mime.lookup(type));
- };
+ };
/**
* Function: write
@@ -395,7 +401,7 @@ function createResponse(options) {
* Render a view with a callback responding with the
* rendered string.
*/
- mockResponse.render = function(a, b, c) {
+ mockResponse.render = function(a, b) {
_renderView = a;
@@ -434,35 +440,35 @@ function createResponse(options) {
return writableStream.destroySoon.apply(this, arguments);
};
- mockResponse.addListener = function(event, listener) {
+ mockResponse.addListener = function() {
return eventEmitter.addListener.apply(this, arguments);
};
- mockResponse.on = function(event, listener) {
+ mockResponse.on = function() {
return eventEmitter.on.apply(this, arguments);
};
- mockResponse.once = function(event, listener) {
+ mockResponse.once = function() {
return eventEmitter.once.apply(this, arguments);
};
- mockResponse.removeListener = function(event, listener) {
+ mockResponse.removeListener = function() {
return eventEmitter.removeListener.apply(this, arguments);
};
- mockResponse.removeAllListeners = function(event) {
+ mockResponse.removeAllListeners = function() {
return eventEmitter.removeAllListeners.apply(this, arguments);
};
- mockResponse.setMaxListeners = function(n) {
+ mockResponse.setMaxListeners = function() {
return eventEmitter.setMaxListeners.apply(this, arguments);
};
- mockResponse.listeners = function(event) {
+ mockResponse.listeners = function() {
return eventEmitter.listeners.apply(this, arguments);
};
- mockResponse.emit = function(event) {
+ mockResponse.emit = function() {
return eventEmitter.emit.apply(this, arguments);
};
diff --git a/lib/mockWritableStream.js b/lib/mockWritableStream.js
index 585b929..567532b 100644
--- a/lib/mockWritableStream.js
+++ b/lib/mockWritableStream.js
@@ -1,3 +1,5 @@
+'use strict';
+
/*
* http://nodejs.org/api/stream.html#stream_writable_stream
*/
@@ -13,4 +15,4 @@ WritableStream.prototype.end = function () {};
WritableStream.prototype.destroy = function () {};
WritableStream.prototype.destroySoon = function () {};
-module.exports = WritableStream;
\ No newline at end of file
+module.exports = WritableStream;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mocks-http.git
More information about the Pkg-javascript-commits
mailing list