MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / paramCase

Function paramCase

packages/common-helpers/src/param-case.ts:5–22  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

3const DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
4
5export function paramCase(input: string) {
6 const result = input
7 .replace(DEFAULT_SPLIT_REGEXP_1, '$1\0$2')
8 .replace(DEFAULT_SPLIT_REGEXP_2, '$1\0$2')
9 .replace(DEFAULT_STRIP_REGEXP, '\0');
10
11 let start = 0;
12 let end = result.length;
13
14 while (result.charAt(start) === '\0') start++;
15 while (result.charAt(end - 1) === '\0') end--;
16
17 return result
18 .slice(start, end)
19 .split('\0')
20 .map((str) => str.toLowerCase())
21 .join('-');
22}

Callers 2

param-case.test.tsFile · 0.90
makeErrorMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected