z-schema 3.18.3 → 3.18.4
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/README.md +3 -2
- package/dist/ZSchema-browser-min.js +1 -1
- package/dist/ZSchema-browser-min.js.map +1 -1
- package/dist/ZSchema-browser-test.js +3502 -3005
- package/dist/ZSchema-browser.js +281 -135
- package/package.json +4 -4
- package/src/SchemaCache.js +8 -3
- package/src/ZSchema.js +2 -2
- package/src/ReferenceCache.js +0 -34
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "z-schema",
|
|
3
|
-
"version": "3.18.
|
|
3
|
+
"version": "3.18.4",
|
|
4
4
|
"description": "JSON schema validator",
|
|
5
5
|
"homepage": "https://github.com/zaggino/z-schema",
|
|
6
6
|
"authors": [
|
|
@@ -67,15 +67,15 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"coveralls": "latest",
|
|
70
|
-
"grunt": "^0.
|
|
70
|
+
"grunt": "^1.0.1",
|
|
71
71
|
"grunt-cli": "latest",
|
|
72
|
-
"grunt-browserify": "^
|
|
72
|
+
"grunt-browserify": "^5.2.0",
|
|
73
73
|
"grunt-contrib-copy": "latest",
|
|
74
74
|
"grunt-contrib-jasmine": "latest",
|
|
75
75
|
"grunt-contrib-jshint": "latest",
|
|
76
76
|
"grunt-contrib-uglify": "latest",
|
|
77
77
|
"grunt-jasmine-node": "latest",
|
|
78
|
-
"grunt-jasmine-node-coverage": "^
|
|
78
|
+
"grunt-jasmine-node-coverage": "^1.2.0",
|
|
79
79
|
"grunt-jscs": "latest",
|
|
80
80
|
"grunt-lineending": "latest",
|
|
81
81
|
"jasmine-node": "latest",
|
package/src/SchemaCache.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var isequal = require("lodash.isequal");
|
|
3
4
|
var Report = require("./Report");
|
|
4
5
|
var SchemaCompilation = require("./SchemaCompilation");
|
|
5
6
|
var SchemaValidation = require("./SchemaValidation");
|
|
@@ -93,11 +94,15 @@ exports.getSchema = function (report, schema) {
|
|
|
93
94
|
};
|
|
94
95
|
|
|
95
96
|
exports.getSchemaByReference = function (report, key) {
|
|
96
|
-
var
|
|
97
|
-
|
|
97
|
+
var i = this.referenceCache.length;
|
|
98
|
+
while (i--) {
|
|
99
|
+
if (isequal(this.referenceCache[i][0], key)) {
|
|
100
|
+
return this.referenceCache[i][1];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
98
103
|
// not found
|
|
99
104
|
var schema = Utils.cloneDeep(key);
|
|
100
|
-
this.referenceCache.
|
|
105
|
+
this.referenceCache.push([key, schema]);
|
|
101
106
|
return schema;
|
|
102
107
|
};
|
|
103
108
|
|
package/src/ZSchema.js
CHANGED
|
@@ -11,7 +11,7 @@ var SchemaValidation = require("./SchemaValidation");
|
|
|
11
11
|
var Utils = require("./Utils");
|
|
12
12
|
var Draft4Schema = require("./schemas/schema.json");
|
|
13
13
|
var Draft4HyperSchema = require("./schemas/hyper-schema.json");
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
/*
|
|
16
16
|
default options
|
|
17
17
|
*/
|
|
@@ -65,7 +65,7 @@ var defaultOptions = {
|
|
|
65
65
|
*/
|
|
66
66
|
function ZSchema(options) {
|
|
67
67
|
this.cache = {};
|
|
68
|
-
this.referenceCache =
|
|
68
|
+
this.referenceCache = [];
|
|
69
69
|
|
|
70
70
|
this.setRemoteReference("http://json-schema.org/draft-04/schema", Draft4Schema);
|
|
71
71
|
this.setRemoteReference("http://json-schema.org/draft-04/hyper-schema", Draft4HyperSchema);
|
package/src/ReferenceCache.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
var isequal = require("lodash.isequal");
|
|
2
|
-
|
|
3
|
-
function ReferenceCache() {
|
|
4
|
-
this.init();
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
if (typeof Map !== "undefined") {
|
|
8
|
-
ReferenceCache.prototype = {
|
|
9
|
-
init: function () { this.map = new Map(); },
|
|
10
|
-
set: function (key, value) {
|
|
11
|
-
this.map.set(key, value);
|
|
12
|
-
},
|
|
13
|
-
get: function (key) {
|
|
14
|
-
return this.map.get(key);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
} else {
|
|
18
|
-
ReferenceCache.prototype = {
|
|
19
|
-
init: function () { this.map = []; },
|
|
20
|
-
set: function (key, value) {
|
|
21
|
-
this.map.push([key, value]);
|
|
22
|
-
},
|
|
23
|
-
get: function (key) {
|
|
24
|
-
var i = this.map.length;
|
|
25
|
-
while (i--) {
|
|
26
|
-
if (isequal(this.map[i][0], key)) {
|
|
27
|
-
return this.map[i][1];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = ReferenceCache;
|