@opndev/html 0.0.1 → 0.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/Changes +5 -0
- package/LICENSE +9 -0
- package/README.md +1 -1
- package/lib/index.mjs +3 -1
- package/lib/xhr.mjs +45 -1
- package/package.json +26 -26
- package/README.md.license +0 -3
package/Changes
CHANGED
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) <year> <copyright holders>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This is a utility function package for HTML based actions. It is an ESM package.
|
|
4
4
|
|
|
5
|
-
[If you want to know more, have a look at our documenation](https://opndev.gitlab.io/javascript/opndev-js-
|
|
5
|
+
[If you want to know more, have a look at our documenation](https://opndev.gitlab.io/javascript/opndev-js-html/)
|
|
6
6
|
|
|
7
7
|
## Development
|
|
8
8
|
|
package/lib/index.mjs
CHANGED
package/lib/xhr.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2024 Wesley Schwengle
|
|
1
|
+
// SPDX-FileCopyrightText: 2024, 2026 Wesley Schwengle <wesleys@opperschaap.net>
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: MIT
|
|
4
4
|
|
|
@@ -17,26 +17,70 @@ function isInStatusRange(xhr, code) {
|
|
|
17
17
|
return false
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Check if an HTTP status is an info status
|
|
23
|
+
*
|
|
24
|
+
* @function isInfo
|
|
25
|
+
* @param {*} xhr Should support xhr.status
|
|
26
|
+
* @returns {Boolean} true or false
|
|
27
|
+
*/
|
|
20
28
|
function isInfo(xhr) {
|
|
21
29
|
return isInStatusRange(xhr, 100);
|
|
22
30
|
}
|
|
23
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Check if an HTTP status is a success status
|
|
34
|
+
*
|
|
35
|
+
* @function isSuccess
|
|
36
|
+
* @param {*} xhr Should support xhr.status
|
|
37
|
+
* @returns {Boolean} true or false
|
|
38
|
+
*/
|
|
24
39
|
function isSuccess(xhr) {
|
|
25
40
|
return isInStatusRange(xhr, 200);
|
|
26
41
|
}
|
|
27
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Check if an HTTP status is a redirect status
|
|
45
|
+
*
|
|
46
|
+
* @function isRedirect
|
|
47
|
+
* @param {*} xhr Should support xhr.status
|
|
48
|
+
* @returns {Boolean} true or false
|
|
49
|
+
*/
|
|
28
50
|
function isRedirect(xhr) {
|
|
29
51
|
return isInStatusRange(xhr, 300);
|
|
30
52
|
}
|
|
31
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Check if an HTTP status is a client error status
|
|
56
|
+
*
|
|
57
|
+
* @function isClientError
|
|
58
|
+
* @param {*} xhr Should support xhr.status
|
|
59
|
+
* @returns {Boolean} true or false
|
|
60
|
+
*/
|
|
32
61
|
function isClientError(xhr) {
|
|
33
62
|
return isInStatusRange(xhr, 400);
|
|
34
63
|
}
|
|
35
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Check if an HTTP status is a server error status
|
|
67
|
+
*
|
|
68
|
+
* @function isClientError
|
|
69
|
+
* @param {*} xhr Should support xhr.status
|
|
70
|
+
* @returns {Boolean} true or false
|
|
71
|
+
*/
|
|
36
72
|
function isServerError(xhr) {
|
|
37
73
|
return isInStatusRange(xhr, 500);
|
|
38
74
|
}
|
|
39
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Check if an HTTP status is an error status. This can be either client or
|
|
78
|
+
* server.
|
|
79
|
+
*
|
|
80
|
+
* @function isError
|
|
81
|
+
* @param {*} xhr Should support xhr.status
|
|
82
|
+
* @returns {Boolean} true or false
|
|
83
|
+
*/
|
|
40
84
|
function isError(xhr) {
|
|
41
85
|
if (isClientError(xhr) || isServerError(xhr))
|
|
42
86
|
return true;
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@opndev/html",
|
|
3
|
-
"version": "0.0.1",
|
|
4
|
-
"description": "HTML utility functions for OPN Development",
|
|
5
|
-
"main": "lib/index.mjs",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"mode": "auto",
|
|
8
|
-
"sideEffects": false,
|
|
9
|
-
"homepage": "https://opndev.gitlab.io/javascript/opndev-js-html/",
|
|
10
|
-
"repository": {
|
|
11
|
-
"url": "git+https://gitlab.com/opndev/javascript/opndev-js-html.git"
|
|
12
|
-
},
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://gitlab.com/opndev/javascript/opndev-js-html/issues"
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"test": "tap",
|
|
18
|
-
"jsdoc" : "jsdoc -c jsdoc.json"
|
|
19
|
-
},
|
|
20
2
|
"author": {
|
|
21
|
-
"name": "Wesley Schwengle",
|
|
22
3
|
"email": "wesley@opndev.io",
|
|
4
|
+
"name": "Wesley Schwengle",
|
|
23
5
|
"url": "https://opndev.io"
|
|
24
6
|
},
|
|
25
|
-
"
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://gitlab.com/opndev/javascript/opndev-js-html/-/issues"
|
|
9
|
+
},
|
|
10
|
+
"description": "HTML utility functions for OPN Development",
|
|
26
11
|
"devDependencies": {
|
|
27
|
-
"jsdoc"
|
|
12
|
+
"jsdoc": "latest",
|
|
28
13
|
"tap": "latest"
|
|
29
14
|
},
|
|
30
|
-
"
|
|
31
|
-
"lib
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./lib/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://opndev.gitlab.io/javascript/opndev-js-html/",
|
|
19
|
+
"keywords": [
|
|
20
|
+
"utility"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"name": "@opndev/html",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://gitlab.com/opndev/javascript/opndev-js-html.git"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"jsdoc": "jsdoc -c jsdoc.json",
|
|
30
|
+
"test": "tap"
|
|
31
|
+
},
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"type": "module",
|
|
34
|
+
"version": "0.0.2"
|
|
35
35
|
}
|
package/README.md.license
DELETED