mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2025-01-03 10:22:11 +01:00
JSDoc comments.
This commit is contained in:
parent
7c94d1865e
commit
9fbaeb520f
1 changed files with 56 additions and 3 deletions
59
lib/index.js
59
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) {
|
GitStats.save = function (stats, callback) {
|
||||||
Fs.writeFile(STORE_PATH, JSON.stringify(stats, null, 1), 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) {
|
GitStats.iterateDays = function (data, callback) {
|
||||||
|
|
||||||
if (typeof data === "function") {
|
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) {
|
GitStats.graph = function (data, callback) {
|
||||||
|
|
||||||
if (typeof data === "function") {
|
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.calendar = function (data, callback) {
|
||||||
GitStats.graph(data, function (err, graph) {
|
GitStats.graph(data, function (err, graph) {
|
||||||
if (err) { return callback(err); }
|
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) {
|
GitStats.ansiCalendar = function (data, callback) {
|
||||||
|
|
||||||
if (typeof data === "function") {
|
if (typeof data === "function") {
|
||||||
|
@ -228,8 +283,6 @@ GitStats.ansiCalendar = function (data, callback) {
|
||||||
GitStats.iterateDays(function (cDay, mDay) {
|
GitStats.iterateDays(function (cDay, mDay) {
|
||||||
sDay = mDay.format("ddd");
|
sDay = mDay.format("ddd");
|
||||||
if (mDay.format("D") === "1") {
|
if (mDay.format("D") === "1") {
|
||||||
debugger
|
|
||||||
//months[mDay.format(DATE_FORMAT)] = mDay.format("MMM");
|
|
||||||
months.push(mDay.format("MMM"));
|
months.push(mDay.format("MMM"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue