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

@doist/piiranha

v3.5.8

Published

Remove personally identifiable information from text.

Readme

piiranha

NPM Package

Remove personally identifiable information from text.

This package is published on npm as @doist/piiranha and is maintained as a fork of the original solvvy/redact-pii package.

Prerequisites

This library is primarily written for Node.js, but also works in the browser with compatible tooling/runtime (such as Vite, Webpack, Rollup, Parcel, esbuild). A transpiler/build setup such as TypeScript compiler, Babel, or both, can be used to target older browser support. It is written in TypeScript and currently compiles to ES2016. The project is tested in CI on Node.js 18.x and 20.x.

Simple example (synchronous API)

npm install @doist/piiranha
import { SyncRedactor } from 'piiranha';
const redactor = new SyncRedactor();
const redactedText = redactor.redact('Hi David Johnson, Please give me a call at 555-555-5555');
// Hi NAME, Please give me a call at PHONE_NUMBER
console.log(redactedText);

CommonJS equivalent:

const { SyncRedactor } = require('piiranha');
const redactor = new SyncRedactor();
const redactedText = redactor.redact('Hi David Johnson, Please give me a call at 555-555-5555');
// Hi NAME, Please give me a call at PHONE_NUMBER
console.log(redactedText);

Simple example (asynchronous / promise-based API)

import { AsyncRedactor } from 'piiranha';
const redactor = new AsyncRedactor();
redactor.redactAsync('Hi David Johnson, Please give me a call at 555-555-5555').then((redactedText) => {
  // Hi NAME, Please give me a call at PHONE_NUMBER
  console.log(redactedText);
});

Supported Features

  • sync and async API variants
  • ability to customize what to use as replacement value for detected patterns
  • built in regex based redaction rules for:
    • credentials
    • creditCardNumber
    • emailAddress
    • ipAddress
    • names
    • password
    • phoneNumber
    • streetAddress
    • username
    • usSocialSecurityNumber
    • zipcode
    • url
    • digits
  • ability to add custom redaction regex patterns and complete custom redaction functions (both sync and async)

Advanced usage and features

Customize replacement values

import { SyncRedactor } from 'piiranha';

// use a single replacement value for all built-in patterns found.
const redactor = new SyncRedactor({ globalReplaceWith: 'TOP_SECRET' });
redactor.redact('Dear David Johnson, I live at 42 Wallaby Way');
// Dear TOP_SECRET, I live at TOP_SECRET

// use a custom replacement value for a specific built-in pattern
const redactor = new SyncRedactor({
  builtInRedactors: {
    names: {
      replaceWith: 'ANONYMOUS_PERSON',
    },
  },
});

redactor.redact('Dear David Johnson');
// Dear ANONYMOUS_PERSON

Add custom patterns or redaction functions

Note that the order of redaction rules matters, therefore you have to decide whether you want your custom redaction rules to run before or after the built-in ones. Generally it's better to put very specialized patterns or functions before the built-in ones and more broad / general ones after.

import { SyncRedactor } from 'piiranha';

// add a custom regexp pattern
const redactor = new SyncRedactor({
  customRedactors: {
    before: [
      {
        regexpPattern: /\b(cat|dog|cow)s?\b/gi,
        replaceWith: 'ANIMAL',
      },
    ],
  },
});

redactor.redact('I love cats, dogs, and cows');
// I love ANIMAL, ANIMAL, and ANIMAL

// add a synchronous custom redaction function
const redactor = new SyncRedactor({
  customRedactors: {
    before: [
      {
        redact(textToRedact) {
          return textToRedact.includes('TopSecret')
            ? 'THIS_FILE_IS_SO_TOP_SECRET_WE_HAD_TO_REDACT_EVERYTHING'
            : textToRedact;
        },
      },
    ],
  },
});

redactor.redact('This document is classified as TopSecret.');
// THIS_FILE_IS_SO_TOP_SECRET_WE_HAD_TO_REDACT_EVERYTHING

import { AsyncRedactor } from './src/index';

// add an asynchronous custom redaction function
const redactor = new AsyncRedactor({
  customRedactors: {
    before: [
      {
        redactAsync(textToRedact) {
          return myCustomRESTApiServer.redactCustomWords(textToRedact);
        },
      },
    ],
  },
});

Disable specific built-in redaction rules

const redactor = new SyncRedactor({
  builtInRedactors: {
    names: {
      enabled: false,
    },
    emailAddress: {
      enabled: false,
    },
  },
});

Contributing

Enable local git hooks

To block direct local commits to the main branch, run:

npm run setup-hooks

This configures core.hooksPath to use the committed hooks in .githooks/.

Pull Request requirements

Before a PR can be merged to main:

  • Code owner review — A maintainer must approve the PR
  • Passing tests — All automated checks must pass:
    • TypeScript type checking
    • Jest unit tests (Node.js 18.x and 20.x)
    • Prettier code formatting
  • Stale reviews dismissed — If you push new commits after approval, the review is dismissed and must be re-approved

These checks ensure code quality and prevent regressions.

Branch naming convention

For non-main branches, commits are allowed only when branch names match:

<owner>/<type>/<description>

Allowed type values:

  • feat
  • fix
  • chore
  • docs
  • refactor
  • test
  • ci
  • build
  • perf
  • style

Examples:

  • odsamuels/chore/setup-hooks
  • alice/feat/redaction-pipeline

Automation branches are also allowed:

  • dependabot/*
  • renovate/*

Run tests

You can run the tests via npm run test.