Browse Source

improve naming in API

d98762625 6 năm trước cách đây
mục cha
commit
a7874cc351

+ 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.
  * Argument names are converted to camel case for consistency.
  *
  *
  * @param {Operation} op - the operation to extract args from
  * @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 = {};
     const result = {};
     op.args.forEach((a) => {
     op.args.forEach((a) => {
         if (a.type === "option" || a.type === "editableOption") {
         if (a.type === "option" || a.type === "editableOption") {
@@ -173,7 +172,7 @@ function createArgOptions(op) {
  * @returns {Function} The operation's run function, wrapped in
  * @returns {Function} The operation's run function, wrapped in
  * some type conversion logic
  * some type conversion logic
  */
  */
-export function wrap(OpClass) {
+export function _wrap(OpClass) {
 
 
     // Check to see if class's run function is async.
     // Check to see if class's run function is async.
     const opInstance = new OpClass();
     const opInstance = new OpClass();
@@ -218,7 +217,7 @@ export function wrap(OpClass) {
 
 
     // used in chef.help
     // used in chef.help
     wrapped.opName = OpClass.name;
     wrapped.opName = OpClass.name;
-    wrapped.argOptions = createArgOptions(opInstance);
+    wrapped.args = createArgInfo(opInstance);
 
 
     return wrapped;
     return wrapped;
 }
 }
@@ -321,7 +320,7 @@ export function bake(){
  * Explain that the given operation is not included in the Node.js version.
  * Explain that the given operation is not included in the Node.js version.
  * @param {String} name - name of operation
  * @param {String} name - name of operation
  */
  */
-export function explainExludedFunction(name) {
+export function _explainExludedFunction(name) {
     /**
     /**
      * Throw new error type with useful message.
      * 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 "babel-polyfill";
 import NodeDish from "./NodeDish";
 import NodeDish from "./NodeDish";
-import { wrap, help, bake, explainExludedFunction } from "./api";
+import { _wrap, help, bake, _explainExludedFunction } from "./api";
 import {
 import {
     // import as core_ to avoid name clashes after wrap.
     // import as core_ to avoid name clashes after wrap.
 `;
 `;
@@ -74,11 +74,11 @@ function generateChef() {
 `;
 `;
 
 
 includedOperations.forEach((op) => {
 includedOperations.forEach((op) => {
-    code += `        "${decapitalise(op)}": wrap(core_${op}),\n`;
+    code += `        "${decapitalise(op)}": _wrap(core_${op}),\n`;
 });
 });
 
 
 excludedOperations.forEach((op) => {
 excludedOperations.forEach((op) => {
-    code += `        "${decapitalise(op)}": explainExludedFunction("${op}"),\n`;
+    code += `        "${decapitalise(op)}": _explainExludedFunction("${op}"),\n`;
 });
 });
 
 
 code += `    };
 code += `    };