Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.
/ animalcase-js Public archive

A library to convert payloads and response object from camel case to snake case and vice versa.

License

Notifications You must be signed in to change notification settings

gsuntres/animalcase-js

Repository files navigation

Archiving since there are better alternatives out there, like case-anything.

Overview

A library to convert object's keys from came case to snake case and vice versa.

Install

@animalcase-js/core can be used to manually convert keys.

npm i --save @animalcase-js/core

@animalcase-js/express a middleware for express.js

npm i --save @animalcase-js/express

Usage

const caseconvert = require('@animalcase-js/core')

const myObject = {
  propA: 1,
  propB: 2,
  myPropC: 'Hi'
}

caseconvert.convertToSnakeCase(myObject)

console.log(myObject)

should display

{
  prop_a: 1,
  prop_b: 2,
  my_prop_c: 'Hi'
}