UNPKG

typia

Version:

Superfast runtime validators with only one line

19 lines (18 loc) 883 B
import { __notationRename } from "./private/__notationRename.mjs"; //#region src/internal/_notationCamel.ts const _notationCamelSnake = (str) => { while (str.startsWith("_")) str = str.substring(1); if (str.length === 0) return ""; const index = str.indexOf("_"); if (index < 0) return str.toLowerCase(); const middle = str[index + 1]; if (middle === void 0) return str.toLowerCase(); return middle === "_" ? _notationCamelSnake(`${str.substring(0, index)}_${str.substring(index + 2)}`) : `${str.substring(0, index).toLowerCase()}${middle.toUpperCase()}${_notationCamelSnake(str.substring(index + 2))}`; }; const _notationCamel = __notationRename({ plain: (str) => str === str.toUpperCase() ? str.toLowerCase() : `${str[0].toLowerCase()}${str.substring(1)}`, snake: _notationCamelSnake }); //#endregion export { _notationCamel }; //# sourceMappingURL=_notationCamel.mjs.map