Skip to content

Commit

Permalink
Update README example
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Oct 19, 2023
1 parent ff92ece commit 2e7db3e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
- [swap-case](https://github.com/blakeembrey/change-case/tree/master/packages/swap-case)
- [title-case](https://github.com/blakeembrey/change-case/tree/master/packages/title-case)

### TypeScript and ESM

All packages are [pure ESM packages](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) and ship with TypeScript definitions. They cannot be `require`'d or used with legacy `node` module resolution in TypeScript.

## Related

- [Meteor](https://github.com/Konecty/change-case)
Expand Down
18 changes: 11 additions & 7 deletions packages/change-case/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ npm install change-case --save

## Usage

These case change functions are included:
```js
import * as changeCase from "change-case";

changeCase.camelCase("TEST_VALUE"); //=> "testValue"
```

Included case functions:

| Method | Result |
| ----------------- | ----------- |
Expand All @@ -27,17 +33,15 @@ These case change functions are included:
| `snakeCase` | `two_words` |
| `trainCase` | `Two-Words` |

All core methods accept [`options`](#options) as the second argument.

### Options
All methods accept an `options` object as the second argument:

- `locale?: string[] | string | false` Lower/upper according to specified locale, defaults to host environment. Set to `false` to disable.
- `separateNumbers?: boolean` Splits `foo123` into `foo 123` instead of keeping them together. Defaults to `true`.
- `prefixCharacters?: string` Retain at the beginning of the string. Defaults to `""`. Example: use `"_"` to keep the underscores in `__typename`.

### Split

**Change case** also exports a `split` function which can be used to build your own case formatting methods. It accepts a string and returns each "word" as an array. For example:
**Change case** exports a `split` utility which can be used to build other case functions. It accepts a string and returns each "word" as an array. For example:

```js
split("fooBar")
Expand All @@ -53,11 +57,11 @@ import * as changeKeys from "change-case/keys";
changeKeys.camelCase({ TEST_KEY: true }); //=> { testKey: true }
```

Keys is a wrapper around all case methods to support transforming objects to any case.
**Change case keys** wraps around the core methods to transform object keys to any case.

### API

- **input: unknown** Any JavaScript value.
- **input: any** Any JavaScript value.
- **depth: number** Specify the depth to transfer for case transformation. Defaults to `1`.
- **options: object** Same as base case library.

Expand Down

0 comments on commit 2e7db3e

Please sign in to comment.