MCPcopy Create free account
hub / github.com/microsoft/vscode-cpptools / deconstruct

Function deconstruct

Extension/src/Utility/Text/identifiers.ts:9–19  ·  view source on GitHub ↗
(identifier: string | string[])

Source from the content-addressed store, hash-verified

7
8/** takes an identifier string and deconstructs and normalizes it. */
9export function deconstruct(identifier: string | string[]): string[] {
10 if (is.array(identifier)) {
11 return identifier.flatMap(deconstruct);
12 }
13 return `${identifier}`
14 .replace(/([a-z]+)([A-Z])/g, '$1 $2')
15 .replace(/(\d+)([a-z|A-Z]+)/g, '$1 $2')
16 .replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3')
17 .split(/[\W|_]+/)
18 .map((each) => each.toLowerCase());
19}
20/**
21 * Takes an identifier string and deconstructs and normalizes it and smashes it together.
22 *

Callers 4

smashFunction · 0.85
pascalCaseFunction · 0.85
camelCaseFunction · 0.85
dashCaseFunction · 0.85

Calls 1

arrayMethod · 0.80

Tested by

no test coverage detected