@garystorey/slugify
v1.0.3
Published
A small utility to remove/replace whitepace from a string
Downloads
166
Maintainers
Readme
slugify
A small dependency-free utility to remove whitespace from a string.
Installation
You can install either with npm
or yarn
:
npm install @garystorey/slugify
yarn add @garystorey/slugify
Parameters
| Parameter Type | Required | Description --------|----------|--- | string| Yes| The string to strip whitespace | string| No | Replacement character
Usage
slugify
has one required string
parameter.
import slugify from '@garystorey/slugify';
const slug = slugify('My Title');
console.log(slug);
// "mytitle"
Optionally, a replacement character can be provided as a second argument:
import slugify from '@garystorey/slugify';
const slug = slugify('My Title','_');
console.log(slug);
// "my_title"
slugify
is written in TypeScript.