0.1.6 • Published 4 years ago

props-to-camelcase v0.1.6

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

PropsToCamelCase Build Status

This library convert underscored object keys to camelCase. It's helpful when you get some props or response from third party like APIs or libraries when your ESlint configured to strict camelCase properties.

Examples

import propsToCamelCase from 'props-to-camelcase';

let obj = propsToCamelCase({
  user_id: 1,
  user_name: 'John Doe'
});

console.log(obj);
// { userId: 1, userName: 'John Doe' }
let arr = propsToCamelCase([
  { user_id: 1 },
  { user_id: 2 }
]);

console.log(arr);
// [{ userId: 1 }, { userId: 2 }]
fetch('/users')
  .then(res => res.json())
  // [{ user_id: 1, user_name: 'John Doe' }]
  .then(propsToCamelCase)
  .then(res => console.log(res));

// [{ userId: 1, userName: 'John Doe' }]

const promise = fetch('/users').then(res => res.json());

console.log(propsToCamelCase(promise));
// [{ userId: 1, userName: 'John Doe' }]

Scripts

npm start # development mode
npm build # build the library
npm test  # run the tests
0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago