@anmiles/downloader 2.0.1 → 2.0.2
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.
- package/.eslintrc.js +1 -88
- package/CHANGELOG.md +6 -2
- package/dist/lib/downloader.d.ts +3 -2
- package/dist/lib/downloader.js.map +1 -1
- package/package.json +3 -2
- package/src/lib/downloader.ts +4 -2
- package/file +0 -0
package/.eslintrc.js
CHANGED
|
@@ -1,93 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root : true,
|
|
3
3
|
extends : [
|
|
4
|
-
'eslint
|
|
5
|
-
'plugin:jest/recommended',
|
|
4
|
+
'./node_modules/@anmiles/eslint-config/.eslintrc.js',
|
|
6
5
|
],
|
|
7
|
-
parser : '@typescript-eslint/parser',
|
|
8
|
-
parserOptions : {
|
|
9
|
-
ecmaVersion : 2019,
|
|
10
|
-
sourceType : 'module',
|
|
11
|
-
},
|
|
12
|
-
plugins : [
|
|
13
|
-
'@typescript-eslint',
|
|
14
|
-
'align-assignments',
|
|
15
|
-
'import',
|
|
16
|
-
'jest',
|
|
17
|
-
],
|
|
18
|
-
env : {
|
|
19
|
-
node : true,
|
|
20
|
-
jest : true,
|
|
21
|
-
},
|
|
22
|
-
ignorePatterns : [
|
|
23
|
-
'**/node_modules/',
|
|
24
|
-
'coverage/',
|
|
25
|
-
'dist/',
|
|
26
|
-
],
|
|
27
|
-
rules : {
|
|
28
|
-
'no-unused-vars' : [ 'off' ],
|
|
29
|
-
'@typescript-eslint/no-redeclare' : [ 'error' ],
|
|
30
|
-
'@typescript-eslint/no-unused-vars' : [ 'error' ],
|
|
31
|
-
'align-assignments/align-assignments' : [ 'error' ],
|
|
32
|
-
'array-bracket-spacing' : [ 'error', 'always' ],
|
|
33
|
-
'arrow-body-style' : [ 'error' ],
|
|
34
|
-
'arrow-parens' : [ 'error' ],
|
|
35
|
-
'arrow-spacing' : [ 'error' ],
|
|
36
|
-
'block-spacing' : [ 'error' ],
|
|
37
|
-
'brace-style' : [ 'error' ],
|
|
38
|
-
'camelcase' : [ 'error' ],
|
|
39
|
-
'comma-dangle' : [ 'error', 'always-multiline' ],
|
|
40
|
-
'comma-spacing' : [ 'error' ],
|
|
41
|
-
'comma-style' : [ 'error' ],
|
|
42
|
-
'complexity' : [ 'error' ],
|
|
43
|
-
'computed-property-spacing' : [ 'error', 'never' ],
|
|
44
|
-
'curly' : [ 'error' ],
|
|
45
|
-
'dot-location' : [ 'error', 'property' ],
|
|
46
|
-
'eol-last' : [ 'error' ],
|
|
47
|
-
'func-call-spacing' : [ 'error' ],
|
|
48
|
-
'func-style' : [ 'error', 'declaration', { allowArrowFunctions : true } ],
|
|
49
|
-
'generator-star-spacing' : [ 'error', 'neither' ],
|
|
50
|
-
'import/order' : [ 'error', { groups : [ 'builtin', 'external', 'unknown', 'internal', 'parent', 'sibling', 'index' ] } ],
|
|
51
|
-
'indent' : [ 'error', 'tab', { SwitchCase : 1 } ],
|
|
52
|
-
'jest/no-standalone-expect' : [ 'error' ],
|
|
53
|
-
'key-spacing' : [ 'error', { beforeColon : true, afterColon : true, align : 'colon' } ],
|
|
54
|
-
'keyword-spacing' : [ 'error' ],
|
|
55
|
-
'linebreak-style' : [ 'error', 'unix' ],
|
|
56
|
-
'max-params' : [ 'error', { max : 5 } ],
|
|
57
|
-
'new-parens' : [ 'error' ],
|
|
58
|
-
'no-eval' : [ 'error' ],
|
|
59
|
-
'no-extra-bind' : [ 'error' ],
|
|
60
|
-
'no-floating-decimal' : [ 'error' ],
|
|
61
|
-
'no-implied-eval' : [ 'error' ],
|
|
62
|
-
'no-loop-func' : [ 'error' ],
|
|
63
|
-
'no-mixed-spaces-and-tabs' : [ 'error', 'smart-tabs' ],
|
|
64
|
-
'no-multiple-empty-lines' : [ 'error', { max : 1, maxEOF : 1, maxBOF : 0 } ],
|
|
65
|
-
'no-redeclare' : [ 'off' ],
|
|
66
|
-
'no-return-await' : [ 'error' ],
|
|
67
|
-
'no-trailing-spaces' : [ 'error' ],
|
|
68
|
-
'no-useless-rename' : [ 'error' ],
|
|
69
|
-
'no-var' : [ 'error' ],
|
|
70
|
-
'no-whitespace-before-property' : [ 'error' ],
|
|
71
|
-
'object-curly-spacing' : [ 'error', 'always' ],
|
|
72
|
-
'object-property-newline' : [ 'error', { allowMultiplePropertiesPerLine : true } ],
|
|
73
|
-
'object-shorthand' : [ 'error' ],
|
|
74
|
-
'operator-linebreak' : [ 'error', 'before' ],
|
|
75
|
-
'prefer-const' : [ 'error' ],
|
|
76
|
-
'prefer-numeric-literals' : [ 'error' ],
|
|
77
|
-
'prefer-spread' : [ 'error' ],
|
|
78
|
-
'prefer-template' : [ 'error' ],
|
|
79
|
-
'quote-props' : [ 'error', 'consistent-as-needed' ],
|
|
80
|
-
'quotes' : [ 'error', 'single', { avoidEscape : true } ],
|
|
81
|
-
'semi-spacing' : [ 'error' ],
|
|
82
|
-
'semi' : [ 'error' ],
|
|
83
|
-
'space-before-blocks' : [ 'error' ],
|
|
84
|
-
'space-before-function-paren' : [ 'error', { anonymous : 'never', named : 'never', asyncArrow : 'always' } ],
|
|
85
|
-
'space-in-parens' : [ 'error' ],
|
|
86
|
-
'space-infix-ops' : [ 'error' ],
|
|
87
|
-
'space-unary-ops' : [ 'error' ],
|
|
88
|
-
'spaced-comment' : [ 'error' ],
|
|
89
|
-
'template-curly-spacing' : [ 'error' ],
|
|
90
|
-
'yield-star-spacing' : [ 'error' ],
|
|
91
|
-
'yoda' : [ 'error' ],
|
|
92
|
-
},
|
|
93
6
|
};
|
package/CHANGELOG.md
CHANGED
|
@@ -5,11 +5,15 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [2.0.2](../../tags/v2.0.2) - 2023-05-06
|
|
9
|
+
### Changed
|
|
10
|
+
- Use shared eslint config
|
|
11
|
+
|
|
12
|
+
## [2.0.1](../../tags/v2.0.1) - 2023-05-04
|
|
9
13
|
### Changed
|
|
10
14
|
- Use `event-emitter` to mock subscriptions on request/response
|
|
11
15
|
|
|
12
|
-
## [
|
|
16
|
+
## [2.0.0](../../tags/v2.0.0) - 2023-05-03
|
|
13
17
|
### Changed
|
|
14
18
|
- Ready to release
|
|
15
19
|
|
package/dist/lib/downloader.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ declare const _default: {
|
|
|
6
6
|
downloadJSON: typeof downloadJSON;
|
|
7
7
|
};
|
|
8
8
|
export default _default;
|
|
9
|
+
type BufferEncoding = Parameters<Buffer['toString']>[0];
|
|
9
10
|
declare function download(url: string): Promise<Buffer>;
|
|
10
11
|
declare function download(url: string, file: string): Promise<void>;
|
|
11
|
-
declare function downloadString(url: string, encoding?:
|
|
12
|
-
declare function downloadJSON(url: string, encoding?:
|
|
12
|
+
declare function downloadString(url: string, encoding?: BufferEncoding): Promise<string>;
|
|
13
|
+
declare function downloadJSON(url: string, encoding?: BufferEncoding): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"downloader.js","sourceRoot":"","sources":["../../src/lib/downloader.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,4DAA+B;AAE/B,8DAAsC;AAGtC,kBAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"downloader.js","sourceRoot":"","sources":["../../src/lib/downloader.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,4DAA+B;AAE/B,8DAAsC;AAGtC,kBAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AAM1D,SAAS,QAAQ,CAAC,GAAW,EAAE,IAAa;IAC3C,OAAO,IAAI,OAAO,CAAgB,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M,CAAC,cAAc,GAAG,uBAAuB,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AApDQ,4BAAQ;AAsDjB,KAAK,UAAU,cAAc,CAAC,GAAW,EAAE,WAA2B,MAAM;IAC3E,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACjC,MAAM,oBAAoB,QAAQ,EAAE,CAAC;KACrC;IAED,MAAM,MAAM,GAAG,MAAM,oBAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9C,OAAO,oBAAK,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AA7DkB,wCAAc;AA+DjC,KAAK,UAAU,YAAY,CAAC,GAAW,EAAE,WAA2B,MAAM;IACzE,MAAM,IAAI,GAAG,MAAM,oBAAU,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAlEkC,oCAAY"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anmiles/downloader",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Wrapper for downloading data as string, buffer or complex types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"download",
|
|
@@ -30,11 +30,12 @@
|
|
|
30
30
|
"iconv-lite": "^0.6.3"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
+
"@anmiles/eslint-config": "^1.0.4",
|
|
33
34
|
"@types/event-emitter": "^0.3.3",
|
|
34
35
|
"@types/jest": "^29.5.1",
|
|
35
36
|
"@typescript-eslint/eslint-plugin": "^5.59.2",
|
|
36
37
|
"@typescript-eslint/parser": "^5.59.2",
|
|
37
|
-
"eslint": "^8.
|
|
38
|
+
"eslint": "^8.40.0",
|
|
38
39
|
"eslint-plugin-align-assignments": "^1.1.2",
|
|
39
40
|
"eslint-plugin-import": "^2.27.5",
|
|
40
41
|
"eslint-plugin-jest": "^27.2.1",
|
package/src/lib/downloader.ts
CHANGED
|
@@ -8,6 +8,8 @@ import downloader from './downloader';
|
|
|
8
8
|
export { download, downloadString, downloadJSON };
|
|
9
9
|
export default { download, downloadString, downloadJSON };
|
|
10
10
|
|
|
11
|
+
type BufferEncoding = Parameters<Buffer['toString']>[0];
|
|
12
|
+
|
|
11
13
|
function download(url: string): Promise<Buffer>;
|
|
12
14
|
function download(url: string, file: string): Promise<void>;
|
|
13
15
|
function download(url: string, file?: string): Promise<Buffer | void> {
|
|
@@ -57,7 +59,7 @@ function download(url: string, file?: string): Promise<Buffer | void> {
|
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
async function downloadString(url: string, encoding:
|
|
62
|
+
async function downloadString(url: string, encoding: BufferEncoding = 'utf8') {
|
|
61
63
|
if (!Buffer.isEncoding(encoding)) {
|
|
62
64
|
throw `Unknown encoding ${encoding}`;
|
|
63
65
|
}
|
|
@@ -66,7 +68,7 @@ async function downloadString(url: string, encoding: Parameters<Buffer['toString
|
|
|
66
68
|
return iconv.decode(buffer, encoding);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
async function downloadJSON(url: string, encoding:
|
|
71
|
+
async function downloadJSON(url: string, encoding: BufferEncoding = 'utf8') {
|
|
70
72
|
const json = await downloader.downloadString(url, encoding);
|
|
71
73
|
return JSON.parse(json);
|
|
72
74
|
}
|
package/file
DELETED
|
File without changes
|