Add jsdocs to fp build modules.

This commit is contained in:
John-David Dalton
2016-05-29 16:06:02 -07:00
parent a164735369
commit 695d74d7c5

View File

@@ -18,16 +18,29 @@ var templateData = {
'toFuncList': toFuncList 'toFuncList': toFuncList
}; };
function toArgOrder(array) { /**
* Converts arranged argument `indexes` into a named argument string
* representation of their order.
*
* @param {number[]} indexes The arranged argument indexes.
* @returns {string} Returns the named argument string.
*/
function toArgOrder(indexes) {
var reordered = []; var reordered = [];
_.each(array, function(newIndex, index) { _.each(indexes, function(newIndex, index) {
reordered[newIndex] = argNames[index]; reordered[newIndex] = argNames[index];
}); });
return '`(' + reordered.join(', ') + ')`'; return '`(' + reordered.join(', ') + ')`';
} }
function toFuncList(array) { /**
var chunks = _.chunk(array.slice().sort(), 5), * Converts `funcNames` into a backticked chunked list string representation.
*
* @param {string[]} funcNames The function names.
* @returns {string} Returns the function list string.
*/
function toFuncList(funcNames) {
var chunks = _.chunk(funcNames.slice().sort(), 5),
lastChunk = _.last(chunks), lastChunk = _.last(chunks),
last = lastChunk ? lastChunk.pop() : undefined; last = lastChunk ? lastChunk.pop() : undefined;
@@ -51,12 +64,22 @@ function toFuncList(array) {
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/**
* A no-frills callback that throws any error it receives.
*
* @param {Object} [error] The error object.
*/
function onComplete(error) { function onComplete(error) {
if (error) { if (error) {
throw error; throw error;
} }
} }
/**
* Creates the FP-Guide wiki at the `target` path.
*
* @param {string} target The output file path.
*/
function build(target) { function build(target) {
target = path.resolve(target); target = path.resolve(target);
fs.writeFile(target, template.wiki(templateData), onComplete); fs.writeFile(target, template.wiki(templateData), onComplete);