From 9fbaeb520f768a9f2b091d06c6a7a9c816a8407f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Sun, 8 Feb 2015 20:15:25 +0200 Subject: [PATCH] JSDoc comments. --- lib/index.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index ad89705..4f717e1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -100,10 +100,35 @@ GitStats.get = function (callback) { }); }; +/** + * save + * Saves the provided stats. + * + * @name save + * @function + * @param {Object} stats The stats to be saved. + * @param {Function} callback The callback function. + * @return {undefined} + */ GitStats.save = function (stats, callback) { Fs.writeFile(STORE_PATH, JSON.stringify(stats, null, 1), callback); -} +}; +/** + * iterateDays + * Iterate the days, calling the callback function for each day. + * + * @name iterateDays + * @function + * @param {Object} data An object containing the following fields: + * + * - `start` (Moment): A `Moment` date object representing the start date (default: *an year ago*). + * - `end` (Moment): A `Moment` date object representing the end date (default: *now*). + * - `format` (String): The format of the date (default: `"MMM D, YYYY"`). + * + * @param {Function} callback The callback function called with the current day formatted (type: string) and the `Moment` date object. + * @return {undefined} + */ GitStats.iterateDays = function (data, callback) { if (typeof data === "function") { @@ -132,6 +157,16 @@ GitStats.iterateDays = function (data, callback) { } }; +/** + * graph + * Creates an object with the stats on the provided period (default: *last year*). + * + * @name graph + * @function + * @param {Object} data The object passed to the `iterateDays` method. + * @param {Function} callback The callback function. + * @return {undefined} + */ GitStats.graph = function (data, callback) { if (typeof data === "function") { @@ -163,6 +198,16 @@ GitStats.graph = function (data, callback) { }); }; +/** + * calendar + * Creates the calendar data for the provided period (default: *last year*). + * + * @name calendar + * @function + * @param {Object} data The object passed to the `graph` method. + * @param {Function} callback The callback function. + * @return {undefined} + */ GitStats.calendar = function (data, callback) { GitStats.graph(data, function (err, graph) { if (err) { return callback(err); } @@ -205,6 +250,16 @@ GitStats.calendar = function (data, callback) { }); }; +/** + * ansiCalendar + * Creates the ANSI contributions calendar. + * + * @name ansiCalendar + * @function + * @param {Object} data The object passed to the `calendar` method. + * @param {Function} callback The callback function. + * @return {undefined} + */ GitStats.ansiCalendar = function (data, callback) { if (typeof data === "function") { @@ -228,8 +283,6 @@ GitStats.ansiCalendar = function (data, callback) { GitStats.iterateDays(function (cDay, mDay) { sDay = mDay.format("ddd"); if (mDay.format("D") === "1") { - debugger - //months[mDay.format(DATE_FORMAT)] = mDay.format("MMM"); months.push(mDay.format("MMM")); }