npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shelf/fast-chunk-string

v4.1.0

Published

Chunk string into equal substrings with unicode support

Readme

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

import fastChunkString from '@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 M2 Max.

Running "Without Unicode" suite...
Progress: 100%

  ~33 kb split by 2 kb:
    14 106 903 ops/s, ±1.71%    | 86.19% slower

  ~33 kb split by 1 mb:
    100 461 043 ops/s, ±1.45%   | 1.63% slower

  ~330 kb split by 2 kb:
    1 600 485 ops/s, ±0.63%     | 98.43% slower

  ~330 kb split by 1 mb:
    102 125 168 ops/s, ±1.50%   | fastest

  ~3.3 mb split by 2 kb:
    161 507 ops/s, ±1.19%       | 99.84% slower

  ~3.3 mb split by 1 mb:
    41 773 807 ops/s, ±1.54%    | 59.1% slower

  ~33 mb split by 2 kb:
    11 098 ops/s, ±0.25%        | slowest, 99.99% slower

  ~33 mb split by 1 mb:
    5 506 349 ops/s, ±0.58%     | 94.61% slower

Finished 8 cases!
  Fastest: ~330 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:
    847 ops/s, ±0.99%   | 12.14% slower

  ~33 kb split by 1 mb with unicodeAware:
    964 ops/s, ±0.25%   | fastest

  ~330 kb split by 2 kb with unicodeAware:
    71 ops/s, ±0.76%    | slowest, 92.63% slower

  ~330 kb split by 1 mb with unicodeAware:
    90 ops/s, ±0.94%    | 90.66% slower

Finished 4 cases!
  Fastest: ~33 kb split by 1 mb with unicodeAware
  Slowest: ~330 kb split by 2 kb with unicodeAware

Recent optimizations — September 2025

September 2025 improvements were delivered autonomously by the gpt-5-codex model. We treated the hot paths like any latency-sensitive service and tuned the slowest sections:

  • Single-pass unicode chunking – length and slicing now come from the same runes() walk, eliminating the extra string-length scan and keeping multicodepoint graphemes intact.
  • Consolidated ASCII loop – collapsed the fast path into one traversal with early exits for empty inputs and oversized chunk sizes to trim per-call overhead.
  • Fractional-size parity – restored the legacy slice coercion semantics so non-integer chunk sizes behave exactly as before, backed by new regression tests.

The result is steadier throughput in the ASCII suite (for example ~33 kb split by 1 mb climbs from 85.6M to 100.5M ops/s) and a 9–10× lift in the unicode-aware scenarios (e.g. 33 kb splits rise from ~101 ops/s to ~964 ops/s) while preserving behaviour for combining marks and emoji ligatures.

See Also

Publish

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

License

MIT © Shelf