@stdlib/utils-uncapitalize-keys
v0.2.2
Published
Convert the first letter of each object key to lowercase.
Downloads
18
Readme
uncapitalizeKeys
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' }
See Also
@stdlib/utils-capitalize-keys
: convert the first letter of each object key to uppercase.@stdlib/utils-lowercase-keys
: convert each object key to lowercase.
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
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.