Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

property-handlers

patrick-steele-idem19.1kMIT1.1.1

Utility for mapping object properties to handler functions

utlity, object, properties, handler, functions

readme

property-handlers

Installation

npm install property-handlers --save

Usage

var propertyHandlers = require('property-handlers');
propertyHandlers(object, handlers, path);

Arguments

  • object: An object with properties
  • handlers: An object with properties that correspond to allowed properties. The value of each property should be a handler function
  • 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');