Skip to content

Commit 21f19ba

Browse files
authoredSep 29, 2023
docs: improve readme with code examples
1 parent 872fa9d commit 21f19ba

File tree

1 file changed

+42
-25
lines changed

1 file changed

+42
-25
lines changed
 

Diff for: ‎README.md

+42-25
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
[![npm version][npm-version-src]][npm-version-href]
44
[![npm downloads][npm-downloads-src]][npm-downloads-href]
5-
[![Github Actions][github-actions-src]][github-actions-href]
6-
[![Codecov][codecov-src]][codecov-href]
75
[![bundle][bundle-src]][bundle-href]
6+
[![Codecov][codecov-src]][codecov-href]
87

98
<!-- ![](.github/banner.svg) -->
109

@@ -14,8 +13,6 @@ Install using npm or yarn:
1413

1514
```bash
1615
npm i scule
17-
# or
18-
yarn add scule
1916
```
2017

2118
Import:
@@ -28,41 +25,67 @@ const { pascalCase } = require('scule')
2825
import { pascalCase } from 'scule'
2926
```
3027

31-
**Notice:** You may need to transpile package for legacy environments
28+
**Notice:** You may need to transpile package for legacy environments.
3229

3330
## Utils
3431

3532
### `pascalCase(str)`
3633

37-
Splits string and joins by PascalCase convention (`foo-bar` => `FooBar`)
34+
Splits string and joins by PascalCase convention:
3835

39-
**Remarks:**
36+
```ts
37+
pascalCase('foo-bar_baz')
38+
// FooBarBaz
39+
```
4040

41-
- If an uppercase letter is followed by other uppercase letters (like `FooBAR`), they are preserved
41+
**Notice:** If an uppercase letter is followed by other uppercase letters (like `FooBAR`), they are preserved.
4242

4343
### `camelCase`
4444

45-
Splits string and joins by camelCase convention (`foo-bar` => `fooBar`)
45+
Splits string and joins by camelCase convention:
46+
47+
```ts
48+
camelCase('foo-bar_baz')
49+
// fooBarBaz
50+
```
4651

4752
### `kebabCase(str)`
4853

49-
Splits string and joins by kebab-case convention (`fooBar` => `foo-bar`)
54+
Splits string and joins by kebab-case convention:
5055

51-
**Remarks:**
56+
```ts
57+
kebabCase('fooBar_Baz')
58+
// foo-bar-baz
59+
```
5260

53-
- It does **not** preserve case
61+
**Notice:** It does **not** preserve case.
5462

5563
### `snakeCase`
5664

57-
Splits string and joins by snake_case convention (`foo-bar` => `foo_bar`)
65+
Splits string and joins by snake_case convention:
66+
67+
```ts
68+
snakeCase('foo-barBaz')
69+
// foo_bar_baz
70+
```
5871

5972
### `upperFirst(str)`
6073

61-
Converts first character to upper case
74+
Converts first character to upper case:
75+
76+
```ts
77+
upperFirst('hello world!')
78+
// Hello world!
79+
```
6280

6381
### `lowerFirst(str)`
6482

65-
Converts first character to lower case
83+
Converts first character to lower case:
84+
85+
```ts
86+
lowerFirst('Hello world!')
87+
// hello world!
88+
```
6689

6790
### `splitByCase(str, splitters?)`
6891

@@ -85,17 +108,11 @@ Converts first character to lower case
85108
[MIT](./LICENSE)
86109

87110
<!-- Badges -->
88-
[npm-version-src]: https://img.shields.io/npm/v/scule?style=flat-square
111+
[npm-version-src]: https://img.shields.io/npm/v/scule?style=flat&colorA=18181B&colorB=F0DB4F
89112
[npm-version-href]: https://npmjs.com/package/scule
90-
91-
[npm-downloads-src]: https://img.shields.io/npm/dm/scule?style=flat-square
113+
[npm-downloads-src]: https://img.shields.io/npm/dm/scule?style=flat&colorA=18181B&colorB=F0DB4F
92114
[npm-downloads-href]: https://npmjs.com/package/scule
93-
94-
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/scule/ci/main?style=flat-square
95-
[github-actions-href]: https://github.com/unjs/scule/actions?query=workflow%3Aci
96-
97-
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/scule/main?style=flat-square
115+
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/scule/main?style=flat&colorA=18181B&colorB=F0DB4F
98116
[codecov-href]: https://codecov.io/gh/unjs/scule
99-
100-
[bundle-src]: https://img.shields.io/bundlephobia/minzip/scule?style=flat-square
117+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/scule?style=flat&colorA=18181B&colorB=F0DB4F
101118
[bundle-href]: https://bundlephobia.com/result?p=scule

0 commit comments

Comments
 (0)
Please sign in to comment.