@stdlib/utils-uppercase-keys
v0.2.2
Published
Convert each object key to uppercase.
Downloads
6
Readme
uppercaseKeys
Convert each object key to uppercase.
Installation
npm install @stdlib/utils-uppercase-keys
Usage
var uppercaseKeys = require( '@stdlib/utils-uppercase-keys' );
uppercaseKeys( obj )
Converts each object
key to uppercase, mapping the transformed keys to a new object
having the same values.
var obj1 = {
'a': 1,
'b': 2
};
var obj2 = uppercaseKeys( obj1 );
// returns { 'A': 1, 'B': 2 }
Notes
- The function only transforms own properties. Hence, the function does not transform inherited properties.
- The function shallow copies key values.
Examples
var uppercaseKeys = require( '@stdlib/utils-uppercase-keys' );
var obj1 = {
'a': 'beep',
'b': 'boop',
'c': 'foo',
'd': 'bar'
};
var obj2 = uppercaseKeys( obj1 );
console.dir( obj2 );
// => { 'A': 'beep', 'B': 'boop', 'C': 'foo', 'D': '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.