property-handlers

2018-11-08 admin

property-handlers是什么

什么是property-handlers,Utility for mapping object properties to handler functions

property-handlers使用教程帮助文档

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');

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-44881.html

文章标题:property-handlers

回到顶部