Native Penguin Milk

    string-bionic-split
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.3 • Public • Published

    string-bionic-split

    Calculate a word string split position index for later highlighting

    page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

    Install

    This package is pure ESM.

    npm i string-bionic-split

    Quick Take

    import { strict as assert } from "assert";
    
    import { split } from "string-bionic-split";
    
    const sources = [
      "the",
      "quick",
      "brown",
      "fox",
      "jumps",
      "over",
      "a",
      "lazy",
      "dog",
    ];
    
    const splitSources = sources.map(
      (str) => `${str.slice(0, split(str))} + ${str.slice(split(str))}`
    );
    
    assert.deepEqual(splitSources, [
      "t + he",
      "qui + ck",
      "bro + wn",
      "f + ox",
      "jum + ps",
      "ov + er",
      "a + ",
      "la + zy",
      "d + og",
    ]);

    Documentation

    Please visit codsen.com for a full description of the API.

    Contributing

    To report bugs or request features or assistance, raise an issue on GitHub.

    Licence

    MIT License.

    Copyright © 2010-2022 Roy Revelt and other contributors.

    ok codsen star

    Install

    npm i string-bionic-split

    DownloadsWeekly Downloads

    5

    Version

    2.0.3

    License

    MIT

    Unpacked Size

    11.6 kB

    Total Files

    7

    Last publish

    Collaborators

    • royston