MCPcopy Create free account
hub / github.com/rollup/plugins / isWellFormedString

Function isWellFormedString

packages/pluginutils/src/dataToEsm.ts:65–71  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

63const hasStringIsWellFormed = 'isWellFormed' in String.prototype;
64
65function isWellFormedString(input: string): boolean {
66 // @ts-expect-error String::isWellFormed exists from ES2024. tsconfig lib is set to ES6
67 if (hasStringIsWellFormed) return input.isWellFormed();
68
69 // https://github.com/tc39/proposal-is-usv-string/blob/main/README.md#algorithm
70 return !/\p{Surrogate}/u.test(input);
71}
72
73// Matches the ECMAScript `IdentifierName` grammar, which (unlike a binding
74// identifier) also accepts reserved words such as `switch`/`await`. Such names

Callers 1

dataToEsmFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected