🔠 Converts string to constant case.
Syntax
TypeScript
import { constantCase } from '@opentf/std'; constantCase(str: string): string;
Parameters
str: The string to convert.
Returns
The CONSTANT_CASEd string — snakeCase in upper case, the spelling environment variables and action type constants use.
Examples
TypeScript
constantCase('Foo Bar') //=> 'FOO_BAR' constantCase('fooBar') //=> 'FOO_BAR' constantCase('--foo-bar--') //=> 'FOO_BAR'
A run of capitals still splits at the word boundary:
TypeScript
constantCase('XMLHttpRequest') //=> 'XML_HTTP_REQUEST'