@xhmikosr/downloader 16.1.2 → 16.1.3

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.
Files changed (3) hide show
  1. package/index.js +5 -5
  2. package/package.json +5 -5
  3. package/readme.md +12 -11
package/index.js CHANGED
@@ -2,7 +2,7 @@ import events from 'node:events';
2
2
  import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import process from 'node:process';
5
- import contentDisposition from 'content-disposition';
5
+ import {parse} from 'content-disposition';
6
6
  import archiveType from '@xhmikosr/archive-type';
7
7
  import decompress from '@xhmikosr/decompress';
8
8
  import extName from 'ext-name';
@@ -25,7 +25,7 @@ const getExtFromMime = response => {
25
25
  return null;
26
26
  }
27
27
 
28
- const exts = extName.mime(header);
28
+ const exts = extName.mime(header.split(';')[0].trim());
29
29
 
30
30
  return exts.length === 1 ? exts[0].ext : null;
31
31
  };
@@ -34,7 +34,7 @@ const getFilename = async (response, data) => {
34
34
  const header = response.headers['content-disposition'];
35
35
 
36
36
  if (header) {
37
- const parsed = contentDisposition.parse(header);
37
+ const parsed = parse(header);
38
38
 
39
39
  if (parsed.parameters?.filename) {
40
40
  return parsed.parameters.filename;
@@ -55,8 +55,8 @@ const getFilename = async (response, data) => {
55
55
  return filename;
56
56
  };
57
57
 
58
- const filterEvents = async (name, listener) => {
59
- for await (const [message] of events.on(name, listener)) {
58
+ const filterEvents = async (emitter, event) => {
59
+ for await (const [message] of events.on(emitter, event)) {
60
60
  if (message) {
61
61
  return message;
62
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xhmikosr/downloader",
3
- "version": "16.1.2",
3
+ "version": "16.1.3",
4
4
  "description": "Download and extract files",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,8 +43,8 @@
43
43
  ],
44
44
  "dependencies": {
45
45
  "@xhmikosr/archive-type": "^8.0.1",
46
- "@xhmikosr/decompress": "^11.1.1",
47
- "content-disposition": "^1.1.0",
46
+ "@xhmikosr/decompress": "^11.1.3",
47
+ "content-disposition": "^2.0.1",
48
48
  "ext-name": "^5.0.0",
49
49
  "file-type": "^21.3.4",
50
50
  "filenamify": "^7.0.1",
@@ -52,10 +52,10 @@
52
52
  "got": "^14.6.6"
53
53
  },
54
54
  "devDependencies": {
55
- "@xhmikosr/decompress-unzip": "^8.1.0",
55
+ "@xhmikosr/decompress-unzip": "^8.1.1",
56
56
  "ava": "^7.0.0",
57
57
  "c8": "^11.0.0",
58
- "nock": "^14.0.12",
58
+ "nock": "^14.0.15",
59
59
  "xo": "^2.0.2"
60
60
  },
61
61
  "xo": {
package/readme.md CHANGED
@@ -1,17 +1,15 @@
1
- # download [![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)
1
+ # @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)
2
2
 
3
3
  > Download and extract files
4
4
 
5
5
  *See [download-cli](https://github.com/kevva/download-cli) for the command-line version.*
6
6
 
7
-
8
7
  ## Install
9
8
 
10
9
  ```sh
11
10
  npm install @xhmikosr/downloader
12
11
  ```
13
12
 
14
-
15
13
  ## Usage
16
14
 
17
15
  ```js
@@ -23,25 +21,28 @@ import download from '@xhmikosr/downloader';
23
21
 
24
22
  fs.writeFileSync('dist/foo.jpg', await download('http://unicorn.com/foo.jpg'));
25
23
 
26
- download('unicorn.com/foo.jpg').pipe(fs.createWriteStream('dist/foo.jpg'));
24
+ download('http://unicorn.com/foo.jpg').pipe(fs.createWriteStream('dist/foo.jpg'));
27
25
 
28
26
  await Promise.all([
29
- 'unicorn.com/foo.jpg',
30
- 'cats.com/dancing.gif'
27
+ 'http://unicorn.com/foo.jpg',
28
+ 'http://cats.com/dancing.gif'
31
29
  ].map(url => download(url, 'dist')));
32
30
  })();
33
31
  ```
34
32
 
35
33
  ### Proxies
36
34
 
37
- To work with proxies, read the [`got documentation`](https://github.com/sindresorhus/got#proxies).
35
+ To work with proxies, read the [`got documentation`](https://github.com/sindresorhus/got/blob/main/documentation/tips.md#proxying).
36
+
37
+ ### SSL
38
38
 
39
+ TLS 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).
39
40
 
40
41
  ## API
41
42
 
42
43
  ### download(url, destination?, options?)
43
44
 
44
- Returns 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#streams-1).
45
+ Returns 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).
45
46
 
46
47
  #### url
47
48
 
@@ -53,7 +54,7 @@ URL to download.
53
54
 
54
55
  Type: `string`
55
56
 
56
- Path to where your file will be written.
57
+ Directory to save the file to.
57
58
 
58
59
  #### options
59
60
 
@@ -67,14 +68,14 @@ Same options as [`got`](https://github.com/sindresorhus/got#options).
67
68
 
68
69
  Same options as [`decompress`](https://github.com/XhmikosR/decompress#options).
69
70
 
70
- ##### extract
71
+ ##### options.extract
71
72
 
72
73
  * Type: `boolean`
73
74
  * Default: `false`
74
75
 
75
76
  If set to `true`, try extracting the file using [`decompress`](https://github.com/XhmikosR/decompress).
76
77
 
77
- ##### filename
78
+ ##### options.filename
78
79
 
79
80
  Type: `string`
80
81