{"_id":"@cao-mei-you-ren/torrent-file","name":"@cao-mei-you-ren/torrent-file","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@cao-mei-you-ren/torrent-file","version":"1.0.0","description":"Parse a torrent file (name, hash, files, pieces)","author":{"name":"CaoMeiYouRen"},"contributors":[{"name":"Scott Cooper","email":"scttcper@gmail.com"},{"name":"CaoMeiYouRen"}],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/CaoMeiYouRen/torrent-file.git"},"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"sideEffects":false,"keywords":[],"scripts":{"lint":"pnpm run '/^(lint:biome|lint:eslint)$/'","lint:biome":"biome check .","lint:eslint":"eslint --ext .ts,.tsx .","lint:fix":"pnpm run '/^(lint:biome|lint:eslint):fix$/'","lint:eslint:fix":"eslint --ext .ts,.tsx . --fix","lint:biome:fix":"biome check . --apply","prepare":"npm run build","build":"tsup","test":"vitest run","test:watch":"vitest","test:ci":"vitest run --coverage --reporter=default --reporter=junit --outputFile=./junit.xml"},"dependencies":{"@cao-mei-you-ren/crypto-hash":"^3.0.0","uint8array-extras":"^1.1.0"},"devDependencies":{"@biomejs/biome":"1.6.0","@ctrl/eslint-config-biome":"2.1.1","@sindresorhus/tsconfig":"5.0.0","@types/node":"20.11.25","@vitest/coverage-v8":"1.3.1","parse-torrent":"11.0.16","tsup":"^8.1.0","typescript":"5.4.2","vitest":"1.3.1"},"publishConfig":{"access":"public"},"release":{"branches":["master"]},"engines":{"node":">=18"},"_id":"@cao-mei-you-ren/torrent-file@1.0.0","gitHead":"4e49d01ba8ad810eae69eb01a4f257c2c0c54532","bugs":{"url":"https://github.com/CaoMeiYouRen/torrent-file/issues"},"homepage":"https://github.com/CaoMeiYouRen/torrent-file#readme","_nodeVersion":"20.10.0","_npmVersion":"10.5.0","dist":{"integrity":"sha512-UPSrDHEWA26oz4HGOneGWdOxLnZ3WAvzQECC1LWbiuLYed1E9mgGijrQT0HS+MzhmzUHwZ3FhEgrU7PC7kTXCA==","shasum":"c0302ba79a21720bd8a8e39529c88d18758ece19","tarball":"https://registry.npmjs.org/@cao-mei-you-ren/torrent-file/-/torrent-file-1.0.0.tgz","fileCount":7,"unpackedSize":30998,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDP8YdzeBOI38dWYw8wpEe/RhejqvyySYHSJDKpWjQ92AIhAO0tHbZmNoDnv5C70QZH4Heb5TdnbdTkPgy0z0UgdTLG"}]},"_npmUser":{"name":"cao-mei-you-ren","email":"caomeiyouren@qq.com"},"directories":{},"maintainers":[{"name":"cao-mei-you-ren","email":"caomeiyouren@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/torrent-file_1.0.0_1720368007132_0.4501966920373148"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-07T16:00:06.995Z","1.0.0":"2024-07-07T16:00:07.277Z","modified":"2024-07-07T16:00:07.584Z"},"maintainers":[{"name":"cao-mei-you-ren","email":"caomeiyouren@qq.com"}],"description":"Parse a torrent file (name, hash, files, pieces)","homepage":"https://github.com/CaoMeiYouRen/torrent-file#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/CaoMeiYouRen/torrent-file.git"},"contributors":[{"name":"Scott Cooper","email":"scttcper@gmail.com"},{"name":"CaoMeiYouRen"}],"author":{"name":"CaoMeiYouRen"},"bugs":{"url":"https://github.com/CaoMeiYouRen/torrent-file/issues"},"license":"MIT","readme":"# torrent-file [![npm](https://badgen.net/npm/v/@ctrl/torrent-file)](https://www.npmjs.com/package/@ctrl/torrent-file) [![coverage](https://badgen.net/codecov/c/github/scttcper/torrent-file)](https://codecov.io/gh/scttcper/torrent-file) [![bundlesize](https://badgen.net/bundlephobia/min/@ctrl/torrent-file)](https://bundlephobia.com/result?p=@ctrl/torrent-file)\n\n> Parse a torrent file and read encoded data. \n\nThis project is based on [parse-torrent](https://www.npmjs.com/package/parse-torrent) and [node-bencode](https://github.com/themasch/node-bencode) to parse the data of a torrent file. This library implements its own [bencode](http://www.bittorrent.org/beps/bep_0003.html) encoder and decoder that does not use `Buffer`.\n\n### Install\n```console\nnpm install @ctrl/torrent-file\n```\n\n### API\n\n##### info\nThe content of the metainfo file.\n```ts\nimport fs from 'fs';\nimport { info } from '@ctrl/torrent-file';\n\nconst torrentInfo = info(fs.readFileSync('myfile'));\nconsole.log({ torrentInfo });\n```\n\n##### files\ndata about the files described in the torrent file, includes hashes of the pieces\n```ts\nimport fs from 'fs';\nimport { files } from '@ctrl/torrent-file';\n\nconst torrentFiles = files(fs.readFileSync('myfile'));\nconsole.log({ torrentFiles });\n```\n\n##### hash\nsha1 of torrent file info. This hash is commenly used by torrent clients as the ID of the torrent. It is async and sha1 encoding is handled by [crypto-hash](https://github.com/sindresorhus/crypto-hash)\n```ts\nimport fs from 'fs';\nimport { hash } from '@ctrl/torrent-file';\n\n(async () => {\n  const torrentHash = await hash(fs.readFileSync('myfile'));\n  console.log({ torrentHash });\n})()\n```\n\n\n### See Also\n[parse-torrent](https://www.npmjs.com/package/parse-torrent) - \"@ctrl/torrent-file\" torrent parsing based very heavily off this project  \n[node-bencode](https://github.com/themasch/node-bencode) - bencoder built into this project heavily based off this project   \n","readmeFilename":"README.md"}