Scrub objects giving a condition function and a process function that is invoked if the condition is true.
var Scrubber = require('object-scrubber'); var testObj = { _id: 'test', title: 'test', collection: ['test1', 'test2'] } var scrubber = new Scrubber() scrubber.when(function (xx) { return typeof(x.value) === 'string' }, function (x) { return x.value + '_processed!' }); scrubber.scrub(testObj);