oh-my-case

1.0.5 • Public • Published

Oh my cases

Library to recursively convert any types from any cases to destination one

Install

npm

npm install oh-my-cases

yarn

yarn add oh-my-cases

Usage

import { snakeToCamel } from 'oh-my-cases'

snakeToCamel('snake_case') // => 'snakeCase'
snakeToCamel({'snake_case': 11}) // => {'snakeCase': 11}

How to contribute

To add support for new case, just add two functions like snakeStringtoCamel and snakeToCamel into index.js and export function for case conversion. Don't forgot about tests.

Example for camelCase:

// index.js

const snakeStringToCamel = (value) => {
  return value.replace(/_(\w)/g, (m) => m[1].toUpperCase())
}

const snakeToCamel = toCase(snakeStringToCamel)

module.exports = {
  // ...
  snakeToCamel
  // ...
}

Then make a Pull Request and thanks to you for help grow open source :)

Package Sidebar

Install

npm i oh-my-case

Weekly Downloads

1

Version

1.0.5

License

MIT

Unpacked Size

5.34 kB

Total Files

5

Last publish

Collaborators

  • d.a.nelson