Skip to content

It provides an API to convert the values of the object into uppercase. Client of this API can specify if values of nested keys are also required to be converted to uppercase.

License

luthraG/uppercase-values

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uppercase-values

It provides an API to convert the values of the object into uppercase. Client of this API can specify if values of nested keys are also required to be converted to uppercase.

Installation

Install with npm:

$ npm install uppercase-values --save

Usage

var UPPER_CASE_VALUES = require('uppercase-values');

var object = {
    'California' : 'ca',
    'Texas'      : 'tx',
    'NEW YORK'   : 'ny' 
};

UPPER_CASE_VALUES.toUpperCaseValues(object);
//=> { 'California' : 'CA', 'Texas' : 'TX', 'NEW YORK' : 'NY' }

var days = {
    'SUNDAY'    : 'First',
    'MONDAY'    : 'Second',
    'TUESDAY'   : 'Third',
    'WEDNESDAY' : 3
};

UPPER_CASE_VALUES.toUpperCaseValues(days);
//=> { 'SUNDAY': 'FIRST', 'MONDAY' : 'SECOND', 'TUESDAY' : 'THIRD', 'WEDNESDAY' : 3 }

Clone the repo

$ git clone https://github.com/luthraG/uppercase-values.git

API

toUpperCaseValues(obj, [options])

This API takes two parameters:

  1. Object whose values to be converted to uppercase and
  2. options object. This argument is optional

Options

Various options supported by this API are :

  • deep - To specify if values of nested keys should also be converted to uppercase. Default is false.

Example with options

var UPPER_CASE_VALUES = require('uppercase-values');

var days = {
    'SUNDAY'    : 'First',
    'MONDAY'    : 'Second',
    'TUESDAY'   : 'Third',
    'WEDNESDAY' : 3,
    'WEEK_END'  : {
    	'SUNDAY' : {
    		'CODE' : {
    			'ABBR' : 'sat'
    		}
    	}
	}
};

UPPER_CASE_VALUES.toUpperCaseValues(days, { deep : true});
//=> { 'SUNDAY': 'FIRST', 'MONDAY' : 'SECOND', 'TUESDAY' : 'THIRD', 'WEDNESDAY' : 3, 'WEEK_END' : { 'SUNDAY' : { 'CODE' : { 'ABBR' : 'SAT' } } } }

Related projects

You might also be interested in these projects:

Author

Gaurav Luthra

License

MIT © Gaurav Luthra

About

It provides an API to convert the values of the object into uppercase. Client of this API can specify if values of nested keys are also required to be converted to uppercase.

Resources

License

Stars

Watchers

Forks

Packages

No packages published