Permalink
Browse files

Further steps to placate JSDoc

  • Loading branch information...
1 parent 62a40c0 commit b3bb6e59110765df0e1bae0a49f62350992cae66 @tedeh committed Jun 24, 2012
Showing with 84 additions and 33 deletions.
  1. +17 −7 lib/client/fork.js
  2. +16 −6 lib/client/http.js
  3. +9 −5 lib/client/index.js
  4. +7 −5 lib/client/jquery.js
  5. +20 −3 lib/index.js
  6. +3 −1 lib/server/fork.js
  7. +1 −1 lib/server/http.js
  8. +4 −2 lib/server/https.js
  9. +4 −2 lib/server/index.js
  10. +3 −1 lib/server/middleware.js
View
24 lib/client/fork.js
@@ -1,20 +1,30 @@
var utils = require('../utils');
-var JaysonClient = require('./');
-var JaysonServer = require('../').Server;
+var Client = require('./');
-var JaysonForkClient = module.exports = function(server, options) {
- if(!(this instanceof JaysonForkClient)) return new JaysonForkClient(server, options);
- JaysonClient.apply(this, arguments);
+/**
+ * Constructor for a Jayson HTTP Client
+ * @class Jayson JSON-RPC Fork Client
+ * @extends Client
+ * @param {Server} server An instance of Server
+ * @param {Object} [options] Optional hash of settings
+ * @return {ForkClient}
+ * @api public
+ */
+var ForkClient = function(server, options) {
+ if(!(this instanceof ForkClient)) return new ForkClient(server, options);
+ Client.apply(this, arguments);
var defaults = utils.merge(this.options, {
encoding: 'utf8'
});
this.options = utils.merge(defaults, options || {});
};
-utils.inherits(JaysonForkClient, JaysonClient);
+utils.inherits(ForkClient, Client);
-JaysonForkClient.prototype._request = function(request, callback) {
+module.exports = ForkClient;
+
+ForkClient.prototype._request = function(request, callback) {
// copies options so object can be modified in this context
var options = utils.merge({}, this.options);
this.server.call(request, callback);
View
22 lib/client/http.js
@@ -1,20 +1,30 @@
var http = require('http');
var utils = require('../utils');
-var JaysonClient = require('./index');
+var Client = require('./index');
-var JaysonHttpClient = module.exports = function(options) {
- if(!(this instanceof JaysonHttpClient)) return new JaysonHttpClient(options);
- JaysonClient.apply(this, arguments);
+/**
+ * Constructor for a Jayson HTTP Client
+ * @class Jayson JSON-RPC HTTP Client
+ * @extends Client
+ * @param {Object} [options] Optional hash of settings
+ * @return {HttpClient}
+ * @api public
+ */
+var HttpClient = function(options) {
+ if(!(this instanceof HttpClient)) return new HttpClient(options);
+ Client.apply(this, arguments);
var defaults = utils.merge(this.options, {
encoding: 'utf8'
});
this.options = utils.merge(defaults, options || {});
};
-utils.inherits(JaysonHttpClient, JaysonClient);
+utils.inherits(HttpClient, Client);
-JaysonHttpClient.prototype._request = function(request, callback) {
+module.exports = HttpClient;
+
+HttpClient.prototype._request = function(request, callback) {
// copies options so object can be modified in this context
var options = utils.merge({}, this.options);
View
14 lib/client/index.js
@@ -9,7 +9,7 @@ var utils = require('../utils');
* @return {Client}
* @api public
*/
-var Client = module.exports = function(server, options) {
+var Client = function(server, options) {
if(!(server instanceof Server) && arguments.length === 1) {
options = server;
server = null;
@@ -26,14 +26,18 @@ var Client = module.exports = function(server, options) {
if(server) this.server = server;
};
-/*
- * @description HTTP(s) client constructor
+module.exports = Client;
+
+/**
+ * HTTP(s) client constructor
+ * @type HttpClient
* @static
*/
Client.http = require('./http');
-/*
- * @description Fork client constructor
+/**
+ * Fork client constructor
+ * @type ForkClient
* @static
*/
Client.fork = require('./fork');
View
12 lib/client/jquery.js
@@ -1,7 +1,7 @@
;(function($) {
- var JaysonClientJquery = window.Jayson = function(options) {
- if(!(this instanceof JaysonClientJquery)) return new JaysonClientJquery(options);
+ var ClientJquery = function(options) {
+ if(!(this instanceof ClientJquery)) return new ClientJquery(options);
var defaults = {
dataType: 'json',
@@ -13,7 +13,9 @@
this.options = $.extend(defaults, options || {});
};
- JaysonClientJquery.prototype.request = function(method, params, id, callback) {
+ window.Jayson = ClientJquery;
+
+ ClientJquery.prototype.request = function(method, params, id, callback) {
// wrap around the error and success callbacks for post-processing
var options = $.extend({}, this.options, {
error: function(xhr, status, error) { callback($.makeArray(arguments)); },
@@ -31,7 +33,7 @@
// Expose the client as a jQuery extension
$.fn.jayson = function(options) {
options = options || {};
- var client = new JaysonClientJquery(options);
+ var client = new ClientJquery(options);
client.request(options.method, options.params, options.id, function(err, data) {
if(err) {
if($.isFunction(options.error)) {
@@ -88,7 +90,7 @@
// Expose the client via AMD if available
if(typeof(define) === 'function') {
define('jayson', [], function() {
- return JaysonClientJquery;
+ return ClientJquery;
});
}
})(jQuery);
View
23 lib/index.js
@@ -1,5 +1,22 @@
-exports.client = exports.Client = require('./client');
+/**
+ * @namespace Jayson namespace available as require('jayson')
+ */
+var Jayson = module.exports;
-exports.server = exports.Server = require('./server');
+/**
+ * @static
+ * @type Client
+ */
+Jayson.Client = Jayson.client = require('./client');
-exports.utils = require('./utils');
+/**
+ * @static
+ * @type Server
+ */
+Jayson.Server = Jayson.server = require('./server');
+
+/**
+ * @static
+ * @type Utils
+ */
+Jayson.Utils = Jayson.utils = require('./utils');
View
4 lib/server/fork.js
@@ -11,7 +11,7 @@ var JaysonServer = require('./index');
* @returns {ForkServer}
* @api public
*/
-var ForkServer = module.exports = function(path, options) {
+var ForkServer = function(path, options) {
if(!(this instanceof ForkServer)) return new ForkServer(path, options);
// reference to the child process
@@ -40,6 +40,8 @@ var ForkServer = module.exports = function(path, options) {
};
utils.inherits(ForkServer, JaysonServer);
+module.exports = ForkServer;
+
/**
* Kills the child process
* @returns {void}
View
2 lib/server/http.js
@@ -4,7 +4,7 @@ var utils = require('../utils');
/**
* Constructor for a Jayson HTTP server
* @class Jayson JSON-RPC HTTP Server
- * @extends http.Server
+ * @extends require('http').Server
* @return {HttpServer}
* @api public
*/
View
6 lib/server/https.js
@@ -4,12 +4,14 @@ var utils = require('../utils');
/**
* Constructor for a Jayson HTTPS server
* @class Jayson JSON-RPC HTTPS Server
- * @extends https.Server
+ * @extends require('https').Server
* @return {HttpServer}
* @api public
*/
-var HttpsServer = module.exports = function(server, options) {
+var HttpsServer = function(server, options) {
if(!(this instanceof HttpsServer)) return new HttpsServer(server, options);
https.Server.call(this, utils.httpRequestWrapper(server, options));
};
utils.inherits(HttpsServer, https.Server);
+
+module.exports = HttpsServer;
View
6 lib/server/index.js
@@ -5,7 +5,7 @@ var utils = require('../utils');
/**
* Constructor for a Jayson server
* @class Jayson JSON-RPC Server
- * @extends events.EventEmitter
+ * @extends require('events').EventEmitter
* @param {Object} [methods] Methods to add
* @param {Object} [options] Options to set
* @property {Object} options A reference to the internal options object that can be modified directly
@@ -16,7 +16,7 @@ var utils = require('../utils');
* @return {Server}
* @api public
*/
-var Server = module.exports = function(methods, options) {
+var Server = function(methods, options) {
if(!(this instanceof Server)) return new Server(methods, options);
var defaults = {
@@ -48,6 +48,8 @@ var Server = module.exports = function(methods, options) {
};
utils.inherits(Server, events.EventEmitter);
+module.exports = Server;
+
/**
* Interfaces that will be automatically bound as properties of a Server instance
* @type Object
View
4 lib/server/middleware.js
@@ -1,6 +1,6 @@
var utils = require('../utils');
-var JaysonMiddleware = module.exports = function(server, options) {
+var JaysonMiddleware = function(server, options) {
return function(req, res, next) {
var options = utils.merge(server.options, options || {});
@@ -41,3 +41,5 @@ var JaysonMiddleware = module.exports = function(server, options) {
}
};
};
+
+module.exports = JaysonMiddleware;

0 comments on commit b3bb6e5

Please sign in to comment.