casify
Converts object keys or array of objects' keys to different case styles. Returns shallow copy of objects.
Install
$ npm install --save casify
Usage
; const object = first_name: 'John' 'last name': 'Smith'; ;// { firstName: 'John', lastName: 'Smith' } ;// { FirstName: 'John', LastName: 'Smith' } ;// { 'first-name': 'John', 'last-name': 'Smith' } ;// { 'first_name': 'John', 'last_name': 'Smith' } ;// { 'First Name': 'John', 'Last Name': 'Smith' } ;// { 'FIRST NAME': 'John', 'LAST NAME': 'Smith' } ;// { 'first name': 'John', 'last name': 'Smith' } const array = tv_show: 'Malcom in the Middle' 'actor-name': 'Frankie Muniz' tv_show: 'Breaking Bad' 'ACTOR NAME': 'Bryan Cranston' tv_show: 'Mad Men' 'Actor Name': 'Jon Hamm' ; ;// [// { tvShow: 'Malcom in the Middle', actorName: 'Frankie Muniz' },// { tvShow: 'Breaking Bad', actorName: 'Bryan Cranston' },// { tvShow: 'Mad Men', actorName: 'Jon Hamm' },// ] ;// [// { TvShow: 'Malcom in the Middle', ActorName: 'Frankie Muniz' },// { TvShow: 'Breaking Bad', ActorName: 'Bryan Cranston' },// { TvShow: 'Mad Men', ActorName: 'Jon Hamm' },// ] ;// [// { 'tv-show': 'Malcom in the Middle', 'actor-name': 'Frankie Muniz' }// { 'tv-show': 'Breaking Bad', 'actor-name': 'Bryan Cranston' }// { 'tv-show': 'Mad Men', 'actor-name': 'Jon Hamm' }// ] ;// [// { tv_show: 'Malcom in the Middle', actor_name: 'Frankie Muniz' }// { tv_show: 'Breaking Bad', actor_name: 'Bryan Cranston' }// { tv_show: 'Mad Men', actor_name: 'Jon Hamm' }// ] ;// [// { 'Tv Show': 'Malcom in the Middle', 'Actor Name': 'Frankie Muniz' }// { 'Tv Show': 'Breaking Bad', 'Actor Name': 'Bryan Cranston' }// { 'Tv Show': 'Mad Men', 'Actor Name': 'Jon Hamm' }// ] ;// [// { 'TV SHOW': 'Malcom in the Middle', 'ACTOR NAME': 'Frankie Muniz' }// { 'TV SHOW': 'Breaking Bad', 'ACTOR NAME': 'Bryan Cranston' }// { 'TV SHOW': 'Mad Men', 'ACTOR NAME': 'Jon Hamm' }// ] ;// [// { 'tv show': 'Malcom in the Middle', 'actor name': 'Frankie Muniz' }// { 'tv show': 'Breaking Bad', 'actor name': 'Bryan Cranston' }// { 'tv show': 'Mad Men', 'actor name': 'Jon Hamm' }// ]
License
MIT © Milan