Skip to content

Commit

Permalink
docs: improve readme with code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored Sep 29, 2023
1 parent 872fa9d commit 21f19ba
Showing 1 changed file with 42 additions and 25 deletions.
67 changes: 42 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions][github-actions-src]][github-actions-href]
[![Codecov][codecov-src]][codecov-href]
[![bundle][bundle-src]][bundle-href]
[![Codecov][codecov-src]][codecov-href]

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

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

```bash
npm i scule
# or
yarn add scule
```

Import:
Expand All @@ -28,41 +25,67 @@ const { pascalCase } = require('scule')
import { pascalCase } from 'scule'
```

**Notice:** You may need to transpile package for legacy environments
**Notice:** You may need to transpile package for legacy environments.

## Utils

### `pascalCase(str)`

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

**Remarks:**
```ts
pascalCase('foo-bar_baz')
// FooBarBaz
```

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

### `camelCase`

Splits string and joins by camelCase convention (`foo-bar` => `fooBar`)
Splits string and joins by camelCase convention:

```ts
camelCase('foo-bar_baz')
// fooBarBaz
```

### `kebabCase(str)`

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

**Remarks:**
```ts
kebabCase('fooBar_Baz')
// foo-bar-baz
```

- It does **not** preserve case
**Notice:** It does **not** preserve case.

### `snakeCase`

Splits string and joins by snake_case convention (`foo-bar` => `foo_bar`)
Splits string and joins by snake_case convention:

```ts
snakeCase('foo-barBaz')
// foo_bar_baz
```

### `upperFirst(str)`

Converts first character to upper case
Converts first character to upper case:

```ts
upperFirst('hello world!')
// Hello world!
```

### `lowerFirst(str)`

Converts first character to lower case
Converts first character to lower case:

```ts
lowerFirst('Hello world!')
// hello world!
```

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

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

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/scule?style=flat-square
[npm-version-src]: https://img.shields.io/npm/v/scule?style=flat&colorA=18181B&colorB=F0DB4F
[npm-version-href]: https://npmjs.com/package/scule

[npm-downloads-src]: https://img.shields.io/npm/dm/scule?style=flat-square
[npm-downloads-src]: https://img.shields.io/npm/dm/scule?style=flat&colorA=18181B&colorB=F0DB4F
[npm-downloads-href]: https://npmjs.com/package/scule

[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/scule/ci/main?style=flat-square
[github-actions-href]: https://github.com/unjs/scule/actions?query=workflow%3Aci

[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/scule/main?style=flat-square
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/scule/main?style=flat&colorA=18181B&colorB=F0DB4F
[codecov-href]: https://codecov.io/gh/unjs/scule

[bundle-src]: https://img.shields.io/bundlephobia/minzip/scule?style=flat-square
[bundle-src]: https://img.shields.io/bundlephobia/minzip/scule?style=flat&colorA=18181B&colorB=F0DB4F
[bundle-href]: https://bundlephobia.com/result?p=scule

0 comments on commit 21f19ba

Please sign in to comment.