https://github.com/loopmode/utils-str
String utils in javascript
https://github.com/loopmode/utils-str
Last synced: 6 months ago
JSON representation
String utils in javascript
- Host: GitHub
- URL: https://github.com/loopmode/utils-str
- Owner: loopmode
- Created: 2018-05-29T16:17:17.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-03T13:45:11.000Z (almost 8 years ago)
- Last Synced: 2025-09-01T04:09:55.148Z (7 months ago)
- Language: JavaScript
- Size: 146 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# @loopmode/utils-str
A set of javascript string utilities.
## Installation
```
yarn add @loopmode/utils-str
```
## Usage
```javascript
import Str from '@loopmode/utils-str';
console.log(Str.ucFirst('foo')); // 'Foo'
console.log(Str.lcFirst('Foo')); // 'foo'
console.log(Str.normalizePath('foo/')); // '/foo'
console.log(Str.joinPath('foo/', '/bar', 'baz')); // '/foo/bar/baz'
console.log(Str.removeTrailingSlash('foo/')); // 'foo'
console.log(Str.removeLeadingSlash('/foo')); // 'foo'
console.log(Str.forceTrailingSlash('foo')); // 'foo/'
console.log(Str.forceLeadingSlash('foo')); // '/foo'
console.log(Str.endsWith('foo', 'o')); // true
console.log(Str.startsWith('foo', 'f')); // true
console.log(Str.leftPad(7, 3)); // '007'
```
## Docs
Check [https://loopmode.github.io/utils-str](https://loopmode.github.io/utils-str) or the `/docs` folder