UNPKG

boats

Version:

Beautiful Open / Async Template System - Write less yaml with BOATS and Nunjucks.

28 lines (27 loc) 951 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); /** * * @param input * @param {string|array} replace - String or array of string replacements * @return {string} */ const lcFirst_1 = tslib_1.__importDefault(require("../lcFirst")); const ucFirst_1 = tslib_1.__importDefault(require("../ucFirst")); exports.default = (input, replace) => { if (typeof replace === 'string') { replace = [replace]; } if (!Array.isArray(replace)) { throw Error('The replace values must be either a string or an array of strings.'); } let returnString = ''; replace.forEach((replaceItem, i) => { const replaceInString = (i === 0) ? input : returnString; returnString = (0, lcFirst_1.default)((replaceInString.split(replaceItem).map((part) => { return (0, ucFirst_1.default)(part); })).join('')); }); return returnString; };