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

postkit-tag

v1.0.0

Published

Take raw text input and turns it into clean, consistent tags for PostKit posts

Readme

Package Name: postkit-tag-utility

Purpose

This library takes raw text input and turns it into clean, consistent tags by handling all the parsing, normalizing, deduplication, and validation of data automatically.

Exports

parseTags

Description: Split raw input into usable tags.

Input:

  • text — a text string

Output:

  • An array of tag strings

Example:

parseTags("javascript, web dev, coding");
// => ["javascript", "web dev", "coding"]

Edge Cases

parseTags("  ");
// => []

parseTags("can't,won't");
// => ["cant", "wont"]

parseTags("coding,,typescript");
// => ["coding", "typescript"]

parseTags(",coding, typescript,");
// => ["coding", "typescript"]

parseTags("***");
// => []

parseTags("javascript, ***, coding");
// => ["javascript", "coding"]

parseTags("javascript, jffffffffffffffffffffffavascript")
// => ["javascript"]

normalizeTag

Description: Standardize case, whitespace, and special characters

Input:

  • tagStr — a tag string

Output:

  • A cleaned tag string

Example:

normalizeTag("  JavaScript  ");
// => "javascript"

Edge Cases

normalizeTag("can't");
// => "cant"

normalizeTag("***");
// => ""

normalizeTag("lot    of   space");
// => "lot of space"

normalizeTag("HELLO");
// => "hello"

normalizeTag("hello");
// => "hello"

removeDuplicateTags

Description: Keep tags unique while preserving usable order.

Input:

  • tagArr — an array of tag strings

Output:

  • An array of unique tag strings

Example:

removeDuplicateTags(["javascript", "coding", "javascript"]);
// => ["javascript", "coding"]

Edge Cases

removeDuplicateTags(["javascript", "coding"]);
// => ["javascript", "coding"]

removeDuplicateTags(["javascript"]);
// => ["javascript"]

removeDuplicateTags();
// => []

removeDuplicateTags(["JavaScript", "javascript"]);
// => ["javascript"]

removeDuplicateTags(["javascript", "javascript "]);
// => ["javascript"]

removeDuplicateTags(["javascript javascript javascript javascript"]);
// => []

isValidTag

Description: Return whether a tag follows your package rules.

Input:

  • tagStr — a tag string

Output:

  • A boolean

Example:

isValidTag("javascript");
// => true

isValidTag("");
// => false

Edge Cases

isValidTag("this is tag");
// => true

isValidTag("this is,tag");
// => true

isValidTag("THIS IS TAG");
// => true

isValidTag("");
// => false

isValidTag("   ");
// => false

isValidTag("my tag!!");
// => true

isValidTag("  tag ");
// => true

isValidTag("123");
// => true

isValidTag("this is a very long tag that exceeds the limit");
// => false

isValidTag("a");
// => true

Design Notes

Strict type handling — every function defensively handles non-string inputs like numbers, null, and undefined, returning a safe default like [], "", or false instead of crashing.

Comma as the standard delimiter — parseTags uses commas to split input and is the only function that handles commas. By the time a tag reaches any other function, commas should already be gone.

Lowercase as the standard — all functions normalize to lowercase internally before doing their work, so input like "THIS IS TAG" is treated the same as "this is tag" across the entire library.

Whitespace is collapsed but spaces are allowed — tags can contain spaces like "web dev", but extra whitespace gets collapsed to a single space and trimmed, striking a balance between flexibility and cleanliness.

Deduplication is case and whitespace aware — removeDuplicateTags normalizes each tag internally before comparing, so "JavaScript" and "javascript" and "javascript " are all treated as duplicates.

Special characters including commas are always stripped — all functions remove special characters internally before doing their work, so input like "can't" becomes "cant" and "***" becomes "" consistently across the library.

parseTags is the only entry point for raw user input — normalizeTag expects an already-split tag and should never receive raw user input directly. Commas are handled exclusively by parseTags as a splitting character, so by the time a tag reaches normalizeTag, commas should already be gone.

Tags have a 20 character limit — isValidTag returns false for any tag exceeding 20 characters after normalization.

removeDuplicateTags and parseTags uphold tag rules - In addition to normalizing the tags, these functions uphold the character requirements of tags by calling isValidTag internally. Normalized tags that don't have any length or are over 20 characters are removed from the returned string arrays.