@ctrl/magnet-link 4.0.2 → 4.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.
package/README.md CHANGED
@@ -4,9 +4,10 @@
4
4
 
5
5
  Port of [webtorrent/magnet-uri](https://github.com/webtorrent/magnet-uri) by [feross](https://github.com/feross) that uses fewer dependencies in typescript
6
6
 
7
- __Demo__: https://magnet-link.vercel.app
7
+ **Demo**: https://magnet-link.vercel.app
8
8
 
9
9
  ### Install
10
+
10
11
  ```console
11
12
  npm install @ctrl/magnet-link
12
13
  ```
@@ -14,15 +15,19 @@ npm install @ctrl/magnet-link
14
15
  ### Use
15
16
 
16
17
  #### Encode
18
+
17
19
  ```ts
18
20
  import { magnetDecode } from '@ctrl/magnet-link';
19
21
 
20
- const uri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337';
22
+ const uri =
23
+ 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337';
21
24
  const parsed = magnetDecode(uri);
22
- console.log(parsed.dn) // "Leaves of Grass by Walt Whitman.epub"
23
- console.log(parsed.infoHash) // "d2474e86c95b19b8bcfdb92bc12c9d44667cfa36"
25
+ console.log(parsed.dn); // "Leaves of Grass by Walt Whitman.epub"
26
+ console.log(parsed.infoHash); // "d2474e86c95b19b8bcfdb92bc12c9d44667cfa36"
24
27
  ```
28
+
25
29
  The entire parsed object
30
+
26
31
  ```json
27
32
  {
28
33
  "xt": "urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36",
@@ -75,6 +80,7 @@ You can also use convenience key names like name (dn), infoHash (xt), infoHashIn
75
80
  ```
76
81
 
77
82
  ### See Also
83
+
84
+ - magnet-uri https://github.com/webtorrent/magnet-uri
78
85
  - magnet uri spec http://www.bittorrent.org/beps/bep_0053.html
79
86
  - more spec http://www.bittorrent.org/beps/bep_0009.html
80
- - magnet-uri https://github.com/webtorrent/magnet-uri
package/dist/src/index.js CHANGED
@@ -29,7 +29,6 @@ export function magnetDecode(uri) {
29
29
  return;
30
30
  }
31
31
  result[key] = [r, val];
32
- // eslint-disable-next-line no-useless-return
33
32
  return;
34
33
  });
35
34
  if (result.xt) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/magnet-link",
3
- "version": "4.0.2",
3
+ "version": "4.2.0",
4
4
  "description": "Parse a magnet URI into an object",
5
5
  "author": "Scott Cooper <scttcper@gmail.com>",
6
6
  "homepage": "https://magnet-link.vercel.app",
@@ -23,12 +23,8 @@
23
23
  "dev": "npm run demo:watch",
24
24
  "demo:build": "npm run build --workspace=demo",
25
25
  "demo:watch": "npm run dev --workspace=demo",
26
- "lint": "pnpm run '/^(lint:biome|lint:eslint)$/'",
27
- "lint:biome": "biome check .",
28
- "lint:eslint": "eslint --ext .ts,.tsx .",
29
- "lint:fix": "pnpm run '/^(lint:biome|lint:eslint):fix$/'",
30
- "lint:eslint:fix": "eslint --ext .ts,.tsx . --fix",
31
- "lint:biome:fix": "biome check . --apply",
26
+ "lint": "oxlint . && prettier --check . --experimental-cli",
27
+ "lint:fix": "oxlint . --fix && prettier --write . --log-level=error --experimental-cli",
32
28
  "prepare": "npm run build",
33
29
  "build": "tsc",
34
30
  "test": "vitest run",
@@ -36,17 +32,25 @@
36
32
  "test:ci": "vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml"
37
33
  },
38
34
  "dependencies": {
39
- "rfc4648": "^1.5.3",
40
- "uint8array-extras": "^1.1.0"
35
+ "rfc4648": "^1.5.4",
36
+ "uint8array-extras": "^1.5.0"
41
37
  },
42
38
  "devDependencies": {
43
- "@biomejs/biome": "1.6.0",
44
- "@ctrl/eslint-config-biome": "2.1.1",
45
- "@sindresorhus/tsconfig": "5.0.0",
46
- "@types/node": "20.11.25",
47
- "@vitest/coverage-v8": "1.3.1",
48
- "typescript": "5.4.2",
49
- "vitest": "1.3.1"
39
+ "@ctrl/oxlint-config": "1.2.6",
40
+ "@sindresorhus/tsconfig": "8.0.1",
41
+ "@types/node": "24.6.1",
42
+ "@vitest/coverage-v8": "3.2.4",
43
+ "oxlint": "1.19.0",
44
+ "prettier": "3.6.2",
45
+ "typescript": "5.9.3",
46
+ "vitest": "3.2.4"
47
+ },
48
+ "prettier": {
49
+ "singleQuote": true,
50
+ "trailingComma": "all",
51
+ "arrowParens": "avoid",
52
+ "semi": true,
53
+ "printWidth": 100
50
54
  },
51
55
  "workspaces": [
52
56
  "demo"