Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including bistring with all npm packages installed. Try it out:

var bistring = require("bistring")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bistring v0.4.0

Bidirectionally transformed strings


npm version

The bistring library provides non-destructive versions of common string processing operations like normalization, case folding, and find/replace. Each bistring remembers the original string, and how its substrings map to substrings of the modified version.

For example:

import BiString from "bistring";

let s = new BiString("𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐, 𝖇𝖗𝖔𝖜𝖓 🦊 𝖏𝖚𝖒𝖕𝖘 𝖔𝖛𝖊𝖗 𝖙𝖍𝖊 𝖑𝖆𝖟𝖞 🐶");
s = s.normalize("NFKD");         // Unicode normalization
s = s.toLowerCase();             // Case-insensitivity
s = s.replace("🦊", "fox");      // Replace emoji with text
s = s.replace("🐶", "dog");
s = s.replace(/[^\w\s]+/g, "");  // Strip everything but letters and spaces
s = s.substring(0, 19);          // Extract a substring
console.log(s.modified);         // The modified substring, after changes
// the quick brown fox
// 𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐, 𝖇𝖗𝖔𝖜𝖓 🦊

This allows you to perform very aggressive text processing completely invisibly.


Click here for a live demo of the bistring library in your browser.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free