1.0.0 • Published 4 years ago
cleansify v1.0.0
- 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 cleansifyconst { 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
1.0.0
4 years ago