transform-props
v1.0.1
Published
Transform @object properties using @propKeys and @transformers. ES5 compatible.
Downloads
397
Maintainers
Readme
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'