@travelperksl/case-converter

transform object to use different case conventions

Usage no npm install needed!

<script type="module">
  import travelperkslCaseConverter from 'https://cdn.skypack.dev/@travelperksl/case-converter';
</script>

README

case-converter npm version Build Status codecov semantic-release

A lightweight library that converts objects to different case conventions. Great for consuming APIs of services with different conventions, e.g. Python or Ruby.

Demo

Features

  • toCamelCase
  • toSnakeCase
  • toKebabCase
  • toPascalCase

Install

npm install @travelperksl/case-converter

Example:

  import { toCamelCase } from '@travelperksl/case-converter'

  const snakeCase = {
    an_object: {
      'kebab-case': 'nested content',
      nested_array: [{ an_object: 'something' }]
    },
    an_array: [
      { zero_index: 0 },
      { one_index: 1 }
    ]
  }

  const camelCase = toCamelCase(snakeCase);

  console.log(camelCase)
  /*
    {
      anObject: {
        kebabCase: 'nested content',
        nestedArray: [{ anObject: 'something' }]
      },
      anArray: [
        { zeroIndex: 0 },
        { oneIndex: 1 }
      ]
    }
  */