Nougat Predominant Middleware

    @demouth/mb_strimwidth

    1.0.0 • Public • Published

    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.0/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.0/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

    Install

    npm i @demouth/mb_strimwidth

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    106 kB

    Total Files

    18

    Last publish

    Collaborators

    • demouth