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

sweatmap

v0.3.7

Published

SweatMap takes in a series of UTF-8 strings and maps them to UTF-8 strings that are as small as possible while still being unique.

Downloads

10

Readme

SweatMap

npm version Build Status

Take in a series of UTF-8 strings and map them to UTF-8 strings that are as small as possible while still being unique.

Why?

The motivation behind SweatMap was to take semantic CSS Identifiers (e.g. for selectors) and make them as small as possible at build time. With new tools that can take advantage of CSS Modules all we needed was something to map our current class names to something smaller.

Installation

npm install sweatmap --save

How to use

SweatMap uses a few ES6 features that may not be present in your Node/Browser depending on the version. These include: Array.fill, Object.assign, Object.freeze, and Object.keys

  • Constructor(obj):

    Takes in an object with up to three optional properties:

    • cssSafe [default false]: true disallows characters that aren't safe for CSS Identifiers.
    • additional_ranges [object]: An object where the key is a "range name" and the value is an object with a start character point and an end character point. You can set null to either start or end to remove a character range.
    • existing_strings [default {}]: Pass in an object of strings that you don't want changed. Key is the original name, value is the name that should be used.
  • bytes(string): Returns a byte count of the string passed in.

  • size(): Returns number of entries in the map.

  • cssSafeString(string): Determines if the string is a safe CSS Identifier.

  • set(string): Returns an obfuscated UTF-8 string that's unique to all strings in the map.

  • delete(key): Removes the string from the map.

  • clear(): Empties the map.

  • clear(): Empties the map.

  • entries(): Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.

  • get(key): Returns the value for a given key.

  • get_obfuscated(value): Returns the key for a given value.

  • has(key): Returns true/false if a key exists in the map.

  • has_obfuscated(value): Returns true/false if a value exists in the map.