Convert text to a deterministic uppercase ASCII JavaScript identifier.
Characters outside A-Z, a-z, 0-9, _, and $ become _. A result beginning with a digit is prefixed with _; an empty input therefore returns _.
A-Z
a-z
0-9
_
$
Usage:
import { toJavaScriptGlobalName } from "mazey";const globalName = toJavaScriptGlobalName("@scope/my-library");console.log(globalName); Copy
import { toJavaScriptGlobalName } from "mazey";const globalName = toJavaScriptGlobalName("@scope/my-library");console.log(globalName);
Output:
_SCOPE_MY_LIBRARY Copy
_SCOPE_MY_LIBRARY
Text such as a package name or bundle filename.
An uppercase identifier suitable for an IIFE global name.
TypeError when value is not a string.
value
Convert text to a deterministic uppercase ASCII JavaScript identifier.
Characters outside
A-Z,a-z,0-9,_, and$become_. A result beginning with a digit is prefixed with_; an empty input therefore returns_.Usage:
Output: