koa-files 1.0.2 → 2.1.0

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/typings/Send.d.ts CHANGED
@@ -4,82 +4,79 @@
4
4
  * @author nuintun
5
5
  */
6
6
  import { Context } from 'koa';
7
- export declare type Ignore = false | ((path: string) => boolean);
8
7
  export interface Options {
9
- acceptRanges?: boolean;
10
- cacheControl?: boolean;
11
- etag?: boolean;
12
- ignore?: Ignore;
13
- immutable?: boolean;
14
- lastModified?: boolean;
15
- maxAge?: number;
8
+ etag?: boolean;
9
+ cacheControl?: string;
10
+ acceptRanges?: boolean;
11
+ lastModified?: boolean;
12
+ ignore?: (path: string) => boolean;
16
13
  }
17
14
  /**
18
15
  * @class Send
19
16
  */
20
17
  export default class Send {
21
- private ctx;
22
- private root;
23
- private options;
24
- private path;
25
- /**
26
- * @constructor
27
- * @param {Context} ctx
28
- * @param {string} root
29
- * @param {Options} options
30
- */
31
- constructor(ctx: Context, root: string, options: Options);
32
- /**
33
- * @method isConditionalGET
34
- * @returns {boolean}
35
- */
36
- private isConditionalGET;
37
- /**
38
- * @method isPreconditionFailure
39
- * @returns {boolean}
40
- */
41
- private isPreconditionFailure;
42
- /**
43
- * @method isRangeFresh
44
- * @returns {boolean}
45
- */
46
- private isRangeFresh;
47
- /**
48
- * @method isIgnore
49
- * @param {string} path
50
- * @returns {boolean}
51
- */
52
- private isIgnore;
53
- /**
54
- * @method parseRange
55
- * @param {Stats} stats
56
- * @returns {Ranges}
57
- */
58
- private parseRange;
59
- /**
60
- * @method setupHeaders
61
- * @param {string} path
62
- * @param {Stats} stats
63
- */
64
- private setupHeaders;
65
- /**
66
- * @method read
67
- * @param {string} path
68
- * @param {Range} range
69
- * @param {PassThrough} buffer
70
- * @param {boolean} end
71
- * @returns {Promise<true>}
72
- */
73
- private read;
74
- /**
75
- * @method send
76
- * @param {string} path
77
- * @param {Range[]} ranges
78
- */
79
- private send;
80
- /**
81
- * @method response
82
- * @returns {Promise<boolean>}
83
- */
84
- response(): Promise<boolean>;
18
+ private ctx;
19
+ private root;
20
+ private options;
21
+ private path;
22
+ /**
23
+ * @constructor
24
+ * @param {Context} ctx
25
+ * @param {string} root
26
+ * @param {Options} options
27
+ */
28
+ constructor(ctx: Context, root: string | undefined, options: Options);
29
+ /**
30
+ * @method isConditionalGET
31
+ * @returns {boolean}
32
+ */
33
+ private isConditionalGET;
34
+ /**
35
+ * @method isPreconditionFailure
36
+ * @returns {boolean}
37
+ */
38
+ private isPreconditionFailure;
39
+ /**
40
+ * @method isRangeFresh
41
+ * @returns {boolean}
42
+ */
43
+ private isRangeFresh;
44
+ /**
45
+ * @method isIgnore
46
+ * @param {string} path
47
+ * @returns {boolean}
48
+ */
49
+ private isIgnore;
50
+ /**
51
+ * @method parseRange
52
+ * @param {Stats} stats
53
+ * @returns {Ranges}
54
+ */
55
+ private parseRange;
56
+ /**
57
+ * @method setupHeaders
58
+ * @param {string} path
59
+ * @param {Stats} stats
60
+ */
61
+ private setupHeaders;
62
+ /**
63
+ * @method read
64
+ * @param {string} path
65
+ * @param {Range} range
66
+ * @param {PassThrough} buffer
67
+ * @param {boolean} end
68
+ * @returns {Promise<true>}
69
+ */
70
+ private read;
71
+ /**
72
+ * @method send
73
+ * @param {string} path
74
+ * @param {Range[]} ranges
75
+ */
76
+ private send;
77
+ /**
78
+ * @method response
79
+ * @returns {Promise<boolean>}
80
+ */
81
+ response(): Promise<boolean>;
85
82
  }
@@ -4,9 +4,9 @@
4
4
  * @author nuintun
5
5
  */
6
6
  import { Middleware } from 'koa';
7
- import { Ignore, Options as SendOptions } from './Send';
8
- interface Options extends SendOptions {
9
- defer?: boolean;
7
+ import { Options as SendOptions } from './Send';
8
+ export interface Options extends SendOptions {
9
+ defer?: boolean;
10
10
  }
11
11
  /**
12
12
  * @function server
@@ -14,4 +14,3 @@ interface Options extends SendOptions {
14
14
  * @param {Options} options
15
15
  */
16
16
  export default function server(root: string, options?: Options): Middleware;
17
- export { Options, Ignore };
package/.editorconfig DELETED
@@ -1,39 +0,0 @@
1
- # http://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- indent_style = space
6
- indent_size = 2
7
- end_of_line = lf
8
- charset = utf-8
9
- trim_trailing_whitespace = true
10
- insert_final_newline = true
11
-
12
- # Use 4 spaces for the Python files
13
- [*.py]
14
- indent_size = 4
15
- max_line_length = 80
16
-
17
- # The JSON files contain newlines inconsistently
18
- [*.json]
19
- insert_final_newline = ignore
20
-
21
- # Minified JavaScript files shouldn't be changed
22
- [*.min.js]
23
- indent_style = ignore
24
- insert_final_newline = ignore
25
-
26
- # Makefiles always use tabs for indentation
27
- [Makefile]
28
- indent_style = tab
29
-
30
- # Batch files use tabs for indentation
31
- [*.bat]
32
- indent_style = tab
33
-
34
- [*.md]
35
- trim_trailing_whitespace = false
36
-
37
- [*.{cs,cshtml}]
38
- indent_size = 4
39
- charset = utf-8-bom
package/.prettierrc DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "printWidth": 128,
3
- "singleQuote": true,
4
- "arrowParens": "avoid",
5
- "trailingComma": "none",
6
- "overrides": [
7
- {
8
- "files": ["*.css", "*.less", "*.scss"],
9
- "options": {
10
- "singleQuote": false
11
- }
12
- }
13
- ]
14
- }