{"name":"@xhmikosr/downloader","version":"16.0.1","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.0.1","maintainers":[{"name":"xhmikosr","email":"xhmikosr@gmail.com"}],"homepage":"https://github.com/XhmikosR/download#readme","bugs":{"url":"https://github.com/XhmikosR/download/issues"},"xo":{"rules":{"promise/prefer-await-to-then":"off","unicorn/prevent-abbreviations":"off"}},"dist":{"shasum":"65cb0cf5af7ac6a721e1c5d9b940449b4c6762a9","tarball":"http://registry-npm.ywwl.com/@xhmikosr/downloader/download/@xhmikosr/downloader-16.0.1.tgz","fileCount":4,"integrity":"sha512-K9SzV27xTT1MA2DcGXXNrmAdvXBEN4TB+rg8fnPytlHRp54912AMPv4kd0k6DenczcrjEkYsa9AiFhPO/CEv0Q==","signatures":[{"sig":"MEYCIQDAvvnz5NLJ9Jzc2mGT2hwZUxtEJQ65CZDkiUeoCU3YmwIhAK/Jb1hjU0g6ICFBsuilfQ/JW7cnYYkm8dHgM3iefw7I","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7206,"size":3164,"noattachment":false,"key":"/@xhmikosr/downloader/-/@xhmikosr/downloader-16.0.1.tgz"},"main":"index.js","type":"module","engines":{"node":">=20"},"exports":{".":"./index.js"},"gitHead":"c6ef4d952489859d2783e9f7521efe24cb4e79e5","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.8.0","description":"Download and extract files","directories":{},"_nodeVersion":"24.13.1","dependencies":{"got":"^14.6.6","defaults":"^2.0.2","ext-name":"^5.0.0","file-type":"^21.3.0","filenamify":"^7.0.1","get-stream":"^6.0.1","content-disposition":"^1.0.1","@xhmikosr/decompress":"^11.0.2","@xhmikosr/archive-type":"^8.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","xo":"^1.2.3","ava":"^6.4.1","nock":"^14.0.11","is-zip":"^1.0.0","@xhmikosr/decompress-unzip":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/downloader_16.0.1_1771958449160_0.4063926034809968","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":1771958449318,"_cnpm_publish_time":1771958449318,"dist-tags":{"latest":"16.3.1"}}