1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
8 |
|
9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10 |
|
11 | var Operator = function () {
|
12 | |
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | function Operator(name, cb, factValueValidator) {
|
20 | _classCallCheck(this, Operator);
|
21 |
|
22 | this.name = String(name);
|
23 | if (!name) throw new Error('Missing operator name');
|
24 | if (typeof cb !== 'function') throw new Error('Missing operator callback');
|
25 | this.cb = cb;
|
26 | this.factValueValidator = factValueValidator;
|
27 | if (!this.factValueValidator) this.factValueValidator = function () {
|
28 | return true;
|
29 | };
|
30 | }
|
31 |
|
32 | |
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | _createClass(Operator, [{
|
41 | key: 'evaluate',
|
42 | value: function evaluate(factValue, jsonValue) {
|
43 | return this.factValueValidator(factValue) && this.cb(factValue, jsonValue);
|
44 | }
|
45 | }]);
|
46 |
|
47 | return Operator;
|
48 | }();
|
49 |
|
50 | exports.default = Operator; |
\ | No newline at end of file |