1.0.3 • Published 7 years ago

recapitalizer v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

recapitalizer

Databases are sometimes particular about capitalization. One way to deal with this is to make all db objects lowercase, while keeping the capitalization elsewhere.

This module provides two simple functions for that.

##single(object,column) take an object with all-lowercase or snake-case fields, and a list of those fields camelCased, and return the object with camelCased fields

parameters

namedescription
objectan object with all-lowercase fields
columna list of those fields camelCased

returns

an object with camelCased fields

example

const recapitalizer=require('recapitalizer')
let rawObj={
    lowercase:1,
    snake_case:2
}
let camelColumns=['lowerCase','snakeCase']
recapitalizer.single(rawObj,camelColumns)
//output: { "lowerCase":1,"snakeCase":2 }

##multiple(objects,column) take a list of objects with all-lowercase or snake-case fields, and a list of those fields camelCased, and returns a list of the objects with camelCased fields

parameters

namedescription
objectsa list of objects with all-lowercase fields
columna list of those fields camelCased

returns

a list of the objects with camelCased fields

example

const recapitalizer=require('recapitalizer')
let rawObjList=[{
  lowercase:'1a',
  snake_case:'2a'
  },{
  lowercase:'1b',
  snake_case:'2b'
  }]
let camelColumns=['lowerCase','snakeCase']
recapitalizer.single(rawObj,camelColumns)
/*
output:
[{
  "lowerCase":"1a",
  "snakeCase":"2a"
  },{
  "lowerCase":"1b",
  "snakeCase":"2b"
}]
*/
1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago