z-schema 4.1.0 → 4.2.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "z-schema",
3
- "version": "4.1.0",
3
+ "version": "4.2.2",
4
4
  "engines": {
5
5
  "node": ">=6.0.0"
6
6
  },
@@ -66,10 +66,9 @@
66
66
  ]
67
67
  },
68
68
  "dependencies": {
69
- "core-js": "^2.5.7",
70
69
  "lodash.get": "^4.4.2",
71
70
  "lodash.isequal": "^4.5.0",
72
- "validator": "^10.11.0"
71
+ "validator": "^11.0.0"
73
72
  },
74
73
  "optionalDependencies": {
75
74
  "commander": "^2.7.1"
@@ -81,7 +80,7 @@
81
80
  "grunt-cli": "^1.2.0",
82
81
  "grunt-contrib-copy": "^1.0.0",
83
82
  "grunt-contrib-jasmine": "^1.1.0",
84
- "grunt-contrib-jshint": "^1.1.0",
83
+ "grunt-contrib-jshint": "^2.0.0",
85
84
  "grunt-contrib-uglify": "^3.1.0",
86
85
  "grunt-jscs": "^3.0.1",
87
86
  "grunt-lineending": "^1.0.0",
@@ -21,7 +21,9 @@ var JsonValidators = {
21
21
  return;
22
22
  }
23
23
 
24
- if (Utils.whatIs(json / schema.multipleOf) !== "integer") {
24
+ var stringMultipleOf = String(schema.multipleOf);
25
+ var scale = Math.pow(10, stringMultipleOf.length - stringMultipleOf.indexOf(".") - 1);
26
+ if (Utils.whatIs((json * scale) / (schema.multipleOf * scale)) !== "integer") {
25
27
  report.addError("MULTIPLE_OF", [json, schema.multipleOf], null, schema);
26
28
  }
27
29
  },
@@ -605,7 +607,7 @@ exports.validate = function (report, schema, json) {
605
607
  }
606
608
 
607
609
  if (typeof this.options.customValidator === "function") {
608
- this.options.customValidator(report, schema, json);
610
+ this.options.customValidator.call(this, report, schema, json);
609
611
  }
610
612
 
611
613
  // we don't need the root pointer anymore
package/src/Utils.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/es6/symbol");
4
-
5
3
  exports.jsonSymbol = Symbol.for("z-schema/json");
6
4
 
7
5
  exports.schemaSymbol = Symbol.for("z-schema/schema");
@@ -199,15 +197,15 @@ exports.clone = function (src) {
199
197
  };
200
198
 
201
199
  exports.cloneDeep = function (src) {
202
- var visited = [], cloned = [];
200
+ var vidx = 0, visited = new Map(), cloned = [];
203
201
  function cloneDeep(src) {
204
202
  if (typeof src !== "object" || src === null) { return src; }
205
203
  var res, idx, cidx;
206
204
 
207
- cidx = visited.indexOf(src);
208
- if (cidx !== -1) { return cloned[cidx]; }
205
+ cidx = visited.get(src);
206
+ if (cidx !== undefined) { return cloned[cidx]; }
209
207
 
210
- visited.push(src);
208
+ visited.set(src, vidx++);
211
209
  if (Array.isArray(src)) {
212
210
  res = [];
213
211
  cloned.push(res);