@stdlib/utils-uncapitalize-keys

Convert the first letter of each object key to lowercase.

Usage no npm install needed!

<script type="module">
  import stdlibUtilsUncapitalizeKeys from 'https://cdn.skypack.dev/@stdlib/utils-uncapitalize-keys';
</script>

README

uncapitalizeKeys

NPM version Build Status Coverage Status

Convert the first letter of each object key to lowercase.

Installation

npm install @stdlib/utils-uncapitalize-keys

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' }

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2022. The Stdlib Authors.