formstream 1.2.0 → 1.3.1

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/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "formstream",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "A multipart/form-data encoded stream, helper for file upload.",
5
5
  "main": "lib/formstream.js",
6
+ "types": "types/formstream.d.ts",
6
7
  "files": [
7
- "lib"
8
+ "lib",
9
+ "types/formstream.d.ts"
8
10
  ],
9
11
  "scripts": {
10
12
  "test": "egg-bin test",
11
13
  "cov": "egg-bin cov",
12
- "ci": "npm run lint && npm run cov",
13
- "lint": "jshint ."
14
+ "ci": "npm run lint && npm run tsd && npm run cov",
15
+ "lint": "jshint .",
16
+ "tsd": "tsd"
14
17
  },
15
18
  "repository": {
16
19
  "type": "git",
@@ -31,12 +34,14 @@
31
34
  "pause-stream": "~0.0.11"
32
35
  },
33
36
  "devDependencies": {
37
+ "@types/node": "^20.4.3",
34
38
  "connect-multiparty": "1",
35
39
  "egg-bin": "^5.6.1",
36
40
  "express": "^4.16.4",
37
41
  "jshint": "^2.13.6",
38
42
  "pedding": "1",
39
43
  "should": "4",
44
+ "tsd": "^0.28.1",
40
45
  "urllib": "2"
41
46
  },
42
47
  "author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)",
@@ -0,0 +1,74 @@
1
+ import { Readable, Stream } from 'stream'
2
+
3
+ declare class FormStream extends Stream {
4
+ /**
5
+ * Add a normal field to the form.
6
+ *
7
+ * @param name Name of field
8
+ * @param value Value of field
9
+ */
10
+ field(name: string, value: string): this
11
+
12
+ /**
13
+ * Add a local file to be uploaded to the form.
14
+ *
15
+ * @param name Name of file field
16
+ * @param filepath Local path of the file to be uploaded
17
+ * @param filename Name of the file (will be the base name of filepath if empty)
18
+ * @param filesize Size of the file (will not generate Content-Length header if not specified)
19
+ */
20
+ file(
21
+ name: string,
22
+ filepath: string,
23
+ filename?: string,
24
+ filesize?: number,
25
+ ): this
26
+
27
+ /**
28
+ * Add a buffer as a file to upload.
29
+ *
30
+ * @param name Name of field
31
+ * @param buffer The buffer to be uploaded
32
+ * @param filename The file name that tells the remote server
33
+ * @param contentType Content-Type (aka. MIME Type) of content (will be infered with filename if empty)
34
+ */
35
+ buffer(
36
+ name: string,
37
+ buffer: Buffer,
38
+ filename: string,
39
+ contentType?: string,
40
+ ): this
41
+
42
+ /**
43
+ * Add a readable stream as a file to upload. Event 'error' will be emitted if an error occured.
44
+ *
45
+ * @param name Name of field
46
+ * @param stream A readable stream to be piped
47
+ * @param filename The file name that tells the remote server
48
+ * @param contentType Content-Type (aka. MIME Type) of content (will be infered with filename if empty)
49
+ * @param size Size of the stream (will not generate Content-Length header if not specified)
50
+ */
51
+ stream(
52
+ name: string,
53
+ stream: Readable,
54
+ filename: string,
55
+ contentType?: string,
56
+ size?: number,
57
+ ): this
58
+
59
+ /**
60
+ * Get headers for the request.
61
+ *
62
+ * @param additionalHeaders Additional headers
63
+ */
64
+ headers(additionalHeaders?: Record<string, any>): Record<string, any>
65
+ }
66
+
67
+ declare const formStream: {
68
+ new (): FormStream
69
+ (): FormStream
70
+ }
71
+
72
+ interface formStream extends FormStream {}
73
+
74
+ export = formStream
package/History.md DELETED
@@ -1,83 +0,0 @@
1
-
2
- 1.2.0 / 2023-03-17
3
- ==================
4
-
5
- **features**
6
- * [[`f268e86`](http://github.com/node-modules/formstream/commit/f268e86e6b55d5b981bb7daf9c8662bdcd820f5c)] - feat: Porting from new Buffer() to Buffer.from() (#22) (Matthew Speiser <<mattrspeiser@gmail.com>>)
7
-
8
- **others**
9
- * [[`3c09f70`](http://github.com/node-modules/formstream/commit/3c09f700b2440b8f391650c939d91c2d5e4ae9b3)] - test: run on github action (#21) (fengmk2 <<fengmk2@gmail.com>>)
10
- * [[`2d5ed81`](http://github.com/node-modules/formstream/commit/2d5ed81e95b4fde270b5db2720fff0e19effd2dc)] - test: run test on node 12, 14, 16 (#20) (fengmk2 <<fengmk2@gmail.com>>)
11
-
12
- 1.1.1 / 2021-04-28
13
- ==================
14
-
15
- **fixes**
16
- * [[`c96ba5b`](http://github.com/node-modules/formstream/commit/c96ba5bace0e96bf39770769e43d9de4271971d8)] - fix: upgrade mime to fix wrong mime type (#19) (shaozj <<shaozj@users.noreply.github.com>>)
17
-
18
- **others**
19
- * [[`21918e5`](http://github.com/node-modules/formstream/commit/21918e5fc37a4cea5aae82659d39587f099e805b)] - chore: upgrade devDeps express to latest version (#15) (fengmk2 <<fengmk2@gmail.com>>)
20
-
21
- 1.1.0 / 2016-12-19
22
- ==================
23
-
24
- * deps: upgrade mime to latest version (#9)
25
-
26
- 1.0.0 / 2014-11-04
27
- ==================
28
-
29
- * fix(field): support stream.field(String, Number)
30
- * chore: fix links
31
- * chore: use npm scripts instead of Makefile
32
- * fix test case on node@0.8
33
-
34
- 0.0.8 / 2014-01-17
35
- ==================
36
-
37
- * destroy source stream when formstream destroy()
38
- * add more test cases
39
-
40
- 0.0.7 / 2013-07-25
41
- ==================
42
-
43
- * feature: always try to infer `Content-Length` (@xingrz)
44
- * doc improve
45
-
46
- 0.0.6 / 2013-07-15
47
- ==================
48
-
49
- * added test cases for chaining call (@xingrz)
50
- * improved docs (@xingrz)
51
- * added chaining support (@xingrz)
52
- * api doc
53
- * fixed test causes
54
- * update dependencies version
55
-
56
- 0.0.5 / 2012-11-06
57
- ==================
58
-
59
- * fixed stream error not catch bug
60
-
61
- 0.0.4 / 2012-11-06
62
- ==================
63
-
64
- * fixed #2 support form.buffer()
65
- * add doc for setTotalStreamSize()
66
-
67
- 0.0.3 / 2012-11-06
68
- ==================
69
-
70
- * support content-length use form.setTotalStreamSize(size)
71
- * update readme
72
-
73
- 0.0.2 / 2012-10-11
74
- ==================
75
-
76
- * use buffer-concat support node < 0.8
77
-
78
- 0.0.1 / 2012-10-11
79
- ==================
80
-
81
- * support multi streams.
82
- * add one stream support now.
83
- * Initial commit