How to use truncate-utf8-bytes - 2 common examples

To help you get started, we’ve selected a few truncate-utf8-bytes 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 algolia / npm-search / src / formatPkg.js View on Github external
modified: Date.parse(cleaned.modified),
    lastPublisher,
    owners: (cleaned.owners || []).map(formatUser),
    bin: cleaned.bin,
    types,
    moduleTypes,
    lastCrawl: new Date().toISOString(),
    _searchInternal: {
      alternativeNames,
    },
  };

  const totalSize = sizeof(rawPkg);
  if (totalSize > config.maxObjSize) {
    const sizeDiff = sizeof(rawPkg.readme) - totalSize;
    rawPkg.readme = `${truncate(
      rawPkg.readme,
      config.maxObjSize - sizeDiff
    )} **TRUNCATED**`;
  }

  return traverse(rawPkg).forEach(maybeEscape);
}
github unfoldingWord / translationCore / src / js / components / home / projectsManagement / TruncateAcronym.js View on Github external
function TruncateAcronym(longText, abbrev, len, targetLanguageBookName) {
  const bookName = targetLanguageBookName || longText;

  if (bookName.length + abbrev.length + 3 > len) {
    return (
      <div> {truncateItem( '('.concat(abbrev, ') ', bookName), len + 3) + '...' }
        <span>{'('.concat(abbrev, ') ', bookName)}</span>
      </div>
    );
  } else {
    return (
      <span> {'('.concat(abbrev, ') ', bookName)}</span>
    );
  }
}

truncate-utf8-bytes

Truncate string to given length in bytes

WTFPL
Latest version published 8 years ago

Package Health Score

68 / 100
Full package analysis

Popular truncate-utf8-bytes functions