easy-object-conv
TypeScript icon, indicating that this package has built-in type declarations

1.2.1Β β€’Β PublicΒ β€’Β Published

βš™οΈ Easy Object Keys Converter

Use to convert objects keys in πŸͺ camel case to 🐍 snake case or underscore and in the same way as snake case to camel case.

Installation

npm

  npm i easy-object-conv

yarn

  yarn add easy-object-conv

πŸ’» Usage

Camel Case to Snake Case (underscore)

  import { camelToSnake } from "easy-object-conv"
  ...
  camelToSnake(object)
  ...

Input

  {
    id: 1,
    fieldOne: Bruno,
    fieldTwo: {
      fieldThree: Hello,
      fieldFour: World
    }
  }

Output

  {
    id: 1,
    field_one: Bruno,
    field_two: {
      field_three: Hello,
      field_four: World
    }
  }

Snake Case (underscore) to Camel Case

  import { snakeToCamel } from "easy-object-conv"
  ...
  snakeToCamel(object)
  ...

Input

  {
    id: 1,
    field_one: Bruno,
    field_two: {
      field_three: Hello,
      field_four: World
    }
  }

Output

  {
    id: 1,
    fieldOne: Bruno,
    fieldTwo: {
      fieldThree: Hello,
      fieldFour: World
    }
  }

Thank You for Use! πŸ§‘πŸ»β€πŸ’»

Package Sidebar

Install

npm i easy-object-conv

Weekly Downloads

55

Version

1.2.1

License

MIT

Unpacked Size

5.81 kB

Total Files

11

Last publish

Collaborators

  • dotbruno