Skip to content

Commit

Permalink
Improve JSDoc code examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydenseric committed Jun 28, 2020
1 parent 79f415c commit b08157a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 25 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# extract-files changelog

## Next

### Patch

- Improved JSDoc code examples.

## 8.1.0

### Minor
Expand Down
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ _Extract files from an object._
>
> `clone` is:
>
> ```js
> ```json
> {
> a: null,
> b: [null, null]
> "a": null,
> "b": [null, null]
> }
> ```
>
Expand Down Expand Up @@ -222,9 +222,9 @@ A React Native [`File`](https://developer.mozilla.org/docs/web/api/file) substit
_A camera roll file._
> ```js
> {
> const fileSubstitute = {
> uri: uriFromCameraRoll,
> name: 'a.jpg',
> type: 'image/jpeg'
> }
> type: 'image/jpeg',
> };
> ```
6 changes: 3 additions & 3 deletions src/lib/ReactNativeFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
* @param {ReactNativeFileSubstitute} file A React Native [`File`](https://developer.mozilla.org/docs/web/api/file) substitute.
* @example <caption>An extractable file in React Native.</caption>
* ```js
* import { ReactNativeFile } from 'extract-files'
* import { ReactNativeFile } from 'extract-files';
*
* const file = new ReactNativeFile({
* uri: uriFromCameraRoll,
* name: 'a.jpg',
* type: 'image/jpeg'
* })
* type: 'image/jpeg',
* });
* ```
*/
module.exports = class ReactNativeFile {
Expand Down
18 changes: 9 additions & 9 deletions src/lib/extractFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ const defaultIsExtractableFile = require('./isExtractableFile.js');
* For the following:
*
* ```js
* import { extractFiles } from 'extract-files'
* import { extractFiles } from 'extract-files';
*
* const file1 = new File(['1'], '1.txt', { type: 'text/plain' })
* const file2 = new File(['2'], '2.txt', { type: 'text/plain' })
* const file1 = new File(['1'], '1.txt', { type: 'text/plain' });
* const file2 = new File(['2'], '2.txt', { type: 'text/plain' });
* const value = {
* a: file1,
* b: [file1, file2]
* }
* b: [file1, file2],
* };
*
* const { clone, files } = extractFiles(value, 'prefix')
* const { clone, files } = extractFiles(value, 'prefix');
* ```
*
* `value` remains the same.
*
* `clone` is:
*
* ```js
* ```json
* {
* a: null,
* b: [null, null]
* "a": null,
* "b": [null, null]
* }
* ```
*
Expand Down
12 changes: 6 additions & 6 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ exports.isExtractableFile = require('./isExtractableFile.js');
* @see [`isExtractableFile`]{@link isExtractableFile} is the default extractable file matcher.
* @example <caption>How to check for the default exactable files, as well as a custom type of file.</caption>
* ```js
* import { isExtractableFile } from 'extract-files'
* import { isExtractableFile } from 'extract-files';
*
* const isExtractableFileEnhanced = value =>
* const isExtractableFileEnhanced = (value) =>
* isExtractableFile(value) ||
* (typeof CustomFile !== 'undefined' && value instanceof CustomFile)
* (typeof CustomFile !== 'undefined' && value instanceof CustomFile);
* ```
*/

Expand Down Expand Up @@ -62,10 +62,10 @@ exports.isExtractableFile = require('./isExtractableFile.js');
* @prop {string} [type] File content type.
* @example <caption>A camera roll file.</caption>
* ```js
* {
* const fileSubstitute = {
* uri: uriFromCameraRoll,
* name: 'a.jpg',
* type: 'image/jpeg'
* }
* type: 'image/jpeg',
* };
* ```
*/
2 changes: 1 addition & 1 deletion src/lib/isExtractableFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ReactNativeFile = require('./ReactNativeFile.js');
* @returns {boolean} Is the value an [extractable file]{@link ExtractableFile}.
* @example <caption>How to import.</caption>
* ```js
* import { isExtractableFile } from 'extract-files'
* import { isExtractableFile } from 'extract-files';
* ```
*/
module.exports = function isExtractableFile(value) {
Expand Down

0 comments on commit b08157a

Please sign in to comment.