How to use meaw - 3 common examples

To help you get started, we’ve selected a few meaw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github susisu / atom-markdown-table-editor / lib / table.js View on Github external
function length(str, eawOptions) {
  let len = 0;
  for (const char of str) {
    if (eawOptions.alwaysWideChars.has(char)) {
      len += 2;
      continue;
    }
    if (eawOptions.alwaysNarrowChars.has(char)) {
      len += 1;
      continue;
    }
    switch (getEAW(char)) {
    case 'F':
    case 'W':
      len += 2;
      break;
    case 'A':
      len += eawOptions.ambiguousAsWide ? 2 : 1;
      break;
    default:
      len += 1;
    }
  }
  return len;
}
github susisu / mte-kernel / lib / formatter.js View on Github external
export function _computeTextWidth(text, options) {
  const normalized = options.normalize ? text.normalize("NFC") : text;
  let w = 0;
  for (const char of normalized) {
    if (options.wideChars.has(char)) {
      w += 2;
      continue;
    }
    if (options.narrowChars.has(char)) {
      w += 1;
      continue;
    }
    switch (getEAW(char)) {
    case "F":
    case "W":
      w += 2;
      break;
    case "A":
      w += options.ambiguousAsWide ? 2 : 1;
      break;
    default:
      w += 1;
    }
  }
  return w;
}
github vscode-restructuredtext / vscode-restructuredtext / src / features / underline.ts View on Github external
export function underlineWidth(line: string): number {
    return meaw.computeWidth(line.normalize());
}

meaw

Utilities for Unicode East Asian Width

MIT
Latest version published 1 month ago

Package Health Score

67 / 100
Full package analysis

Popular meaw functions