uncapitalizeKeys

Convert the first letter of each object key to lowercase.

Usage

var uncapitalizeKeys = require( '@stdlib/utils/uncapitalize-keys' );

uncapitalizeKeys( obj )

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

var obj1 = {
    'BeepBoop': 1,
    'FooBar': 2
};

var obj2 = uncapitalizeKeys( 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 uncapitalizeKeys = require( '@stdlib/utils/uncapitalize-keys' );

var obj1 = {
    'AA': 'beep',
    'BB': 'boop',
    'CC': 'foo',
    'DD': 'bar'
};

var obj2 = uncapitalizeKeys( obj1 );

console.dir( obj2 );
// => { 'aA': 'beep', 'bB': 'boop', 'cC': 'foo', 'dD': 'bar' }
Did you find this page helpful?