icanhazip-client 1.0.0 → 1.2.0

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.
Files changed (2) hide show
  1. package/README.md +43 -0
  2. package/package.json +21 -8
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
  ![npm](https://img.shields.io/npm/v/icanhazip-client)
3
3
  ![downloads](https://img.shields.io/npm/dw/icanhazip-client)
4
4
  ![license](https://img.shields.io/npm/l/icanhazip-client)
5
+ ![NPM Unpacked Size](https://img.shields.io/npm/unpacked-size/icanhazip-client)
5
6
  # Icanhazip Client
6
7
  A lightweight JavaScript/TypeScript client for retrieving public IP information using the icanhazip service. This package is **ESM-only** and works in modern browsers and Node.js 18+ environments that support the Fetch API. Provides support for [https://github.com/runvnc/icanhazip](https://github.com/runvnc/icanhazip)
7
8
 
@@ -58,5 +59,47 @@ try {
58
59
  }
59
60
  ```
60
61
 
62
+ ### 📗 Test Coverage
63
+
64
+ ```
65
+ PASS src/get-full-trace/test/index.test.ts
66
+ getFullTrace
67
+ ✓ throws when global fetch is unavailable
68
+ ✓ throws when fetch response is not ok
69
+ ✓ returns parsed trace data
70
+ ✓ ignores malformed lines
71
+ ✓ targets the trace endpoint
72
+ PASS src/get-ipv6/test/index.test.ts
73
+ getIPV6
74
+ ✓ throws when global fetch is unavailable
75
+ ✓ throws when fetch response is not ok
76
+ ✓ returns trimmed ipv6 string
77
+ ✓ targets the ipv6 endpoint
78
+ PASS src/get-ipv4/test/index.test.ts
79
+ getIPV4
80
+ ✓ throws when global fetch is unavailable
81
+ ✓ throws when fetch response is not ok
82
+ ✓ returns trimmed ipv4 string
83
+ ✓ targets the ipv4 endpoint
84
+
85
+ Test Suites: 3 passed, 3 total
86
+ Tests: 13 passed, 13 total
87
+ Snapshots: 0 total
88
+ ```
89
+
90
+ ```
91
+ ----------------|---------|----------|---------|---------|-------------------
92
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
93
+ ----------------|---------|----------|---------|---------|-------------------
94
+ All files | 100 | 100 | 100 | 100 |
95
+ get-full-trace | 100 | 100 | 100 | 100 |
96
+ index.ts | 100 | 100 | 100 | 100 |
97
+ get-ipv4 | 100 | 100 | 100 | 100 |
98
+ index.ts | 100 | 100 | 100 | 100 |
99
+ get-ipv6 | 100 | 100 | 100 | 100 |
100
+ index.ts | 100 | 100 | 100 | 100 |
101
+ ----------------|---------|----------|---------|---------|-------------------
102
+ ```
103
+
61
104
  ### Support
62
105
  Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "icanhazip-client",
3
3
  "description": "Tiny fetch-based client for icanhazip.com (IPv4, IPv6, trace)",
4
4
  "type": "module",
5
- "version": "1.0.0",
5
+ "version": "1.2.0",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
@@ -12,23 +12,36 @@
12
12
  }
13
13
  },
14
14
  "scripts": {
15
- "test": "echo \"Error: no test specified\" && exit 1"
16
- },
17
- "files": ["dist"],
18
- "scripts": {
15
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
16
+ "prebuild": "npm run clean",
19
17
  "build": "tsc",
20
- "prepublishOnly": "npm run build"
18
+ "prepublishOnly": "npm run build",
19
+ "test": "jest",
20
+ "test:watch": "jest --watch",
21
+ "test:coverage": "jest --coverage --verbose"
21
22
  },
22
- "keywords": ["ip", "ipv4", "ipv6", "icanhazip", "icanhazip-client"],
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "keywords": [
27
+ "ip",
28
+ "ipv4",
29
+ "ipv6",
30
+ "icanhazip",
31
+ "icanhazip-client"
32
+ ],
23
33
  "license": "MIT",
24
34
  "devDependencies": {
35
+ "@types/jest": "^29.5.14",
36
+ "jest": "^29.7.0",
37
+ "jest-environment-jsdom": "^30.4.1",
38
+ "ts-jest": "^29.4.6",
25
39
  "typescript": "^5.9.3"
26
40
  },
27
41
  "repository": {
28
42
  "type": "git",
29
43
  "url": "https://github.com/NPM-Workbench/icanhazip-client"
30
44
  },
31
- "license": "MIT",
32
45
  "homepage": "https://github.com/NPM-Workbench/icanhazip-client",
33
46
  "bugs": {
34
47
  "url": "https://github.com/NPM-Workbench/icanhazip-client/issues"