1.0.1 • Published 2 years ago

@smitpatelx/string-utils v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

String Utils

  • A string utility library
  • Small size
    • Stat size: 2.33 KB
    • Parsed size: 1.03 KB
    • Gzipped size: 515 B
  • Simple

VERSION MONTHLY_DOWNLOADS NPM

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
000

Left

left('111 222 333 444 000', 3)

// Output
111

Camelize

camelize('data_rate')
camelize('-git-xyz')

// Output
dataRate
GitXyz

Capitalize

capitalize('data')
capitalize('aPPLE')

// Output
Data
Apple

RemoveWhiteSpace

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
&lt;div&gt;stringUtils&lt;/div&gt;

isEmpty

isEmpty('')
isEmpty('hi')

// Output
true
false

slugify

slugify('Save earth')
slugify('Crème brûlée')

// Output
save-earth
creme-brulee
1.0.1

2 years ago

1.0.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago