Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

easy-object-conv

dotbruu96MIT1.2.1TypeScript support: included

Use to convert objects keys in 🐪 camel case to 🐍 snake case or underscore and in the same way as snake case to camel case.

snake, camel, case, underscore, object, convert, snake-case, camel-case, underscore-case, convert-object-snake-case-to-camel-case, convert-object-camel-case-to-snake-case

readme

⚙️ 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! 🧑🏻‍💻