cleansify
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Cleansify


  • 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

Installation

$ npm i cleansify

Usage

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).

Contributing

Keep it simple. Keep it minimal. Don't put every single feature just because you can.

Authors

  • Travis Knight

License

This project is licensed under the MIT License

Package Sidebar

Install

npm i cleansify

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

7.37 kB

Total Files

9

Last publish

Collaborators

  • travisknight