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

sluglife

v1.0.1

Published

Slugifies strings.

Downloads

13,108

Readme

npm npm NPM Conventional Commits

sluglife (■_■¬)

slugifies string. Handles, unicode, multi-language characters, currency symbols, and more!

Make strings url-safe.

  • respecting RFC 3986
  • Comprehensive tests
  • Coerces foreign symbols to their english equivalent
npm install sluglife

Examples

var slug = require('sluglife')

slug('i ♥ unicode') === 'i-love-unicode';

slug('unicode ♥ is ☢') === 'unicode-love-is-radioactive';

slug('i ♥ unicode', {'replacement': '_'}) === 'i_love_unicode';

slug('I ♥ UNICODE', {'charMap': {'♥': 'freaking love'}}) === 'I-freaking-love-UNICODE';

slug('☏-Number', {lower: true}) === 'telephone-number';

slug('i <3 unicode') === 'i-love-unicode';

Options

slug('string', {
  replacement: '-',               // space separator replacement character
  replaceSymbols: true,           // replace unicode symbols or not
  remove: null,                   // regex to remove characters that match (see 'pretty' definition)
  lower: true,                    // lower case all letters in slug
  charmap: slug.charmap,          // replace special characters
  multicharmap: slug.multicharmap // replace multi-characters
});

Defaults

There are two default setting groups. The default mode is 'pretty'

slug('Hello There World.', {'mode': 'rfc3986'}) === 'hello-there-world.';
slug('Hello There World.', {'mode': 'pretty'}) === 'Hello-There-World';

The default setting groups are defined below.

slug.defaults.modes['rfc3986'] = {
  replacement: '-',
  replaceSymbols: true,
  remove: null,
  lower: true,
  charmap: slug.charmap,
  multicharmap: slug.multicharmap
};
 
slug.defaults.modes['pretty'] = {
  replacement: '-',
  replaceSymbols: true,
  remove: /[.]/g,
  lower: false,
  charmap: slug.charmap,
  multicharmap: slug.multicharmap
};