{"name":"@xhmikosr/downloader","version":"15.1.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@15.1.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":{"promise/prefer-await-to-then":"off","unicorn/prevent-abbreviations":"off"}},"dist":{"shasum":"e8b1a7b30f822275a7f34cac0aaffb01bcf46bef","tarball":"http://registry-npm.ywwl.com/@xhmikosr/downloader/download/@xhmikosr/downloader-15.1.0.tgz","fileCount":4,"integrity":"sha512-poDSeRx/m3OFqr3dUuj9HvV0vppOw3SUd10uNJaqp8D9swzk77LmH+bmyWi4FjBQEXCwh32sp8fMvR/SOgOFLA==","signatures":[{"sig":"MEUCIBo/6BI8bJ22IovFsn6ojw3W1b+mEjsESPskqw3n4E9/AiEA7FEdSFOUgVZmbZYvvK+zg5s4iXatd41trmZ3dhSWYF4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6991,"size":3061,"noattachment":false,"key":"/@xhmikosr/downloader/-/@xhmikosr/downloader-15.1.0.tgz"},"main":"index.js","type":"module","engines":{"node":">=18"},"exports":{".":"./index.js"},"gitHead":"e6d78c8ab133e9041143808f48d648030950020d","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":"10.9.2","description":"Download and extract files","directories":{},"_nodeVersion":"22.17.1","dependencies":{"got":"^13.0.0","defaults":"^3.0.0","ext-name":"^5.0.0","file-type":"^20.5.0","filenamify":"^6.0.0","get-stream":"^6.0.1","content-disposition":"^0.5.4","@xhmikosr/decompress":"^10.1.0","@xhmikosr/archive-type":"^7.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","xo":"^0.60.0","ava":"~6.2.0","nock":"^14.0.6","is-zip":"^1.0.0","path-exists":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/downloader_15.1.0_1753192268867_0.7729523427180438","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":1753192269041,"_cnpm_publish_time":1753192269041,"dist-tags":{"latest":"16.3.1"}}