UNPKG

dmn-eval-js-es5

Version:

Evaluation of DMN 1.1 decision tables, limited to S-FEEL (Simple Friendly Enough Expression Language), es5 browser compatible

54 lines (46 loc) 1.51 kB
'use strict'; const ProxyPolyfill = require('./proxy-polyfill'); /* * * ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary), * Bangalore, India. All Rights Reserved. * */ var addProperties = function addProperties(obj, props) { var child = Object.create(obj); Object.keys(props).forEach(function (key) { var value = props[key]; if (typeof value === 'function') { Object.defineProperty(child, key, { get: function get() { // eslint-disable-line object-shorthand var proto = Object.getPrototypeOf(this); return value.call(proto); } }); } else { Object.defineProperty(child, key, { get: function get() { // eslint-disable-line object-shorthand var proto = Object.getPrototypeOf(this); return key !== 'type' && proto[value] ? proto[value]() : value; } }); } }); var proxy = new ProxyPolyfill(child, { get: function get(target, propKey) { var proto = Object.getPrototypeOf(target); var protoPropValue = proto[propKey]; if (!target.hasOwnProperty(propKey) && typeof protoPropValue === 'function') { return function () { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return protoPropValue.apply(proto, args); }; } return target[propKey]; } }); return proxy; }; module.exports = addProperties;