@legalplace/lplogic 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/LpLogic.js +16 -4
  2. package/package.json +1 -1
package/dist/LpLogic.js CHANGED
@@ -4,18 +4,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var json_logic_js_1 = __importDefault(require("@legalplace/json-logic-js"));
7
+ var safeEqual = function (value, comparator) {
8
+ if (!isNaN(comparator)) {
9
+ if (!isNaN(value)) {
10
+ return parseFloat(value) === parseFloat(comparator);
11
+ }
12
+ return false;
13
+ }
14
+ if (!isNaN(value)) {
15
+ return false;
16
+ }
17
+ return value === comparator;
18
+ };
7
19
  json_logic_js_1.default.add_operation("=", function (value, comparator) {
8
20
  if (!Array.isArray(value)) {
9
- return value === comparator;
21
+ return safeEqual(value, comparator);
10
22
  }
11
- var filter = value.filter(function (_value) { return _value === comparator; });
23
+ var filter = value.filter(function (_value) { return safeEqual(_value, comparator); });
12
24
  return value.length === filter.length;
13
25
  });
14
26
  json_logic_js_1.default.add_operation("<>", function (value, comparator) {
15
27
  if (!Array.isArray(value)) {
16
- return value !== comparator;
28
+ return !safeEqual(value, comparator);
17
29
  }
18
- var filter = value.filter(function (_value) { return _value !== comparator; });
30
+ var filter = value.filter(function (_value) { return !safeEqual(_value, comparator); });
19
31
  return value.length === filter.length;
20
32
  });
21
33
  json_logic_js_1.default.add_operation("==", function (value, comparator) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/lplogic",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "LegalPlace LpLogic",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",