1.0.1 • Published 4 years ago
@smitpatelx/string-utils v1.0.1
String Utils
- A string utility library
- Small size
- Stat size: 2.33 KB
- Parsed size: 1.03 KB
- Gzipped size: 515 B
- Simple
Contribution
This is an open-source project, feel free to contribute to this awesome project.
Best way to do this:
1. Fork the project
2. Create a branch <current_version>-<github_username>-<keyword>. Example: 1.0.0-smitpatelx-changesToIsEmpty
3. Make a pull request
4. Make sure not to change version in package.json (That will be done in next release)
Installation
- NPM
npm i @smitpatelx/string-utils- Yarn
yarn add @smitpatelx/string-utils- CDN
<script src="https://cdn.jsdelivr.net/npm/@smitpatelx/string-utils@latest/src/lib/string-utils.js"></script>Use
import {
left,
right,
camelize,
capitalize,
removeWhiteSpace,
escapeHtml,
isEmpty,
slugify
} from '@smitpatelx/string-utils';Examples
Right
right('111 222 333 444 000', 3)
// Output
000Left
left('111 222 333 444 000', 3)
// Output
111Camelize
camelize('data_rate')
camelize('-git-xyz')
// Output
dataRate
GitXyzCapitalize
capitalize('data')
capitalize('aPPLE')
// Output
Data
AppleRemoveWhiteSpace
removeWhiteSpace('111\n222\t333\n444\n\t000')
removeWhiteSpace(' This \t is awesome \n\n\t library\n! ')
// Output
111 222 333 444 000
This is awesome library !EscapeHtml
escapeHtml('<div>stringUtils</div>')
// Output
<div>stringUtils</div>isEmpty
isEmpty('')
isEmpty('hi')
// Output
true
falseslugify
slugify('Save earth')
slugify('Crème brûlée')
// Output
save-earth
creme-brulee