JSPM

easy-object-conv

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 54
  • Score
    100M100P100Q65603F
  • License MIT

Package Exports

  • easy-object-conv
  • easy-object-conv/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (easy-object-conv) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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 { camelCaseToSnakeCase } from "easy-object-conv"
  ...
  camelCaseToSnakeCase(object)
  ...

Input

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

Output

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

Snake Case (underscore) to Camel Case

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

Input

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

Output

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

Thank You for Use! 🧑🏻‍💻