Built motion from commit 76eb00b9e.|1.0.24
[motion.git] / public / bower_components / lodash / lib / fp / build-doc.js
index bba62d2..6134449 100644 (file)
@@ -1,41 +1,57 @@
 'use strict';
 
-var _ = require('lodash'),
-    fs = require('fs-extra'),
-    path = require('path'),
-    util = require('../common/util');
+const _ = require('lodash');
+const fs = require('fs-extra');
+const path = require('path');
 
-var mapping = require('../../fp/_mapping'),
-    templatePath = path.join(__dirname, 'template/doc'),
-    template = util.globTemplate(path.join(templatePath, '*.jst'));
+const file = require('../common/file');
+const mapping = require('../common/mapping');
+const util = require('../common/util');
 
-var argNames = ['a', 'b', 'c', 'd'];
+const templatePath = path.join(__dirname, 'template/doc');
+const template = file.globTemplate(path.join(templatePath, '*.jst'));
 
-var templateData = {
-  'mapping': mapping,
-  'toArgOrder': toArgOrder,
-  'toFuncList': toFuncList
+const argNames = ['a', 'b', 'c', 'd'];
+
+const templateData = {
+  mapping,
+  toArgOrder,
+  toFuncList
 };
 
-function toArgOrder(array) {
-  return '`(' + _.map(array, function(value) {
-    return argNames[value];
-  }).join(', ') + ')`';
+/**
+ * Converts arranged argument `indexes` into a named argument string
+ * representation of their order.
+ *
+ * @private
+ * @param {number[]} indexes The arranged argument indexes.
+ * @returns {string} Returns the named argument string.
+ */
+function toArgOrder(indexes) {
+  const reordered = [];
+  _.each(indexes, (newIndex, index) => {
+    reordered[newIndex] = argNames[index];
+  });
+  return '`(' + reordered.join(', ') + ')`';
 }
 
-function toFuncList(array) {
-  var chunks = _.chunk(array.slice().sort(), 5),
-      lastChunk = _.last(chunks),
-      last = lastChunk ? lastChunk.pop() : undefined;
+/**
+ * Converts `funcNames` into a chunked list string representation.
+ *
+ * @private
+ * @param {string[]} funcNames The function names.
+ * @returns {string} Returns the function list string.
+ */
+function toFuncList(funcNames) {
+  let chunks = _.chunk(funcNames.slice().sort(), 5);
+  let lastChunk = _.last(chunks);
+  const lastName = lastChunk ? lastChunk.pop() : undefined;
 
   chunks = _.reject(chunks, _.isEmpty);
   lastChunk = _.last(chunks);
 
-  var result = '`' + _.map(chunks, function(chunk) {
-    return chunk.join('`, `') + '`';
-  }).join(',\n`');
-
-  if (last == null) {
+  let result = '`' + _.map(chunks, chunk => chunk.join('`, `') + '`').join(',\n`');
+  if (lastName == null) {
     return result;
   }
   if (_.size(chunks) > 1 || _.size(lastChunk) > 1) {
@@ -43,20 +59,20 @@ function toFuncList(array) {
   }
   result += ' &';
   result += _.size(lastChunk) < 5 ? ' ' : '\n';
-  return result + '`' + last + '`';
+  return result + '`' + lastName + '`';
 }
 
 /*----------------------------------------------------------------------------*/
 
-function onComplete(error) {
-  if (error) {
-    throw error;
-  }
-}
-
+/**
+ * Creates the FP-Guide wiki at the `target` path.
+ *
+ * @private
+ * @param {string} target The output file path.
+ */
 function build(target) {
   target = path.resolve(target);
-  fs.writeFile(target, template.wiki(templateData), onComplete);
+  fs.writeFile(target, template.wiki(templateData), util.pitch);
 }
 
 build(_.last(process.argv));