time-to-botec/js/node_modules/@stdlib/utils/capitalize-keys/README.md
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

2.6 KiB

capitalizeKeys

Convert the first letter of each object key to uppercase.

Usage

var capitalizeKeys = require( '@stdlib/utils/capitalize-keys' );

capitalizeKeys( obj )

Converts the first letter of each object key to uppercase, mapping the transformed keys to a new object having the same values.

var obj1 = {
    'beepBoop': 1,
    'fooBar': 2
};

var obj2 = capitalizeKeys( obj1 );
// returns { 'BeepBoop': 1, 'FooBar': 2 }

Notes

  • The function only transforms own properties. Hence, the function does not transform inherited properties.
  • The function shallow copies key values.

Examples

var capitalizeKeys = require( '@stdlib/utils/capitalize-keys' );

var obj1 = {
    'aa': 'beep',
    'bb': 'boop',
    'cc': 'foo',
    'dd': 'bar'
};

var obj2 = capitalizeKeys( obj1 );

console.dir( obj2 );
// => { 'Aa': 'beep', 'Bb': 'boop', 'Cc': 'foo', 'Dd': 'bar' }