(identifier: string | string[])
| 7 | |
| 8 | /** takes an identifier string and deconstructs and normalizes it. */ |
| 9 | export 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 | * |
no test coverage detected