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

node-masker

v1.1.0

Published

node-masker is a javascript mask library made in TypeScript

Readme

Suport

| Technology | Status | | :-------------------- | :-----------------------: | | Node | Done ✅ | | React | Done ✅ |

Getting Started

Welcome to the Node Masker documentation!

If you are new to using Node Masker, we recommend that you start testing all our features.

If you have questions about anything related to the Node Masker feel free to ask our community in the GitHub discussions.

System Requirements

Setup

Now just install Node Masker and start using: D

npm install node-masker
# or
yarn add node-masker

Usage

Examples

import { mask } from 'node-masker'

const value = 'ABC1C83'
const pattern = 'AAA - 9S99'

mask(value, pattern)
// ABC - 1C83

Pattern can be a pattern array, so remask choose one pattern based on pattern/value length match

const patterns = ['999.999.999-99', '99.999.999/9999-99']

mask('12345678901', patterns) // gets firts pattern (999.999.999-99)
// 123.456.789-01

mask('12345678000106', patterns) // gets second pattern (99.999.999/9999-99)
// 12.345.678/0001-06

More Examples

import { mask } from 'node-masker'

// Converts value to masked phone
mask(1099911111, "(99) 9999-9999"); // -> (10) 9991-1111

// Converts value to masked date
mask(12122000, "99/99/9999"); // -> 12/12/2000

// Converts value to masked document
mask(99911111101, "999.999.999-99"); // -> 999.111.111-01

// Converts value to masked car plate
mask('ABC1234', "AAA-9999"); // -> ABC-1234

// Converts value to masked vehicle identification
mask('9BGRD08X04G117974', "SS.SS.SSSSS.S.S.SSSSSS"); // -> 9B.GR.D08X0.4.G.117974

/* Pass in an optional placeholder option to represent remaining
characters to be entered */
mask('4', {pattern: "(999) 999-9999", placeholder: "x"}); // -> (4xx) xxx-xxxx

Usage Mask Details

mask

Mask format. Can be either a string or array of characters and regular expressions.

mask('130499', "99/99/99")

Simple masks can be defined as strings. The following characters will define mask format:

| Character | Allowed input | | :-------: | :-----------: | | 9 | 0-9 | | a | a-z, A-Z | | * | 0-9, a-z, A-Z |

Any format character can be escaped with a backslash.

More complex masks can be defined as an array of regular expressions and constant characters.

// Canadian postal code mask
const firstLetter = /(?!.*[DFIOQU])[A-VXY]/i;
const letter = /(?!.*[DFIOQU])[A-Z]/i;
const digit = /[0-9]/;
const mask = [firstLetter, digit, letter, " ", digit, letter, digit];

Using React

To use the Node Mask on an input element in React, you need an InputWrapper

import React, { useState } from "react";
import { mask as masker, unMask } from "node-masker";

function App() {
  const [value, setValue] = useState("");
  const masks =  ["99/99/9999", "(999) 999-9999"]

  return (
    <input
      onChange={({ target }) => setValue(unMask(target.value))}
      value={masker(value, masks)}
    />
  );
}

export default App;

Finished example of how to use the powerful Node Masker

License

MIT © Marcelo dos Reis