Merge pull request #18 from Nimblr/jsdoc

Change to JSDoc type formatting {type}
This commit is contained in:
2017-06-24 13:08:21 +02:00
committed by GitHub
4 changed files with 59 additions and 59 deletions
+6 -6
View File
@@ -55,9 +55,9 @@ function resetEnqLinkTimer() {
/** /**
* Client session function - inherits from session() * Client session function - inherits from session()
* *
* @param obj sock - socket object * @param {object} sock - socket object
* @param obj options - as derived from client() * @param {object} options - as derived from client()
* @return obj (returnObj) * @return {object} (returnObj)
*/ */
function clientSession(sock, options) { function clientSession(sock, options) {
var returnObj = session(sock); var returnObj = session(sock);
@@ -89,10 +89,10 @@ function clientSession(sock, options) {
} }
/** /**
* Setup a client * Setup a client.
* *
* @param obj options - host, port, username, password * @param {object} options - host, port, username, password, tls, enqLinkTiming
* @param func callback(err, session) * @param {function} callback(err, session)
*/ */
function client(options, callback) { function client(options, callback) {
var sock; var sock;
+7 -7
View File
@@ -10,7 +10,7 @@ var log = require('winston'),
/** /**
* Try to log a connecting peer in * Try to log a connecting peer in
* *
* @param obj pduObj * @param {object} pduObj
*/ */
function login(pduObj) { function login(pduObj) {
var that = this; var that = this;
@@ -97,9 +97,9 @@ function resetEnqLinkTimer() {
/** /**
* Server session function - inherits from session() * Server session function - inherits from session()
* *
* @param obj sock - socket object * @param {object} sock - socket object
* @param obj options - as derived from server() * @param {object} options - as derived from server()
* @return obj (returnObj) * @return {object} (returnObj)
*/ */
function serverSession(sock, options) { function serverSession(sock, options) {
var returnObj = session(sock); var returnObj = session(sock);
@@ -143,8 +143,8 @@ function serverSession(sock, options) {
/** /**
* Setup a server * Setup a server
* *
* @param obj options - host, port, checkuserpass() etc (OPTIONAL) * @param {object} options - host, port, checkuserpass() etc (OPTIONAL)
* @param func callback(err, session) * @param {function} callback(err, session)
*/ */
function server(options, callback) { function server(options, callback) {
var tlsOrNet; var tlsOrNet;
@@ -174,7 +174,7 @@ function server(options, callback) {
var returnObj = serverSession(sock, options); var returnObj = serverSession(sock, options);
// We have a connection - a socket object is assigned to the connection automatically // We have a connection - a socket object is assigned to the connection automatically
log.verbose('larvitsmpp: lib/server.js: server() - Incomming connection! From: ' + sock.remoteAddress + ':' + sock.remotePort); log.verbose('larvitsmpp: lib/server.js: server() - Incoming connection! From: ' + sock.remoteAddress + ':' + sock.remotePort);
callback(null, returnObj); callback(null, returnObj);
}).listen(options.port, options.host); }).listen(options.port, options.host);
+18 -18
View File
@@ -103,8 +103,8 @@ function closeSocket() {
/** /**
* Write PDU to socket * Write PDU to socket
* *
* @param buf or obj pdu - can also take PDU object * @param {buffer|object} pdu - can also take PDU object
* @param bol closeAfterSend - if true will close the socket after sending * @param {boolean} closeAfterSend - if true will close the socket after sending
*/ */
function sockWrite(pdu, closeAfterSend) { function sockWrite(pdu, closeAfterSend) {
var that = this; var that = this;
@@ -139,9 +139,9 @@ function sockWrite(pdu, closeAfterSend) {
/** /**
* Send a PDU to the remote * Send a PDU to the remote
* *
* @param buf or obj pdu * @param {buffer|object} pdu
* @param bol closeAfterSend - Will close after return is fetched. Defaults to false (OPTIONAL) * @param {boolean} closeAfterSend - Will close after return is fetched. Defaults to false (OPTIONAL)
* @param func callback(err, retPdu) (OPTIONAL) * @param {function} callback(err, retPdu) (OPTIONAL)
*/ */
function send(pdu, closeAfterSend, callback) { function send(pdu, closeAfterSend, callback) {
var pduObj = pdu, var pduObj = pdu,
@@ -213,11 +213,11 @@ function send(pdu, closeAfterSend, callback) {
/** /**
* Send a return to given PDU * Send a return to given PDU
* *
* @param obj or buf pdu * @param {buffer|object} pdu
* @param str status - see list at defs.errors - defaults to 'ESME_ROK' - no error (OPTIONAL) * @param {string} status - see list at defs.errors - defaults to 'ESME_ROK' - no error (OPTIONAL)
* @param obj params (OPTIONAL) * @param {object} [params]
* @param bol closeAfterSend - if true will close the socket after sending (OPTIONAL) * @param {boolean} closeAfterSend - if true will close the socket after sending (OPTIONAL)
* @param func callback(err, retPdu) (OPTIONAL) * @param {function} [callback(err, retPdu)]
*/ */
function sendReturn(pdu, status, params, closeAfterSend, callback) { function sendReturn(pdu, status, params, closeAfterSend, callback) {
var that = this; var that = this;
@@ -259,13 +259,13 @@ function sendReturn(pdu, status, params, closeAfterSend, callback) {
/** /**
* Send an SMS * Send an SMS
* *
* @param obj smsOptions * @param {object} smsOptions
* from - alphanum or international format * from - alphanum or international format
* to - international format * to - international format
* message - string * message - string
* dlr - boolean defaults to false * dlr - boolean defaults to false
* flash - boolean defaults to false * flash - boolean defaults to false
* @param func callback(err, smsIds, retPduObjs) * @param {function} callback(err, smsIds, retPduObjs)
*/ */
function sendSms(smsOptions, callback) { function sendSms(smsOptions, callback) {
var pduObj = {}; var pduObj = {};
@@ -310,12 +310,12 @@ function sendSms(smsOptions, callback) {
/** /**
* Send a longer SMS than 1120 bits * Send a longer SMS than 1120 bits
* *
* @param obj smsOptions * @param {object} smsOptions
* from - alphanum or international format * from - alphanum or international format
* to - international format * to - international format
* message - string * message - string
* dlr - boolean defaults to false * dlr - boolean defaults to false
* @param func callback(err, smsId, retPduObj) * @param {function} callback(err, smsId, retPduObj)
*/ */
function sendLongSms(smsOptions, callback) { function sendLongSms(smsOptions, callback) {
var that = this, var that = this,
@@ -483,8 +483,8 @@ function checkLongSmses() {
/** /**
* Generic session function * Generic session function
* *
* @param obj sock - socket object * @param {object} sock - socket object
* @return obj (returnObj) * @return {object} (returnObj)
*/ */
function session(sock) { function session(sock) {
var returnObj = new events.EventEmitter(); var returnObj = new events.EventEmitter();
@@ -508,10 +508,10 @@ function session(sock) {
returnObj.utils = utils; returnObj.utils = utils;
// Temporary storage for long sms parts // Temporary storage for long sms parts
// These should be cleared if they lingre to long to avoid memory leaks // These should be cleared if they linger to long to avoid memory leaks
returnObj.longSmses = {}; returnObj.longSmses = {};
// Temporary storage for DLRs to long smses // Temporary storage for DLRs to long SMSes
// We keep them like this to be able to simulate a single DLR when all parts have gotten DLRs // We keep them like this to be able to simulate a single DLR when all parts have gotten DLRs
returnObj.longSmsDlrs = {}; returnObj.longSmsDlrs = {};
+28 -28
View File
@@ -5,10 +5,10 @@ var log = require('winston'),
bundleMsgId = 0; bundleMsgId = 0;
/** /**
* Calcualte cmdLength from object * Calculate cmdLength from object
* *
* @param obj obj * @param {object} obj
* @param func callback(err, cmdLength) * @param {function} callback(err, cmdLength)
*/ */
function calcCmdLength(obj, callback) { function calcCmdLength(obj, callback) {
var cmdLength = 16, // All commands are at least 16 octets long var cmdLength = 16, // All commands are at least 16 octets long
@@ -65,9 +65,9 @@ function calcCmdLength(obj, callback) {
/** /**
* Write PDU to buffer * Write PDU to buffer
* *
* @param obj obj - the PDU object to be written to buffer * @param {object} obj - the PDU object to be written to buffer
* @param int cmdLength - The length of the pdu buffer * @param {number} cmdLength - The length of the pdu buffer
* @param func callback(err, buff) * @param {function} callback(err, buff)
*/ */
function writeBuffer(obj, cmdLength, callback) { function writeBuffer(obj, cmdLength, callback) {
var offset = 16, // Start the offset on the body var offset = 16, // Start the offset on the body
@@ -162,10 +162,10 @@ function writeBuffer(obj, cmdLength, callback) {
/** /**
* Decode a short_message * Decode a short_message
* *
* @param buf buffer * @param {buffer} buffer
* @param str encoding 'ASCII', 'LATIN1' or 'UCS2' or hex values * @param {string} encoding 'ASCII', 'LATIN1' or 'UCS2' or hex values
* @param int offset - defaults to 0 * @param {number} offset - defaults to 0
* @return str in utf8 format * @return {string} in utf8 format
*/ */
function decodeMsg(buffer, encoding, offset) { function decodeMsg(buffer, encoding, offset) {
var checkEnc; var checkEnc;
@@ -199,9 +199,9 @@ function encodeMsg(str) {
/** /**
* Transforms a PDU to an object * Transforms a PDU to an object
* *
* @param buf pdu * @param {buffer} pdu
* @param bol stupidNullByte - Define if the short_message should be followed by a stupid NULL byte - will be auto resolved if left undefined * @param {boolean} stupidNullByte - Define if the short_message should be followed by a stupid NULL byte - will be auto resolved if left undefined
* @param func callback(err, obj) * @param {function} callback(err, obj)
*/ */
function pduToObj(pdu, stupidNullByte, callback) { function pduToObj(pdu, stupidNullByte, callback) {
var retObj = {'params': {}, 'tlvs': {}}, var retObj = {'params': {}, 'tlvs': {}},
@@ -359,8 +359,8 @@ function pduToObj(pdu, stupidNullByte, callback) {
/** /**
* Transform an object to a PDU * Transform an object to a PDU
* *
* @param obj obj - example {'cmdName': 'bind_transceiver_resp', 'cmdStatus': 'ESME_ROK', 'seqNr': 2} - to add parameters add a key 'params' as object * @param {object} obj - example {'cmdName': 'bind_transceiver_resp', 'cmdStatus': 'ESME_ROK', 'seqNr': 2} - to add parameters add a key 'params' as object
* @param func callback(err, pdu) * @param {function} callback(err, pdu)
*/ */
function objToPdu(obj, callback) { function objToPdu(obj, callback) {
var err = null, var err = null,
@@ -438,11 +438,11 @@ function objToPdu(obj, callback) {
/** /**
* Create a PDU as a return to another PDU * Create a PDU as a return to another PDU
* *
* @param obj or buf pdu * @param {object|buffer} pdu
* @param str status - see list at defs.errors - defaults to 'ESME_ROK' - no error (OPTIONAL) * @param {string} status - see list at defs.errors - defaults to 'ESME_ROK' - no error (OPTIONAL)
* @param obj params (OPTIONAL) * @param {object} [params]
* @param obj tlvs (OPTIONAL) * @param {object} [tlvs]
* @param func callback(err, pduBuffer) (OPTIONAL) * @param {function} [callback(err, pduBuffer)]
*/ */
function pduReturn(pdu, status, params, tlvs, callback) { function pduReturn(pdu, status, params, tlvs, callback) {
var err = null, var err = null,
@@ -544,8 +544,8 @@ function pduReturn(pdu, status, params, tlvs, callback) {
/** /**
* Format a js date object as ugly SMPP date format * Format a js date object as ugly SMPP date format
* *
* @param obj jsDateObj * @param {object} jsDateObj
* @return str * @return {string}
*/ */
function smppDate(jsDateObj) { function smppDate(jsDateObj) {
var uglyStr = ''; var uglyStr = '';
@@ -582,8 +582,8 @@ function smppDate(jsDateObj) {
/** /**
* Calculate bitCount of short_message * Calculate bitCount of short_message
* *
* @param str msg * @param {string} msg
* @param str encoding - Force encoding ASCII or UCS2 (OPTIONAL) * @param {string} encoding - Force encoding ASCII or UCS2 (OPTIONAL)
* @return integer * @return integer
*/ */
function bitCount(msg, encoding) { function bitCount(msg, encoding) {
@@ -601,8 +601,8 @@ function bitCount(msg, encoding) {
/** /**
* Split a message into multiple messages * Split a message into multiple messages
* *
* @param str msg * @param {string} msg
* @param str encoding - Force encoding ASCII or UCS2 (OPTIONAL) * @param {string} encoding - Force encoding ASCII or UCS2 (OPTIONAL)
* @return array of buffers * @return array of buffers
*/ */
function splitMsg(msg, encoding) { function splitMsg(msg, encoding) {
@@ -691,8 +691,8 @@ function splitMsg(msg, encoding) {
* Send a dlr to an sms * Send a dlr to an sms
* This must be called from an sms object context * This must be called from an sms object context
* *
* @param str status - see list at defs.consts.MESSAGE_STATE - defaults to 'DELIVERED' * @param {string} status - see list at defs.consts.MESSAGE_STATE - defaults to 'DELIVERED'
* @param func callback(err, retPdu, dlrPduObj) * @param {function} callback(err, retPdu, dlrPduObj)
*/ */
function smsDlr(status, callback) { function smsDlr(status, callback) {
var shortMessage, var shortMessage,