Skip to content

⬅️ Back to Table of Contents

📄 getStringLength.ts

📊 Analysis Summary

Metric Count
🔧 Functions 2
📦 Imports 1
📊 Variables & Constants 1

📚 Table of Contents

🛠️ File Location:

📂 packages/eslint-plugin/src/util/getStringLength.ts

📦 Imports

Name Source
Graphemer graphemer

Variables & Constants

Name Type Kind Value Exported
splitter Graphemer | undefined let/var *not shown*

Functions

isASCII(value: string): boolean

Code
function isASCII(value: string): boolean {
  return /^[\u0020-\u007f]*$/u.test(value);
}
  • Parameters:
  • value: string
  • Return Type: boolean
  • Calls:
  • /^[\u0020-\u007f]*$/u.test

getStringLength(value: string): number

Code
export function getStringLength(value: string): number {
  if (isASCII(value)) {
    return value.length;
  }

  splitter ??= new Graphemer();

  return splitter.countGraphemes(value);
}
  • Parameters:
  • value: string
  • Return Type: number
  • Calls:
  • isASCII
  • splitter.countGraphemes