@shelf/fast-chunk-string
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0 • Public • Published

    fast-chunk-string CircleCI

    Chunk string into equal substrings with unicode support

    Credits to stackoverflow.com/a/29202760/2727317

    Install

    $ yarn add @shelf/fast-chunk-string
    

    Usage

    const fastChunkString = require('@shelf/fast-chunk-string');
    
    // the fastest way
    fastChunkString('unicorns', {size: 2, unicodeAware: false});
    // => ['un', 'ic', 'or', 'ns']
    
    // ignore unicode, still fast but inaccurate
    fastChunkString('😀😃😄😁', {size: 2, unicodeAware: false});
    // => ['😀', '😃', '😄', '😁']
    
    // respect unicode, slow but accurate
    fastChunkString('😀😃😄😁', {size: 2, unicodeAware: true});
    // => ['😀😃', '😄😁']

    Benchmarks

    Run via yarn benchmark. Measured on Macbook Pro 16" with M1 Max processor.

    Running "Without Unicode" suite...
    Progress: 100%
    
      ~33 kb split by 2 kb:
        14 384 027 ops/s, ±0.21%    | 86.51% slower
    
      ~33 kb split by 1 mb:
        106 655 332 ops/s, ±0.12%   | fastest
    
      ~330 kb split by 2 kb:
        1 482 220 ops/s, ±0.34%     | 98.61% slower
    
      ~330 kb split by 1 mb:
        106 442 883 ops/s, ±0.14%   | 0.2% slower
    
      ~3.3 mb split by 2 kb:
        153 356 ops/s, ±0.19%       | 99.86% slower
    
      ~3.3 mb split by 1 mb:
        48 824 019 ops/s, ±0.16%    | 54.22% slower
    
      ~33 mb split by 2 kb:
        14 312 ops/s, ±0.28%        | slowest, 99.99% slower
    
      ~33 mb split by 1 mb:
        7 059 008 ops/s, ±0.32%     | 93.38% slower
    
    Finished 8 cases!
      Fastest: ~33 kb split by 1 mb
      Slowest: ~33 mb split by 2 kb
    Running "Unicode Aware" suite...
    Progress: 100%
    
      ~33 kb split by 2 kb with unicodeAware:
        450 ops/s, ±0.24%   | fastest
    
      ~33 kb split by 1 mb with unicodeAware:
        428 ops/s, ±0.36%   | 4.89% slower
    
      ~330 kb split by 2 kb with unicodeAware:
        45 ops/s, ±0.38%    | 90% slower
    
      ~330 kb split by 1 mb with unicodeAware:
        41 ops/s, ±0.42%    | slowest, 90.89% slower
    
    Finished 4 cases!
      Fastest: ~33 kb split by 2 kb with unicodeAware
      Slowest: ~330 kb split by 1 mb with unicodeAware
    

    See Also

    Publish

    $ git checkout master
    $ yarn version
    $ yarn publish
    $ git push origin master --tags

    License

    MIT © Shelf

    Install

    npm i @shelf/fast-chunk-string

    DownloadsWeekly Downloads

    497

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    7.63 kB

    Total Files

    11

    Last publish

    Collaborators

    • anastasiash
    • kchlon
    • dmytro.harazdovskiy
    • duch0416
    • i5adovyi
    • olesiamuller
    • mykola.khytra
    • yuliiakovalchuk
    • el_scrambone
    • bodyaflesh
    • slavammellnikov
    • andrii-nastenko
    • andriisermiahin
    • arkadii007
    • mpushkin
    • batovpavlo
    • vasylhoban
    • andrew214
    • domovoj
    • vozemer
    • oleksii.dymnich
    • set001
    • bogdan.kyba
    • dima-bond
    • maksym.hayovets
    • oles.zadorozhnyy
    • ss1l
    • gemshelf
    • d-mii-
    • hartzler
    • tarasdyksan
    • andrii_butsa
    • nazarko_suv
    • bogdan.kolesnyk
    • vitaliishcherban
    • vladgolubev
    • marianna-milovanova
    • hmelenok
    • knupman
    • maaraanas
    • terret
    • chapelskyi.slavik
    • pihorb
    • irynah
    • diana.kryskuv
    • andy.raven
    • rafler
    • mykola.chepkyi
    • sskalp88
    • demiansua
    • yuriil
    • ktv18
    • drews_abuse
    • rostyslav-horytskyi
    • whodeen