property-handlers
v1.1.1
Published
Utility for mapping object properties to handler functions
Downloads
17,243
Readme
property-handlers
Installation
npm install property-handlers --save
Usage
var propertyHandlers = require('property-handlers');
propertyHandlers(object, handlers, path);
Arguments
object
: An object with propertieshandlers
: An object with properties that correspond to allowed properties. The value of each property should be a handlerfunction
path
: Used for error reporting
Example:
var object = {
foo: 'foo',
bar: 'bar'
};
propertyHandlers(
object,
{
foo: function(value) {
// value === 'foo'
},
bar: function(value) {
// bar === 'bar'
}
},
'some path');