mb_strimwidth ported to JavaScript. Truncates string to specified width, where halfwidth characters count as 1, and fullwidth characters count as 2.
npm install @demouth/mb_strimwidthmb_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.

Using npm:
``sh`
npm install @demouth/mb_strimwidth
Using unpkg CDN:
`html`
This package has the same result as mb_strimwidth() in PHP.
ES Module:
`js`
import { mb_strimwidth } from "@demouth/mb_strimwidth";
console.log(mb_strimwidth('𩸽定食が食べたい😆', 0, 14, '...')); // 𩸽定食が食...
CommonJS:
`js`
const { mb_strimwidth } = require("@demouth/mb_strimwidth");
console.log(mb_strimwidth('𩸽定食が食べたい😆', 0, 14, '...')); // 𩸽定食が食...
Browser:
`html`
Reference(PHP 7.3.28):
`php``
var_dump(mb_strimwidth('𩸽定食が食べたい😆', 0, 14, '...')); // string(19) "𩸽定食が食..."
https://www.php.net/manual/en/function.mb-strimwidth.php