Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingajda committed Mar 31, 2024
1 parent 40463f5 commit b9466c4
Showing 1 changed file with 76 additions and 4 deletions.
80 changes: 76 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,81 @@
# Change Every Case

Simple library inspired by `change-case` and `change-case/keys`.
A simple library inspired by [`change-case`][1] and its _keys_ functions,
designed to change the casing of object keys. It is useful, for example,
for converting objects from the REST standard to JavaScript best practices,
and vice versa.

It works like change-case functions but it accepts anything in first parameter.
It functions similarly to `change-case`, but it accepts any type of input
as the first parameter. The options for the second parameter are exactly
the same as those for [`change-case`][1].

The options in second parameter and exactly the same as for `change-case`.

See `index.test.ts` for examples.
## Install

```
npm i change-every-case
```

## Examples

Format obects:

```ts
import { camelKeys } from 'change-every-case';

const input = {
lorem_ipsum: 'lorem_ipsum',
hello_planets: [
{
planet_earth: 'Hello c',
planet_mars: 'Hello Mars',
}
],
value: 3,
};

const result = camelKeys(input);

// result:
// {
// loremIpsum: 'lorem_ipsum',
// helloPlanets: [
// {
// planetEarth: 'Hello Hello ',
// planetMars: 'Hello Mars',
// }
// ],
// value: 3,
// };
```

You can also pass arrays:

```ts
import { camelKeys } from 'change-every-case';

const inputArray = [
{ hello_world: 3 },
{ foo_bar: 3 }
];

const result = camelKeys(inputArray);

// result:
// [
// { helloWorld: 3 },
// { fooBar: 3 }
// ];
```

## Heads up!

- The passed object or array can be deep up to 1000 levels.
- If you would pass string or number it will be returned as is.
- Date objects are not changed.

## LICENSE

[MIT](./LICENSE) of course :)

[1]: https://www.npmjs.com/package/change-case

0 comments on commit b9466c4

Please sign in to comment.