manner.js 1.0.1 → 1.0.3

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.
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isIpv4Address;
7
+ function isIpv4Address(address) {
8
+ const sections = address.split('.');
9
+ if (sections.length !== 4) {
10
+ return false;
11
+ }
12
+ for (let i = 0; i < sections.length; i += 1) {
13
+ const section = sections;
14
+ const value = parseInt(section);
15
+ if (!(value >= 0 && value <= 255)) {
16
+ return false;
17
+ }
18
+ }
19
+ return true;
20
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isIpv6Address;
7
+ function isIpv6Address(address) {
8
+ const sections = address.split(':');
9
+ if (sections.length !== 8) {
10
+ return false;
11
+ }
12
+ for (let i = 0; i < sections.length; i += 1) {
13
+ const section = sections;
14
+ const value = parseInt(section, 16);
15
+ if (!(value >= 0 && value <= 16 ** 4 - 1)) {
16
+ return false;
17
+ }
18
+ }
19
+ return true;
20
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = parseHttpDate;
7
+ function parseHttpDate(httpDate) {
8
+ let [_, rest] = httpDate.split(', ');
9
+ let [day, month, year, time] = rest.split(' ');
10
+ const [hours, minutes, seconds] = time.split(':');
11
+ const date = new Date();
12
+ date.setFullYear(parseInt(year));
13
+ switch (month) {
14
+ case 'Jan':
15
+ month = 0;
16
+ break;
17
+ case 'Feb':
18
+ month = 1;
19
+ break;
20
+ case 'Mar':
21
+ month = 2;
22
+ break;
23
+ case 'Apr':
24
+ month = 3;
25
+ break;
26
+ case 'May':
27
+ month = 4;
28
+ break;
29
+ case 'Jun':
30
+ month = 5;
31
+ break;
32
+ case 'Jul':
33
+ month = 6;
34
+ break;
35
+ case 'Aug':
36
+ month = 7;
37
+ break;
38
+ case 'Sep':
39
+ month = 8;
40
+ break;
41
+ case 'Oct':
42
+ month = 9;
43
+ break;
44
+ case 'Nov':
45
+ month = 10;
46
+ break;
47
+ case 'Dec':
48
+ month = 11;
49
+ break;
50
+ }
51
+ date.setMonth(month);
52
+ date.setUTCDate(parseInt(day));
53
+ date.setHours(parseInt(hours));
54
+ date.setMinutes(parseInt(minutes));
55
+ date.setSeconds(parseInt(seconds));
56
+ return date;
57
+ }