improve naming in API

This commit is contained in:
d98762625 2019-04-04 11:28:46 +01:00
parent 638093d40e
commit a7874cc351
2 changed files with 10 additions and 11 deletions

View file

@ -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.
*/

View file

@ -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 += ` };