Explorar o código

improve naming in API

d98762625 %!s(int64=6) %!d(string=hai) anos
pai
achega
a7874cc351
Modificáronse 2 ficheiros con 10 adicións e 11 borrados
  1. 7 8
      src/node/api.mjs
  2. 3 3
      src/node/config/scripts/generateNodeIndex.mjs

+ 7 - 8
src/node/api.mjs

@@ -127,17 +127,16 @@ function prepareOp(opInstance, input, args) {
 
 
 /**
- * createArgOptions
+ * createArgInfo
  *
- * Create an object of options for each option or togglestring argument
- * in the given operation.
+ * Create an object of options for each argument in the given operation
  *
  * Argument names are converted to camel case for consistency.
  *
  * @param {Operation} op - the operation to extract args from
- * @returns {{}} - arrays of options for option and toggleString args.
+ * @returns {{}} - arrays of options for args.
 */
-function createArgOptions(op) {
+function createArgInfo(op) {
     const result = {};
     op.args.forEach((a) => {
         if (a.type === "option" || a.type === "editableOption") {
@@ -173,7 +172,7 @@ function createArgOptions(op) {
  * @returns {Function} The operation's run function, wrapped in
  * some type conversion logic
  */
-export function wrap(OpClass) {
+export function _wrap(OpClass) {
 
     // Check to see if class's run function is async.
     const opInstance = new OpClass();
@@ -218,7 +217,7 @@ export function wrap(OpClass) {
 
     // used in chef.help
     wrapped.opName = OpClass.name;
-    wrapped.argOptions = createArgOptions(opInstance);
+    wrapped.args = createArgInfo(opInstance);
 
     return wrapped;
 }
@@ -321,7 +320,7 @@ export function bake(){
  * Explain that the given operation is not included in the Node.js version.
  * @param {String} name - name of operation
  */
-export function explainExludedFunction(name) {
+export function _explainExludedFunction(name) {
     /**
      * Throw new error type with useful message.
     */

+ 3 - 3
src/node/config/scripts/generateNodeIndex.mjs

@@ -40,7 +40,7 @@ let code = `/**
 
 import "babel-polyfill";
 import NodeDish from "./NodeDish";
-import { wrap, help, bake, explainExludedFunction } from "./api";
+import { _wrap, help, bake, _explainExludedFunction } from "./api";
 import {
     // import as core_ to avoid name clashes after wrap.
 `;
@@ -74,11 +74,11 @@ function generateChef() {
 `;
 
 includedOperations.forEach((op) => {
-    code += `        "${decapitalise(op)}": wrap(core_${op}),\n`;
+    code += `        "${decapitalise(op)}": _wrap(core_${op}),\n`;
 });
 
 excludedOperations.forEach((op) => {
-    code += `        "${decapitalise(op)}": explainExludedFunction("${op}"),\n`;
+    code += `        "${decapitalise(op)}": _explainExludedFunction("${op}"),\n`;
 });
 
 code += `    };