cleansify
v1.0.0
Published
Cleansify provides the ability to clean a string by replacing special characters with a different character. It is also possible to create kebab case strings.
Downloads
2
Maintainers
Readme
- Replace special characters within a string with a given character
- Convert a string to kebab case (i.e. "Winter Weather" becomes "winter-weather")
- Set a maximum length for a converted string
$ npm i cleansify
const { cleansify } = require('cleansify');
console.log(cleansify('winter_(weather)')); // prints "winter__weather_"
console.log(cleansify('winter_(weather)', { maxLength: 8 })); // prints "winter__"
console.log(cleansify('winter_(weather)', { replacement: '-' })); // prints "winter--weather-"
console.log(cleansify('winter_(weather)', { replacement: '-', case: 'upper' })); // prints "WINTER--WEATHER-"
Option | Default | Description
--- | --- | ---
maxLength | 100
| The maximum length of the returned clean string
replacement | "null"
| The value to replace the special characters with. Special
case | "default"
| The case of the string returned (i.e. Uppercase, Lowercase). Allowed values: "lower"
, "upper"
, "kebab"
, "default"
. "default"
will return the string as is without changing its case. "kebab"
will replace special characters and spaces with a "-"
(this will ignore "replacement"
configuration).
This project is licensed under the MIT License