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 🙏

© 2024 – Pkg Stats / Ryan Hefner

zero-width-lib

v1.1.0

Published

A lib for zero width character utils

Downloads

22

Readme

zero-width-lib

Travis (.org) npm npm

What's zero-width-lib

Zero-width-lib is a library for manipulating zero width characters (ZWC), which are non-printing and invisible chars.

The common usage of ZWC includes fingerprinting confidential text, embedding hidden text and escaping from string matching (i.e. regex)...

The lib is inspired by this great medium article and got the following features:

  1. 💯stable & cover full test cases
  2. 😆support full width Unicode chars
  3. ⚡️dependencies & performance considered
  4. 📦support CJS, ESM and UMD

Install

npm install zero-width-lib

Usage

Besides ESM, CJS and UMD ways of importing are also supported

// import one method at a time
import { encode } from 'zero-width-lib';
// or import all methods from lib
import * as z from 'zero-width-lib';
// note * represents the invisible ZWC
// U+ represents the Unicode for the character

// 0. six different zwc
const dict = z.zeroWidthDict;
console.log(dict.zeroWidthSpace); // '*' U+200B
console.log(dict.zeroWidthNonJoiner); // '*' U+200C
console.log(dict.zeroWidthJoiner); // '*' U+200D
console.log(dict.leftToRightMark); // '*' U+200E
console.log(dict.rightToLeftMark); // '*' U+200F
console.log(dict.zeroWidthNoBreakSpace); // '*' U+FEFF

// 1. convert text
const text = 'text';
const zwc = z.t2z(text); // '********'
const back = z.z2t(zwc); // 'text'

// 2. embed hidden text
const visble = 'hello world';
const hidden = 'inspired by @umpox';
const encoded = z.encode(visible, hidden); // 'h*********ello world'
const decoded = z.decode(encoded); // 'inpired by @umpox'

// 3. extract ZWC from text
const extracted = z.extract(encoded);
const vis = extracted.vis; // 'hello world'
const hid = extracted.hid; // '*********'

// 4. escape from string matching
const forbidden = 'forbidden';
const escaped = z.split(forbidden); // 'f*o*r*b*i*d*d*e*n*' 

License

MIT