Skip to content

ZacharyRSmith/transform-props

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transform Props

Transform @object properties using @propKeys and @transformers. ES5 compatible.

Installation

$ npm install transform-props

Usage

var transformProps = require('transform-props');

function castToString(arg) {
	return String(arg);
}

var doc = new MongooseModel({ subDoc: { foo: 'bar' }});
var docObj = doc.toObject();

transformProps(docObj, castToString, '_id');

console.log(typeof docObj._id); // 'string'
console.log(typeof docObj.subDoc._id); // 'string'

About

Transform @object properties using @propKeys and @transformers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published