Skip to content

Inspired from Dot Net Data Transfer Object Concept, Utility contains method which rename keys in existing object using plain JavaScript code.

License

Notifications You must be signed in to change notification settings

anomepani/dto-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DTO-UTILS Inspired from Dot Net Data Transfer Object Concept, Utility contains method which rename keys in existing object using plain JavaScript code.

DTO-UTILS - Javascript utility to rename specific keys from array of object or collection easily

DTO-UTILS currently contains one method mapTo

Installation

In a browser:

Using npm:

$ npm i -g npm
$ npm i --save dto-utils

In Node.js:

// Load dto utils
var DTO = require('dto-utils');

How to use:

var collection=[{"category":"version control",url:"https://www.github.com"},{"category":"search engine",url:"https://www.google.com"}];

//Provide key value pair in which key is old key and value is new key(renamed key)
var newKeys={"category":"type"};

var isAllowKeyOverwrite=false;

// By default isAllowKeyOverwrite is true in utils, you can override by pssing appropriate flag
var newCollection=DTO.mapTo(collection,newKeys,isAllowKeyOverwrite); 

// newCollection have updated value like this [{"type":"version control",url:"https://www.github.com"},{"type":"search engine",url:"https://www.google.com"}]

About

Inspired from Dot Net Data Transfer Object Concept, Utility contains method which rename keys in existing object using plain JavaScript code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published