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

fast-replace-diacritics

v1.0.1

Published

2-5x faster diacritics replacement compared to traditional 'str.replace'

Readme

fast-replace-diacritics

Version CI

2-5x faster diacritics replacement compared to traditional 'str.replace'

Uses code points and direct string manipulation. Intended for use in search-like scenario.

No dependencies.

Traditional 'str.replace'?

str.replace(/[^\u0000-\u007e]/g, (c) => {
    return DIACRITICS_MAP.get(c) || c;
});

[!IMPORTANT] The traditional method will bridge the gap performance-wise, when the input string contains long stretches of ASCII.

Usage

npm i fast-replace-diacritics
import { replaceDiacritics } from "fast-replace-diacritics";

const sanitized = replaceDiacritics("Iлtèrnåtïonɑlíƶatï߀ԉ"); // "Internationalizati0n"

You can also download dist/index.js from NPM to use directly:

https://www.npmjs.com/package/fast-replace-diacritics?activeTab=code

Benchmarks (vitest on GH action runner)

index.bench.ts

[!TIP] Click on the CI badge at the top of the readme to see the latest runs.

✓ test/index.bench.ts > Reference 21193ms
name                             hz     min     max    mean     p75     p99    p995    p999     rme   samples
· replaceDiacritics      3,132,848.74  0.0003  3.4313  0.0003  0.0003  0.0004  0.0006  0.0009  ±0.17%  15664244
· tradReplaceDiacritics    825,294.48  0.0011  0.4770  0.0012  0.0012  0.0022  0.0023  0.0103  ±0.06%   4126474

✓ test/index.bench.ts > Simple single-char 40549ms
name                             hz     min     max    mean     p75     p99    p995    p999     rme   samples
· replaceDiacritics      9,426,427.37  0.0001  0.1798  0.0001  0.0001  0.0001  0.0002  0.0002  ±0.05%  47132137
· tradReplaceDiacritics  3,357,032.68  0.0003  0.3967  0.0003  0.0003  0.0003  0.0005  0.0008  ±0.08%  16785164

✓ test/index.bench.ts > Simple dual-char 37012ms
name                             hz     min     max    mean     p75     p99    p995    p999     rme   samples
· replaceDiacritics      8,667,886.46  0.0001  0.7378  0.0001  0.0001  0.0001  0.0002  0.0002  ±0.04%  43339473
· tradReplaceDiacritics  3,000,826.24  0.0003  0.4585  0.0003  0.0003  0.0004  0.0005  0.0009  ±0.06%  15004132

✓ test/index.bench.ts > 1-char string 55942ms
name                              hz     min     max    mean     p75     p99    p995    p999     rme   samples
· replaceDiacritics      13,195,729.10  0.0001  0.1602  0.0001  0.0001  0.0001  0.0001  0.0001  ±0.03%  65978646
· tradReplaceDiacritics   7,335,602.75  0.0001  1.0018  0.0001  0.0001  0.0002  0.0002  0.0004  ±0.15%  36678014

✓ test/index.bench.ts > No replacement 45973ms
name                             hz     min     max    mean     p75     p99    p995    p999     rme   samples
· replaceDiacritics      9,102,157.51  0.0001  0.0845  0.0001  0.0001  0.0001  0.0001  0.0002  ±0.03%  45510788
· tradReplaceDiacritics  7,207,826.72  0.0001  0.4877  0.0001  0.0001  0.0002  0.0002  0.0004  ±0.10%  36039134

BENCH  Summary

replaceDiacritics - test/index.bench.ts > Reference
3.80x faster than tradReplaceDiacritics

replaceDiacritics - test/index.bench.ts > Simple single-char
2.81x faster than tradReplaceDiacritics

replaceDiacritics - test/index.bench.ts > Simple dual-char
2.89x faster than tradReplaceDiacritics

replaceDiacritics - test/index.bench.ts > 1-char string
1.80x faster than tradReplaceDiacritics

replaceDiacritics - test/index.bench.ts > No replacement
1.26x faster than tradReplaceDiacritics