UNPKG

typia

Version:

Superfast runtime validators with only one line

25 lines 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._notationPascal = void 0; const __notationRename_1 = require("./private/__notationRename"); const _notationPascalSnake = (str) => { while (str.startsWith("_")) str = str.substring(1); if (str.length === 0) return ""; const index = str.indexOf("_"); return index < 0 ? `${str[0].toUpperCase()}${str.substring(1).toLowerCase()}` : `${str[0].toUpperCase()}${str .substring(1, index) .toLowerCase()}${_notationPascalSnake(str.substring(index + 1))}`; }; exports._notationPascal = (0, __notationRename_1.__notationRename)({ // `PascalCase<T>` capitalizes the first character of an underscore-free key // and keeps the rest verbatim (`userID` -> `UserID`). plain: (str) => `${str[0].toUpperCase()}${str.substring(1)}`, // With an underscore present, each segment is capitalized and its tail is // lowercased (`MAX_COUNT` -> `MaxCount`), matching `PascalizeSnakeString`. snake: _notationPascalSnake, }); //# sourceMappingURL=_notationPascal.js.map