@cvpcasada/slugify

sindresorhus' slugify packaged for the browser

Stats

StarsIssuesVersionUpdatedCreatedSize
@cvpcasada/slugify
000.3.33 years ago3 years agoMinified + gzip package size for @cvpcasada/slugify in KB

Readme

This is a fork. you might want the original one from Sindresorhus. check that out. This only transpiles it to be compatible to older browsers.

slugify Build Status

Slugify a string

Useful for URLs, filenames, and IDs.

Install

$ npm install @sindresorhus/slugify

Usage

const slugify = require('@sindresorhus/slugify');

slugify('I ♥ Dogs');
//=> 'i-love-dogs'

slugify('  Déjà Vu!  ');
//=> 'deja-vu'

slugify('fooBar 123 $#%');
//=> 'foo-bar-123'

slugify('BAR and baz', {separator: '_'});
//=> 'bar_and_baz'

slugify('I ♥ 🦄 & 🐶', {
  customReplacements: [
    ['🐶', 'dog']
  ]
});
//=> 'i-love-unicorn-and-dog'

API

slugify(input, [options])

input

Type: string

options

Type: Object

separator

Type: string
Default: -

customReplacements

Type: Array
Default: [ ['&', 'and'], ['🦄', 'unicorn'], ['♥', 'love'] ]

Specifying this only replaces the default if you set an item with the same key, like &.

Related

License

MIT © Sindre Sorhus

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.