readmeasy
Version:
Creates README.md for node modules using any template engine as easy as possible.
75 lines • 2.73 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.firstAvailable = exports.prefixLines = exports.changeCase = void 0;
const changeCaseLib = __importStar(require("change-case"));
const title_case_1 = require("title-case");
/** @ignore */
const caseMethods = { ...changeCaseLib, titleCase: title_case_1.titleCase };
/**
* Implements the library [change-case](https://github.com/blakeembrey/change-case).
*
* @ignore
* @param to is shorthand or full name for the change-case function.
* @param string is the string to modify.
* @returns string with case changed.
* @example
* changeCase("camelCase", "test string"); // testString
*/
function changeCase(string, to) {
const method = (to.endsWith("Case") ? to : `${to}Case`);
return caseMethods[method](string);
}
exports.changeCase = changeCase;
/**
* Prefixes a string to the beginning of each line in the first string
*
* @ignore
* @param string is the string to modify.
* @param replacer is the string to prefix to each line.
* @returns prefixed lines.
* @example
* prefixLines("abc\nabc", "--");
* // --abc
* // --abc
*/
function prefixLines(string, replacer = "") {
return string ? replacer + string.replace(/[\r\n]/g, `$&${replacer}`) : "";
}
exports.prefixLines = prefixLines;
/**
* Returns first defined or non-empty input. This may be useful for `handlebars`, because it does not provide
* short circuit operator like `nunjucks`
*
* @ignore
* @param input is list of inputs to check.
* @example
* // Handlebars:
* {{ '{{ firstAvaialbale package.label package.name }}' }}
*
* // Equals this in nunjucks
* {{ '{{ package.label or package.name }}' }}
*/
function firstAvailable(...input) {
return input.find((candidate) => candidate !== undefined && candidate !== "");
}
exports.firstAvailable = firstAvailable;
//# sourceMappingURL=helpers.js.map
;