{"name":"@xhmikosr/downloader","version":"16.3.0","keywords":["download","extract","http","request","url"],"author":{"url":"https://github.com/kevva","name":"Kevin Mårtensson","email":"kevinmartensson@gmail.com"},"license":"MIT","_id":"@xhmikosr/downloader@16.3.0","maintainers":[{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"homepage":"https://github.com/XhmikosR/download#readme","bugs":{"url":"https://github.com/XhmikosR/download/issues"},"xo":{"rules":{"require-unicode-regexp":"off","promise/prefer-await-to-then":"off","unicorn/prevent-abbreviations":"off"}},"dist":{"shasum":"d506bd7d36b8dcfe91d3c3572642e3e35e8c6762","tarball":"http://registry-npm.ywwl.com/@xhmikosr/downloader/download/@xhmikosr/downloader-16.3.0.tgz","fileCount":4,"integrity":"sha512-DF6qHkozD2SiE6yOUOUk8JWpLEPwT4vKZRsDeOZX6ekKDUO/LyeauxOO+H8j3AuRT23YWIx+7Thv7f5SoPS3lQ==","signatures":[{"sig":"MEUCIHE3g4zF2tC8/BWgAefHmbyrKGrR3g+ajpnwgZivTHStAiEAsWnQF3ebDu0QCNbLgvTrW2saYG3vky08mru9H/zp2/k=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9057,"size":3922,"noattachment":false,"key":"/@xhmikosr/downloader/-/@xhmikosr/downloader-16.3.0.tgz"},"main":"index.js","type":"module","engines":{"node":">=20"},"exports":{".":"./index.js"},"gitHead":"29ecc08361af053b67e4d4f6465dc9f5c4216365","scripts":{"xo":"xo","ava":"ava","fix":"xo --fix","lint":"xo","test":"npm run xo && npm run ava","test-ci":"c8 ava"},"_npmUser":{"name":"xhmikosr","email":"xhmikosr@gmail.com"},"repository":{"url":"git+https://github.com/XhmikosR/download.git","type":"git"},"_npmVersion":"11.16.0","description":"Download and extract files","directories":{},"_nodeVersion":"24.18.0","allowScripts":{"unrs-resolver@1.11.1":true},"dependencies":{"got":"^14.6.6","ext-name":"^5.0.0","file-type":"^21.3.4","filenamify":"^7.0.2","content-disposition":"^2.0.1","@xhmikosr/decompress":"^11.1.3","@xhmikosr/archive-type":"^8.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^11.0.0","xo":"^2.0.2","ava":"^7.0.0","nock":"^14.0.16","@xhmikosr/decompress-unzip":"^8.2.1"},"_npmOperationalInternal":{"tmp":"tmp/downloader_16.3.0_1784217067329_0.45559847039063484","host":"s3://npm-registry-packages-npm-production"},"readme":"# @xhmikosr/downloader [![npm version](https://img.shields.io/npm/v/@xhmikosr/downloader?logo=npm&logoColor=fff)](https://www.npmjs.com/package/@xhmikosr/downloader) [![CI Status](https://img.shields.io/github/actions/workflow/status/XhmikosR/download/ci.yml?branch=master&label=CI&logo=github)](https://github.com/XhmikosR/download/actions/workflows/ci.yml?query=branch%3Amaster)\n\n> Download and extract files\n\n*See [download-cli](https://github.com/kevva/download-cli) for the command-line version.*\n\n## Install\n\n```sh\nnpm install @xhmikosr/downloader\n```\n\n## Usage\n\n```js\nimport fs from 'node:fs';\nimport download from '@xhmikosr/downloader';\n\n(async () => {\n\tawait download('http://unicorn.com/foo.jpg', 'dist');\n\n\tfs.writeFileSync('dist/foo.jpg', await download('http://unicorn.com/foo.jpg'));\n\n\tdownload('http://unicorn.com/foo.jpg').pipe(fs.createWriteStream('dist/foo.jpg'));\n\n\tawait Promise.all([\n\t\t'http://unicorn.com/foo.jpg',\n\t\t'http://cats.com/dancing.gif'\n\t].map(url => download(url, 'dist')));\n})();\n```\n\n### Proxies\n\nTo work with proxies, read the [`got documentation`](https://github.com/sindresorhus/got/blob/main/documentation/tips.md#proxying).\n\n### SSL\n\nTLS certificate verification is enabled by default. It honors npm's [`strict-ssl`](https://docs.npmjs.com/cli/v11/using-npm/config#strict-ssl) config, so running `npm config set strict-ssl false` disables it for self-signed certificates or proxy setups. Override per call with [`options.got.https.rejectUnauthorized`](https://github.com/sindresorhus/got/blob/v14.6.6/documentation/5-https.md).\n\n## API\n\n### download(url, destination?, options?)\n\nReturns both a `Promise<Buffer>` and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex) with [additional events](https://github.com/sindresorhus/got/blob/main/documentation/3-streams.md#events).\n\n#### url\n\nType: `string`\n\nURL to download.\n\n#### destination\n\nType: `string`\n\nDirectory to save the file to.\n\n#### options\n\n##### options.got\n\nType: `Object`\n\nSame options as [`got`](https://github.com/sindresorhus/got#options).\n\n##### options.decompress\n\nSame options as [`decompress`](https://github.com/XhmikosR/decompress#options).\n\n##### options.extract\n\n* Type: `boolean`\n* Default: `false`\n\nIf set to `true`, try extracting the file using [`decompress`](https://github.com/XhmikosR/decompress).\n\n##### options.filename\n\nType: `string`\n\nName of the saved file.\n\n##### options.hash\n\nType: `string`\n\nExpected hash of the downloaded data as `\"<algorithm>:<hex>\"`, checked before it's extracted or written. A mismatch throws. `algorithm` is any digest [`crypto.createHash`](https://nodejs.org/api/crypto.html#cryptocreatehashalgorithm-options) accepts.\n\n```js\nawait download('http://unicorn.com/foo.tar.gz', 'dist', {\n\thash: 'sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08'\n});\n```\n","publish_time":1784217067493,"_cnpm_publish_time":1784217067493,"dist-tags":{"latest":"16.3.1"}}