1.0.0 • Published 2 years ago

cleansify v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago
  • 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-"
OptionDefaultDescription
maxLength100The 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