JSPM

@demouth/mb_strimwidth

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15
  • Score
    100M100P100Q57588F
  • License MIT

mb_strimwidth ported to JavaScript. Truncates string to specified width, where halfwidth characters count as 1, and fullwidth characters count as 2.

Package Exports

  • @demouth/mb_strimwidth
  • @demouth/mb_strimwidth/dist/index.cjs.js
  • @demouth/mb_strimwidth/dist/index.es.js
  • @demouth/mb_strimwidth/dist/mb_strimwidth.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@demouth/mb_strimwidth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

mb_strimwidth

mb_strimwidth ported to JavaScript.

Truncates string to specified width, where halfwidth characters count as 1, and fullwidth characters count as 2. See » http://www.unicode.org/reports/tr11/ for details regarding East Asian character widths.

CircleCI

Installation

Using npm:

npm install @demouth/mb_strimwidth

Using unpkg CDN:

<script src="https://unpkg.com/@demouth/mb_strimwidth@1.0.3/dist/mb_strimwidth.min.js"></script>

Examples

This package has the same result as mb_strimwidth() in PHP.

ES Module:

import { mb_strimwidth } from "@demouth/mb_strimwidth";
console.log(mb_strimwidth('𩸽定食が食べたい😆', 0, 14, '...')); // 𩸽定食が食...

CommonJS:

const { mb_strimwidth } = require("@demouth/mb_strimwidth");
console.log(mb_strimwidth('𩸽定食が食べたい😆', 0, 14, '...')); // 𩸽定食が食...

Browser:

<script src="https://unpkg.com/@demouth/mb_strimwidth@1.0.3/dist/mb_strimwidth.min.js"></script>
<script>
  console.log(mb_strimwidth('𩸽定食が食べたい😆', 0, 14, '...')); // 𩸽定食が食...
</script>

Reference(PHP 7.3.28):

var_dump(mb_strimwidth('𩸽定食が食べたい😆', 0, 14, '...')); // string(19) "𩸽定食が食..."

https://www.php.net/manual/en/function.mb-strimwidth.php