node-pluginsmanager-plugin 4.8.8 → 5.0.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/lib/cjs/checkers/RangeError/checkArrayLength.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkArrayLength.js +26 -0
- package/lib/cjs/checkers/RangeError/checkArrayLengthBetween.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkArrayLengthBetween.js +33 -0
- package/lib/cjs/checkers/RangeError/checkIntegerBetween.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkIntegerBetween.js +32 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyArray.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyArray.js +22 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyInteger.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyInteger.js +22 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyNumber.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyNumber.js +22 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyObject.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyObject.js +22 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyString.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyString.js +22 -0
- package/lib/cjs/checkers/RangeError/checkNumberBetween.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkNumberBetween.js +32 -0
- package/lib/cjs/checkers/RangeError/checkObjectLength.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkObjectLength.js +31 -0
- package/lib/cjs/checkers/RangeError/checkObjectLengthBetween.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkObjectLengthBetween.js +36 -0
- package/lib/cjs/checkers/RangeError/checkStringLength.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkStringLength.js +26 -0
- package/lib/cjs/checkers/RangeError/checkStringLengthBetween.d.ts +2 -0
- package/lib/cjs/checkers/RangeError/checkStringLengthBetween.js +33 -0
- package/lib/cjs/checkers/ReferenceError/checkExists.d.ts +2 -0
- package/lib/cjs/checkers/ReferenceError/checkExists.js +19 -0
- package/lib/cjs/checkers/TypeError/checkArray.d.ts +2 -0
- package/lib/cjs/checkers/TypeError/checkArray.js +22 -0
- package/lib/cjs/checkers/TypeError/checkBoolean.d.ts +2 -0
- package/lib/cjs/checkers/TypeError/checkBoolean.js +22 -0
- package/lib/cjs/checkers/TypeError/checkFunction.d.ts +2 -0
- package/lib/cjs/checkers/TypeError/checkFunction.js +22 -0
- package/lib/cjs/checkers/TypeError/checkInteger.d.ts +2 -0
- package/lib/cjs/checkers/TypeError/checkInteger.js +22 -0
- package/lib/cjs/checkers/TypeError/checkNumber.d.ts +2 -0
- package/lib/cjs/checkers/TypeError/checkNumber.js +22 -0
- package/lib/cjs/checkers/TypeError/checkObject.d.ts +2 -0
- package/lib/cjs/checkers/TypeError/checkObject.js +22 -0
- package/lib/cjs/checkers/TypeError/checkString.d.ts +2 -0
- package/lib/cjs/checkers/TypeError/checkString.js +22 -0
- package/lib/cjs/components/DescriptorUser.d.ts +27 -0
- package/lib/cjs/components/DescriptorUser.js +120 -0
- package/lib/cjs/components/Mediator.d.ts +20 -0
- package/lib/cjs/components/Mediator.js +145 -0
- package/lib/cjs/components/MediatorUser.d.ts +12 -0
- package/lib/cjs/components/MediatorUser.js +40 -0
- package/lib/cjs/components/NotFoundError.d.ts +2 -0
- package/lib/cjs/components/NotFoundError.js +7 -0
- package/lib/cjs/components/Orchestrator.d.ts +55 -0
- package/lib/cjs/components/Orchestrator.js +386 -0
- package/lib/cjs/components/Server.d.ts +55 -0
- package/lib/cjs/components/Server.js +535 -0
- package/lib/cjs/main.cjs +90 -0
- package/lib/cjs/main.d.cts +30 -0
- package/lib/cjs/utils/cleanSendedError.d.ts +1 -0
- package/lib/cjs/utils/cleanSendedError.js +43 -0
- package/lib/cjs/utils/descriptor/extractParams.d.ts +3 -0
- package/lib/cjs/utils/descriptor/extractParams.js +21 -0
- package/lib/cjs/utils/descriptor/extractPathMethodByOperationId.d.ts +8 -0
- package/lib/cjs/utils/descriptor/extractPathMethodByOperationId.js +34 -0
- package/lib/cjs/utils/descriptor/extractPattern.d.ts +2 -0
- package/lib/cjs/utils/descriptor/extractPattern.js +28 -0
- package/lib/cjs/utils/descriptor/extractSchemaType.d.ts +4 -0
- package/lib/cjs/utils/descriptor/extractSchemaType.js +18 -0
- package/lib/cjs/utils/file/checkFile.d.ts +1 -0
- package/lib/cjs/utils/file/checkFile.js +17 -0
- package/lib/cjs/utils/file/isFile.d.ts +1 -0
- package/lib/cjs/utils/file/isFile.js +19 -0
- package/lib/cjs/utils/file/readJSONFile.d.ts +1 -0
- package/lib/cjs/utils/file/readJSONFile.js +24 -0
- package/lib/cjs/utils/getUniqueID.d.ts +1 -0
- package/lib/cjs/utils/getUniqueID.js +16 -0
- package/lib/cjs/utils/removeFirstSlash.d.ts +1 -0
- package/lib/cjs/utils/removeFirstSlash.js +8 -0
- package/lib/cjs/utils/request/extractBody.d.ts +7 -0
- package/lib/cjs/utils/request/extractBody.js +52 -0
- package/lib/cjs/utils/request/extractCookies.d.ts +4 -0
- package/lib/cjs/utils/request/extractCookies.js +53 -0
- package/lib/cjs/utils/request/extractIp.d.ts +1 -0
- package/lib/cjs/utils/request/extractIp.js +40 -0
- package/lib/cjs/utils/send.d.ts +2 -0
- package/lib/cjs/utils/send.js +57 -0
- package/lib/cjs/utils/serverCodes.d.ts +14 -0
- package/lib/cjs/utils/serverCodes.js +15 -0
- package/package.json +32 -13
- package/lib/checkers/RangeError/checkArrayLength.js +0 -74
- package/lib/checkers/RangeError/checkArrayLengthBetween.js +0 -97
- package/lib/checkers/RangeError/checkIntegerBetween.js +0 -96
- package/lib/checkers/RangeError/checkNonEmptyArray.js +0 -61
- package/lib/checkers/RangeError/checkNonEmptyInteger.js +0 -61
- package/lib/checkers/RangeError/checkNonEmptyNumber.js +0 -61
- package/lib/checkers/RangeError/checkNonEmptyObject.js +0 -61
- package/lib/checkers/RangeError/checkNonEmptyString.js +0 -61
- package/lib/checkers/RangeError/checkNumberBetween.js +0 -96
- package/lib/checkers/RangeError/checkObjectLength.js +0 -78
- package/lib/checkers/RangeError/checkObjectLengthBetween.js +0 -101
- package/lib/checkers/RangeError/checkStringLength.js +0 -70
- package/lib/checkers/RangeError/checkStringLengthBetween.js +0 -97
- package/lib/checkers/ReferenceError/checkExists.js +0 -49
- package/lib/checkers/TypeError/checkArray.js +0 -61
- package/lib/checkers/TypeError/checkBoolean.js +0 -61
- package/lib/checkers/TypeError/checkFunction.js +0 -61
- package/lib/checkers/TypeError/checkInteger.js +0 -61
- package/lib/checkers/TypeError/checkNumber.js +0 -61
- package/lib/checkers/TypeError/checkObject.js +0 -61
- package/lib/checkers/TypeError/checkString.js +0 -61
- package/lib/checkers/main.js +0 -76
- package/lib/components/DescriptorUser.js +0 -179
- package/lib/components/Mediator.js +0 -220
- package/lib/components/MediatorUser.js +0 -63
- package/lib/components/NotFoundError.js +0 -5
- package/lib/components/Orchestrator.js +0 -634
- package/lib/components/Server.js +0 -777
- package/lib/components/main.js +0 -25
- package/lib/index.d.ts +0 -279
- package/lib/main.js +0 -17
- package/lib/utils/cleanSendedError.js +0 -47
- package/lib/utils/descriptor/extractParams.js +0 -29
- package/lib/utils/descriptor/extractPathMethodByOperationId.js +0 -47
- package/lib/utils/descriptor/extractPattern.js +0 -38
- package/lib/utils/descriptor/extractSchemaType.js +0 -24
- package/lib/utils/descriptor/main.js +0 -21
- package/lib/utils/file/checkFile.js +0 -22
- package/lib/utils/file/isFile.js +0 -29
- package/lib/utils/file/main.js +0 -19
- package/lib/utils/file/readJSONFile.js +0 -30
- package/lib/utils/getUniqueID.js +0 -20
- package/lib/utils/removeFirstSlash.js +0 -7
- package/lib/utils/request/extractBody.js +0 -79
- package/lib/utils/request/extractCookies.js +0 -68
- package/lib/utils/request/extractIp.js +0 -47
- package/lib/utils/request/main.js +0 -19
- package/lib/utils/send.js +0 -75
- package/lib/utils/serverCodes.json +0 -17
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
eslint max-params: [ "error", 5 ]
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
// deps
|
|
8
|
-
|
|
9
|
-
// natives
|
|
10
|
-
const { join } = require("path");
|
|
11
|
-
|
|
12
|
-
// locals
|
|
13
|
-
const checkNumber = require(join(__dirname, "..", "TypeError", "checkNumber.js"));
|
|
14
|
-
const checkNonEmptyNumber = require(join(__dirname, "checkNonEmptyNumber.js"));
|
|
15
|
-
|
|
16
|
-
// private
|
|
17
|
-
|
|
18
|
-
// methods
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Execute an asynchronous check on data
|
|
22
|
-
* @param {string} dataName: data identifier
|
|
23
|
-
* @param {any} data: data to check
|
|
24
|
-
* @param {number} min: min to check
|
|
25
|
-
* @param {number} max: max to check
|
|
26
|
-
* @returns {Promise} check result
|
|
27
|
-
*/
|
|
28
|
-
function _async (dataName, data, min, max) {
|
|
29
|
-
|
|
30
|
-
return checkNumber(dataName, data, true).then(() => {
|
|
31
|
-
return checkNonEmptyNumber(dataName + "/min", min, true);
|
|
32
|
-
}).then(() => {
|
|
33
|
-
return checkNonEmptyNumber(dataName + "/max", max, true);
|
|
34
|
-
}).then(() => {
|
|
35
|
-
|
|
36
|
-
return min > data ? Promise.reject(new RangeError(
|
|
37
|
-
"\"" + dataName + "\" must be higher than " + min
|
|
38
|
-
)) : Promise.resolve();
|
|
39
|
-
|
|
40
|
-
}).then(() => {
|
|
41
|
-
|
|
42
|
-
return max < data ? Promise.reject(new RangeError(
|
|
43
|
-
"\"" + dataName + "\" must be lower than " + max
|
|
44
|
-
)) : Promise.resolve();
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Execute a synchronous check on data
|
|
52
|
-
* @param {string} dataName: data identifier
|
|
53
|
-
* @param {any} data: data to check
|
|
54
|
-
* @param {number} min: min to check
|
|
55
|
-
* @param {number} max: max to check
|
|
56
|
-
* @returns {ReferenceError|TypeError|RangeError|null} check result
|
|
57
|
-
*/
|
|
58
|
-
function _sync (dataName, data, min, max) {
|
|
59
|
-
|
|
60
|
-
let err = checkNumber(dataName, data, false);
|
|
61
|
-
|
|
62
|
-
if (!err) {
|
|
63
|
-
err = checkNonEmptyNumber(dataName + "/min", min, false);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!err) {
|
|
67
|
-
err = checkNonEmptyNumber(dataName + "/max", max, false);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!err && min > data) {
|
|
71
|
-
|
|
72
|
-
err = new RangeError(
|
|
73
|
-
"\"" + dataName + "\" must be higher than " + min
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (!err && max < data) {
|
|
79
|
-
|
|
80
|
-
err = new RangeError(
|
|
81
|
-
"\"" + dataName + "\" must be lower than " + max
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return err;
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// module
|
|
91
|
-
|
|
92
|
-
module.exports = function checkNumberBetween (dataName, data, min, max, async = true) {
|
|
93
|
-
|
|
94
|
-
return async ? _async(dataName, data, min, max) : _sync(dataName, data, min, max);
|
|
95
|
-
|
|
96
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
eslint max-params: [ "error", 5 ]
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
// deps
|
|
8
|
-
|
|
9
|
-
// natives
|
|
10
|
-
const { join } = require("path");
|
|
11
|
-
|
|
12
|
-
// locals
|
|
13
|
-
const checkObject = require(join(__dirname, "..", "TypeError", "checkObject.js"));
|
|
14
|
-
const checkInteger = require(join(__dirname, "..", "TypeError", "checkInteger.js"));
|
|
15
|
-
|
|
16
|
-
// private
|
|
17
|
-
|
|
18
|
-
// methods
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Execute an asynchronous check on data
|
|
22
|
-
* @param {string} dataName: data identifier
|
|
23
|
-
* @param {any} data: data to check
|
|
24
|
-
* @param {number} _length: length to check
|
|
25
|
-
* @returns {Promise} check result
|
|
26
|
-
*/
|
|
27
|
-
function _async (dataName, data, _length) {
|
|
28
|
-
|
|
29
|
-
return checkObject(dataName, data, true).then(() => {
|
|
30
|
-
return checkInteger(dataName + "/length", _length, true);
|
|
31
|
-
}).then(() => {
|
|
32
|
-
|
|
33
|
-
const { length } = Object.keys(data);
|
|
34
|
-
|
|
35
|
-
return _length !== length ? Promise.reject(new RangeError(
|
|
36
|
-
"\"" + dataName + "\" length must be equal to " + _length
|
|
37
|
-
)) : Promise.resolve();
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Execute a synchronous check on data
|
|
45
|
-
* @param {string} dataName: data identifier
|
|
46
|
-
* @param {any} data: data to check
|
|
47
|
-
* @param {number} _length: length to check
|
|
48
|
-
* @returns {ReferenceError|TypeError|RangeError|null} check result
|
|
49
|
-
*/
|
|
50
|
-
function _sync (dataName, data, _length) {
|
|
51
|
-
|
|
52
|
-
let err = checkObject(dataName, data, false);
|
|
53
|
-
|
|
54
|
-
if (!err) {
|
|
55
|
-
err = checkInteger(dataName + "/length", _length, false);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const { length } = Object.keys(data);
|
|
59
|
-
|
|
60
|
-
if (!err && _length !== length) {
|
|
61
|
-
|
|
62
|
-
err = new RangeError(
|
|
63
|
-
"\"" + dataName + "\" length must be equal to " + _length
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return err;
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// module
|
|
73
|
-
|
|
74
|
-
module.exports = function checkObjectLength (dataName, data, length, async = true) {
|
|
75
|
-
|
|
76
|
-
return async ? _async(dataName, data, length) : _sync(dataName, data, length);
|
|
77
|
-
|
|
78
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
eslint max-params: [ "error", 5 ]
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
// deps
|
|
8
|
-
|
|
9
|
-
// natives
|
|
10
|
-
const { join } = require("path");
|
|
11
|
-
|
|
12
|
-
// locals
|
|
13
|
-
const checkObject = require(join(__dirname, "..", "TypeError", "checkObject.js"));
|
|
14
|
-
const checkInteger = require(join(__dirname, "..", "TypeError", "checkInteger.js"));
|
|
15
|
-
const checkNonEmptyInteger = require(join(__dirname, "checkNonEmptyInteger.js"));
|
|
16
|
-
|
|
17
|
-
// private
|
|
18
|
-
|
|
19
|
-
// methods
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Execute an asynchronous check on data
|
|
23
|
-
* @param {string} dataName: data identifier
|
|
24
|
-
* @param {any} data: data to check
|
|
25
|
-
* @param {number} min: min to check
|
|
26
|
-
* @param {number} max: max to check
|
|
27
|
-
* @returns {Promise} check result
|
|
28
|
-
*/
|
|
29
|
-
function _async (dataName, data, min, max) {
|
|
30
|
-
|
|
31
|
-
return checkObject(dataName, data, true).then(() => {
|
|
32
|
-
return checkInteger(dataName + "/min", min, true);
|
|
33
|
-
}).then(() => {
|
|
34
|
-
return checkNonEmptyInteger(dataName + "/max", max, true);
|
|
35
|
-
}).then(() => {
|
|
36
|
-
|
|
37
|
-
const { length } = Object.keys(data);
|
|
38
|
-
|
|
39
|
-
return min > length ? Promise.reject(new RangeError(
|
|
40
|
-
"\"" + dataName + "\" length must be higher than " + min
|
|
41
|
-
)) : Promise.resolve().then(() => {
|
|
42
|
-
|
|
43
|
-
return max < length ? Promise.reject(new RangeError(
|
|
44
|
-
"\"" + dataName + "\" length must be lower than " + max
|
|
45
|
-
)) : Promise.resolve();
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Execute a synchronous check on data
|
|
55
|
-
* @param {string} dataName: data identifier
|
|
56
|
-
* @param {any} data: data to check
|
|
57
|
-
* @param {number} min: min to check
|
|
58
|
-
* @param {number} max: max to check
|
|
59
|
-
* @returns {ReferenceError|TypeError|RangeError|null} check result
|
|
60
|
-
*/
|
|
61
|
-
function _sync (dataName, data, min, max) {
|
|
62
|
-
|
|
63
|
-
let err = checkObject(dataName, data, false);
|
|
64
|
-
|
|
65
|
-
if (!err) {
|
|
66
|
-
err = checkInteger(dataName + "/min", min, false);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!err) {
|
|
70
|
-
err = checkNonEmptyInteger(dataName + "/max", max, false);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const { length } = Object.keys(data);
|
|
74
|
-
|
|
75
|
-
if (!err && min > length) {
|
|
76
|
-
|
|
77
|
-
err = new RangeError(
|
|
78
|
-
"\"" + dataName + "\" length must be higher than " + min
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!err && max < length) {
|
|
84
|
-
|
|
85
|
-
err = new RangeError(
|
|
86
|
-
"\"" + dataName + "\" length must be lower than " + max
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return err;
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// module
|
|
96
|
-
|
|
97
|
-
module.exports = function checkObjectLengthBetween (dataName, data, min, max, async = true) {
|
|
98
|
-
|
|
99
|
-
return async ? _async(dataName, data, min, max) : _sync(dataName, data, min, max);
|
|
100
|
-
|
|
101
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// deps
|
|
4
|
-
|
|
5
|
-
// natives
|
|
6
|
-
const { join } = require("path");
|
|
7
|
-
|
|
8
|
-
// locals
|
|
9
|
-
const checkString = require(join(__dirname, "..", "TypeError", "checkString.js"));
|
|
10
|
-
const checkInteger = require(join(__dirname, "..", "TypeError", "checkInteger.js"));
|
|
11
|
-
|
|
12
|
-
// private
|
|
13
|
-
|
|
14
|
-
// methods
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Execute an asynchronous check on data
|
|
18
|
-
* @param {string} dataName: data identifier
|
|
19
|
-
* @param {any} data: data to check
|
|
20
|
-
* @param {number} length: length to check
|
|
21
|
-
* @returns {Promise} check result
|
|
22
|
-
*/
|
|
23
|
-
function _async (dataName, data, length) {
|
|
24
|
-
|
|
25
|
-
return checkString(dataName, data, true).then(() => {
|
|
26
|
-
return checkInteger(dataName + "/length", length, true);
|
|
27
|
-
}).then(() => {
|
|
28
|
-
|
|
29
|
-
return length !== data.length ? Promise.reject(new RangeError(
|
|
30
|
-
"\"" + dataName + "\" length must be equal to " + length
|
|
31
|
-
)) : Promise.resolve();
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Execute a synchronous check on data
|
|
39
|
-
* @param {string} dataName: data identifier
|
|
40
|
-
* @param {any} data: data to check
|
|
41
|
-
* @param {number} length: length to check
|
|
42
|
-
* @returns {ReferenceError|TypeError|RangeError|null} check result
|
|
43
|
-
*/
|
|
44
|
-
function _sync (dataName, data, length) {
|
|
45
|
-
|
|
46
|
-
let err = checkString(dataName, data, false);
|
|
47
|
-
|
|
48
|
-
if (!err) {
|
|
49
|
-
err = checkInteger(dataName + "/length", length, false);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (!err && length !== data.length) {
|
|
53
|
-
|
|
54
|
-
err = new RangeError(
|
|
55
|
-
"\"" + dataName + "\" length must be equal to " + length
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return err;
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// module
|
|
65
|
-
|
|
66
|
-
module.exports = function checkStringLength (dataName, data, length, async = true) {
|
|
67
|
-
|
|
68
|
-
return async ? _async(dataName, data, length) : _sync(dataName, data, length);
|
|
69
|
-
|
|
70
|
-
};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
eslint max-params: [ "error", 5 ]
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
// deps
|
|
8
|
-
|
|
9
|
-
// natives
|
|
10
|
-
const { join } = require("path");
|
|
11
|
-
|
|
12
|
-
// locals
|
|
13
|
-
const checkString = require(join(__dirname, "..", "TypeError", "checkString.js"));
|
|
14
|
-
const checkInteger = require(join(__dirname, "..", "TypeError", "checkInteger.js"));
|
|
15
|
-
const checkNonEmptyInteger = require(join(__dirname, "checkNonEmptyInteger.js"));
|
|
16
|
-
|
|
17
|
-
// private
|
|
18
|
-
|
|
19
|
-
// methods
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Execute an asynchronous check on data
|
|
23
|
-
* @param {string} dataName: data identifier
|
|
24
|
-
* @param {any} data: data to check
|
|
25
|
-
* @param {number} min: min to check
|
|
26
|
-
* @param {number} max: max to check
|
|
27
|
-
* @returns {Promise} check result
|
|
28
|
-
*/
|
|
29
|
-
function _async (dataName, data, min, max) {
|
|
30
|
-
|
|
31
|
-
return checkString(dataName, data, true).then(() => {
|
|
32
|
-
return checkInteger(dataName + "/min", min, true);
|
|
33
|
-
}).then(() => {
|
|
34
|
-
return checkNonEmptyInteger(dataName + "/max", max, true);
|
|
35
|
-
}).then(() => {
|
|
36
|
-
|
|
37
|
-
return min > data.length ? Promise.reject(new RangeError(
|
|
38
|
-
"\"" + dataName + "\" length must be higher than " + min
|
|
39
|
-
)) : Promise.resolve();
|
|
40
|
-
|
|
41
|
-
}).then(() => {
|
|
42
|
-
|
|
43
|
-
return max < data.length ? Promise.reject(new RangeError(
|
|
44
|
-
"\"" + dataName + "\" length must be lower than " + max
|
|
45
|
-
)) : Promise.resolve();
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Execute a synchronous check on data
|
|
53
|
-
* @param {string} dataName: data identifier
|
|
54
|
-
* @param {any} data: data to check
|
|
55
|
-
* @param {number} min: min to check
|
|
56
|
-
* @param {number} max: max to check
|
|
57
|
-
* @returns {ReferenceError|TypeError|RangeError|null} check result
|
|
58
|
-
*/
|
|
59
|
-
function _sync (dataName, data, min, max) {
|
|
60
|
-
|
|
61
|
-
let err = checkString(dataName, data, false);
|
|
62
|
-
|
|
63
|
-
if (!err) {
|
|
64
|
-
err = checkInteger(dataName + "/min", min, false);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!err) {
|
|
68
|
-
err = checkNonEmptyInteger(dataName + "/max", max, false);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!err && min > data.length) {
|
|
72
|
-
|
|
73
|
-
err = new RangeError(
|
|
74
|
-
"\"" + dataName + "\" length must be higher than " + min
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (!err && max < data.length) {
|
|
80
|
-
|
|
81
|
-
err = new RangeError(
|
|
82
|
-
"\"" + dataName + "\" length must be lower than " + max
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return err;
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// module
|
|
92
|
-
|
|
93
|
-
module.exports = function checkStringLengthBetween (dataName, data, min, max, async = true) {
|
|
94
|
-
|
|
95
|
-
return async ? _async(dataName, data, min, max) : _sync(dataName, data, min, max);
|
|
96
|
-
|
|
97
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// private
|
|
4
|
-
|
|
5
|
-
// methods
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Execute an asynchronous check on data
|
|
9
|
-
* @param {string} dataName: data identifier
|
|
10
|
-
* @param {any} data: data to check
|
|
11
|
-
* @returns {Promise} check result
|
|
12
|
-
*/
|
|
13
|
-
function _async (dataName, data) {
|
|
14
|
-
|
|
15
|
-
return "undefined" === typeof data ? Promise.reject(new ReferenceError(
|
|
16
|
-
"\"" + dataName + "\" does not exist"
|
|
17
|
-
)) : Promise.resolve();
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Execute a synchronous check on data
|
|
23
|
-
* @param {string} dataName: data identifier
|
|
24
|
-
* @param {any} data: data to check
|
|
25
|
-
* @returns {ReferenceError|null} check result
|
|
26
|
-
*/
|
|
27
|
-
function _sync (dataName, data) {
|
|
28
|
-
|
|
29
|
-
let err = null;
|
|
30
|
-
|
|
31
|
-
if ("undefined" === typeof data) {
|
|
32
|
-
|
|
33
|
-
err = new ReferenceError(
|
|
34
|
-
"\"" + dataName + "\" does not exist"
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return err;
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// module
|
|
44
|
-
|
|
45
|
-
module.exports = function checkExists (dataName, data, async = true) {
|
|
46
|
-
|
|
47
|
-
return async ? _async(dataName, data) : _sync(dataName, data);
|
|
48
|
-
|
|
49
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// deps
|
|
4
|
-
|
|
5
|
-
// natives
|
|
6
|
-
const { join } = require("path");
|
|
7
|
-
|
|
8
|
-
// locals
|
|
9
|
-
const checkObject = require(join(__dirname, "checkObject.js"));
|
|
10
|
-
|
|
11
|
-
// private
|
|
12
|
-
|
|
13
|
-
// methods
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Execute an asynchronous check on data
|
|
17
|
-
* @param {string} dataName: data identifier
|
|
18
|
-
* @param {any} data: data to check
|
|
19
|
-
* @returns {Promise} check result
|
|
20
|
-
*/
|
|
21
|
-
function _async (dataName, data) {
|
|
22
|
-
|
|
23
|
-
return checkObject(dataName, data, true).then(() => {
|
|
24
|
-
|
|
25
|
-
return !(data instanceof Array) ? Promise.reject(new TypeError(
|
|
26
|
-
"\"" + dataName + "\" is not an Array"
|
|
27
|
-
)) : Promise.resolve();
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Execute a synchronous check on data
|
|
35
|
-
* @param {string} dataName: data identifier
|
|
36
|
-
* @param {any} data: data to check
|
|
37
|
-
* @returns {ReferenceError|TypeError|null} check result
|
|
38
|
-
*/
|
|
39
|
-
function _sync (dataName, data) {
|
|
40
|
-
|
|
41
|
-
let err = checkObject(dataName, data, false);
|
|
42
|
-
|
|
43
|
-
if (!err && !(data instanceof Array)) {
|
|
44
|
-
|
|
45
|
-
err = new TypeError(
|
|
46
|
-
"\"" + dataName + "\" is not an Array"
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return err;
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// module
|
|
56
|
-
|
|
57
|
-
module.exports = function checkArray (dataName, data, async = true) {
|
|
58
|
-
|
|
59
|
-
return async ? _async(dataName, data) : _sync(dataName, data);
|
|
60
|
-
|
|
61
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// deps
|
|
4
|
-
|
|
5
|
-
// natives
|
|
6
|
-
const { join } = require("path");
|
|
7
|
-
|
|
8
|
-
// locals
|
|
9
|
-
const checkExists = require(join(__dirname, "..", "ReferenceError", "checkExists.js"));
|
|
10
|
-
|
|
11
|
-
// private
|
|
12
|
-
|
|
13
|
-
// methods
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Execute an asynchronous check on data
|
|
17
|
-
* @param {string} dataName: data identifier
|
|
18
|
-
* @param {any} data: data to check
|
|
19
|
-
* @returns {Promise} check result
|
|
20
|
-
*/
|
|
21
|
-
function _async (dataName, data) {
|
|
22
|
-
|
|
23
|
-
return checkExists(dataName, data, true).then(() => {
|
|
24
|
-
|
|
25
|
-
return "boolean" !== typeof data ? Promise.reject(new TypeError(
|
|
26
|
-
"\"" + dataName + "\" is not a boolean"
|
|
27
|
-
)) : Promise.resolve();
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Execute a synchronous check on data
|
|
35
|
-
* @param {string} dataName: data identifier
|
|
36
|
-
* @param {any} data: data to check
|
|
37
|
-
* @returns {ReferenceError|TypeError|null} check result
|
|
38
|
-
*/
|
|
39
|
-
function _sync (dataName, data) {
|
|
40
|
-
|
|
41
|
-
let err = checkExists(dataName, data, false);
|
|
42
|
-
|
|
43
|
-
if (!err && "boolean" !== typeof data) {
|
|
44
|
-
|
|
45
|
-
err = new TypeError(
|
|
46
|
-
"\"" + dataName + "\" is not a boolean"
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return err;
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// module
|
|
56
|
-
|
|
57
|
-
module.exports = function checkBoolean (dataName, data, async = true) {
|
|
58
|
-
|
|
59
|
-
return async ? _async(dataName, data) : _sync(dataName, data);
|
|
60
|
-
|
|
61
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// deps
|
|
4
|
-
|
|
5
|
-
// natives
|
|
6
|
-
const { join } = require("path");
|
|
7
|
-
|
|
8
|
-
// locals
|
|
9
|
-
const checkExists = require(join(__dirname, "..", "ReferenceError", "checkExists.js"));
|
|
10
|
-
|
|
11
|
-
// private
|
|
12
|
-
|
|
13
|
-
// methods
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Execute an asynchronous check on data
|
|
17
|
-
* @param {string} dataName: data identifier
|
|
18
|
-
* @param {any} data: data to check
|
|
19
|
-
* @returns {Promise} check result
|
|
20
|
-
*/
|
|
21
|
-
function _async (dataName, data) {
|
|
22
|
-
|
|
23
|
-
return checkExists(dataName, data, true).then(() => {
|
|
24
|
-
|
|
25
|
-
return "function" !== typeof data ? Promise.reject(new TypeError(
|
|
26
|
-
"\"" + dataName + "\" is not a function"
|
|
27
|
-
)) : Promise.resolve();
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Execute a synchronous check on data
|
|
35
|
-
* @param {string} dataName: data identifier
|
|
36
|
-
* @param {any} data: data to check
|
|
37
|
-
* @returns {ReferenceError|TypeError|null} check result
|
|
38
|
-
*/
|
|
39
|
-
function _sync (dataName, data) {
|
|
40
|
-
|
|
41
|
-
let err = checkExists(dataName, data, false);
|
|
42
|
-
|
|
43
|
-
if (!err && "function" !== typeof data) {
|
|
44
|
-
|
|
45
|
-
err = new TypeError(
|
|
46
|
-
"\"" + dataName + "\" is not a function"
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return err;
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// module
|
|
56
|
-
|
|
57
|
-
module.exports = function checkFunction (dataName, data, async = true) {
|
|
58
|
-
|
|
59
|
-
return async ? _async(dataName, data) : _sync(dataName, data);
|
|
60
|
-
|
|
61
|
-
};
|