Skip to content

Commit

Permalink
JSDOC FileUploadCreateReadStream typedef WIP.
Browse files Browse the repository at this point in the history
The option descriptions still need to be added.

See: jaydenseric/graphql-upload#179 (review)
  • Loading branch information
krasivyy3954 committed Jan 15, 2020
1 parent 6ea0b95 commit 88f129f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/index.js
Expand Up @@ -14,7 +14,18 @@ exports.graphqlUploadExpress = require('./graphqlUploadExpress')
* @prop {string} filename File name.
* @prop {string} mimetype File MIME type. Provided by the client and can’t be trusted.
* @prop {string} encoding File stream transfer encoding.
* @prop {Function} createReadStream Returns a Node.js readable stream of the file contents, for processing and storing the file. Multiple calls create independent streams. Throws if called after all resolvers have resolved, or after an error has interrupted the request. This function can be passed an object with fields `encoding` and `highWaterMark` to configure the returned stream accordingly.
* @prop {FileUploadCreateReadStream} createReadStream Creates a [Node.js readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) of the file’s contents, for processing and storage.
*/

/**
* Creates a [Node.js readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) of an [uploading file’s]{@link FileUpload} contents, for processing and storage. Multiple calls create independent streams. Throws if called after all resolvers have resolved, or after an error has interrupted the request.
* @kind typedef
* @name FileUploadCreateReadStream
* @type {Function}
* @param {object} [options] Options.
* @param {string} [options.encoding]
* @param {number} [options.highWaterMark]
* @returns {Readable} [Node.js readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) of the file’s contents.
*/

/**
Expand Down
19 changes: 18 additions & 1 deletion readme.md
Expand Up @@ -70,6 +70,7 @@ The [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-mult
- [function graphqlUploadKoa](#function-graphqluploadkoa)
- [function processRequest](#function-processrequest)
- [type FileUpload](#type-fileupload)
- [type FileUploadCreateReadStream](#type-fileuploadcreatereadstream)
- [type GraphQLOperation](#type-graphqloperation)
- [type ProcessRequestFunction](#type-processrequestfunction)
- [type ProcessRequestOptions](#type-processrequestoptions)
Expand Down Expand Up @@ -224,7 +225,23 @@ File upload details, resolved from an [`Upload` scalar](#class-graphqlupload) pr
| `filename` | string | File name. |
| `mimetype` | string | File MIME type. Provided by the client and can’t be trusted. |
| `encoding` | string | File stream transfer encoding. |
| `createReadStream` | Function | Returns a Node.js readable stream of the file contents, for processing and storing the file. Multiple calls create independent streams. Throws if called after all resolvers have resolved, or after an error has interrupted the request. This function can be passed an object with fields `encoding` and `highWaterMark` to configure the returned stream accordingly. |
| `createReadStream` | [FileUploadCreateReadStream](#type-fileuploadcreatereadstream) | Creates a [Node.js readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) of the file’s contents, for processing and storage. |

---

### type FileUploadCreateReadStream

Creates a [Node.js readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) of an [uploading file’s](#type-fileupload) contents, for processing and storage. Multiple calls create independent streams. Throws if called after all resolvers have resolved, or after an error has interrupted the request.

**Type:** Function

| Parameter | Type | Description |
| :---------------------- | :------ | :---------- |
| `options` | object? | Options. |
| `options.encoding` | string? | |
| `options.highWaterMark` | number? | |

**Returns:** Readable — [Node.js readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) of the file’s contents.

---

Expand Down

0 comments on commit 88f129f

Please sign in to comment.