UNPKG

typia

Version:

Superfast runtime validators with only one line

26 lines 876 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.__notationUnsnake = void 0; const __notationUnsnake = (props) => (str) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars let prefix = ""; for (let i = 0; i < str.length; i++) { if (str[i] === "_") prefix += "_"; else break; } if (prefix.length !== 0) str = str.substring(prefix.length); const out = (s) => `${prefix}${s}`; if (str.length === 0) return out(""); const items = str.split("_").filter((s) => s.length !== 0); return items.length === 0 ? out("") : items.length === 1 ? out(props.plain(items[0])) : out(items.map(props.snake).join("")); }; exports.__notationUnsnake = __notationUnsnake; //# sourceMappingURL=__notationUnsnake.js.map