node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »



Helpers to transform every properties of an object having a specific suffix.

NPM version Build status Dependency Status devDependency Status Coverage Status

## transform-per-suffixes ### transform-per-suffixes~transformPerSuffixes(suffixes) ⇒ Object | Array | Object | Array Transform every properties of an object according to given suffixes.

Kind: inner method of transform-per-suffixes
Returns: Object | Array - val The source Object/ArrayObject | Array - The modified object

Param Type Description
suffixes Array An array of suffix definitions ({value: String, transform: Function})


var object = {
  _id: 'abbacacaabbacacaabbacaca',
  creation_date: '2015-11-28T16:22:47.552Z',
  value: 'Hey!'
  value: '_id',
  transform: castToObjectId,
}, {
  value: '_date',
  transform: function(d) { return new Date(d) },
// Prints: 
// { 
//   _id: ObjectId('abbacacaabbacacaabbacaca'), 
//   creation_date: Date('2015-11-28T16:22:47.552Z'), 
//   value: 'Hey!' 
// }