Skip to content

Commit

Permalink
docs(jsdocs): move docs out of index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Jul 8, 2016
1 parent 83c58a6 commit 999201a
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 50 deletions.
29 changes: 21 additions & 8 deletions README.md
Expand Up @@ -50,7 +50,7 @@ $ mtd --help

* [CreateMTDFile(options)](#CreateMTDFile) ⇒ <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code>
* [DownloadFromMTDFile(mtdPath)](#DownloadFromMTDFile) ⇒ <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code>
* [FinalizeDownload(meta$)](#FinalizeDownload) ⇒ <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code>
* [FinalizeDownload(params)](#FinalizeDownload) ⇒ <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code>
* [Completion(meta$)](#Completion) ⇒ <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code>

<a name="FILE"></a>
Expand Down Expand Up @@ -171,7 +171,11 @@ file. The file is initially empty and has all the relevant meta
information regarding the download appended to the end.

**Kind**: global function
**Returns**: <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> - multiplexed stream
**Returns**: <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> - A [multiplexed stream](https://github.com/tusharmath/muxer) containing ~
- `written$` - Bytes being saved on disk.
- `meta$` - Meta information about the download.
- `remoteFileSize$` - Size of the content that is to be downloaded.
- `fdW$` - File descriptor in `w` mode.

| Param | Type | Default | Description |
| --- | --- | --- | --- |
Expand All @@ -188,32 +192,41 @@ Reads a `.mtd` file and resumes the download from the last successfully saved
byte.

**Kind**: global function
**Returns**: <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> - multiplexed stream
**Returns**: <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> - A [multiplexed stream](https://github.com/tusharmath/muxer) containing ~
- `metaWritten$` - Meta data buffer stream.
- `response$` - HTTP response object.
- `localFileSize$` - Size of the `.mtd` file on disk.
- `fdR$` - File Descriptor in `r+` mode.
- `meta$` - Download meta information.

| Param | Type | Description |
| --- | --- | --- |
| mtdPath | <code>String</code> | Relative path to the `.mtd` file. |

<a name="FinalizeDownload"></a>

## FinalizeDownload(meta$) ⇒ <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code>
## FinalizeDownload(params) ⇒ <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code>
Removes the meta information and the `.mtd` extension from the file once the
download is successfully completed.

**Kind**: global function
**Returns**: <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> - multiplexed stream
**Returns**: <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> - A [multiplexed stream](https://github.com/tusharmath/muxer) containing ~
- `truncated$` - Fired when the meta data is removed.
- `renamed$` - Fired when the `.mtd` extension is removed.

| Param | Type | Description |
| --- | --- | --- |
| meta$ | <code>Observable</code> | Meta data stream ie. exposed by [DownloadFromMTDFile](#DownloadFromMTDFile) |
| params | <code>object</code> | `{fd$, meta$}` |
| params.fd$ | <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> | File descriptor Observable |
| params.meta$ | <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> | Download meta information |

<a name="Completion"></a>

## Completion(meta$) ⇒ <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code>
Util method that calculates the total completion percentage.
Util method that calculates the total completion percentage (between 0-100).

**Kind**: global function
**Returns**: <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> - Value between 0 - 100
**Returns**: <code>[Observable](https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/observable.md)</code> - Value between 0-100

| Param | Type | Description |
| --- | --- | --- |
Expand Down
17 changes: 17 additions & 0 deletions src/CreateMTDFile.js
Expand Up @@ -13,6 +13,23 @@ import {
JSToBuffer$
} from './Utils'

/**
* Creates a new .mtd file that is a little larger in size than the original
* file. The file is initially empty and has all the relevant meta
* information regarding the download appended to the end.
* @function
* @param {object} options - The `options` must have `mtdPath` and `url`.
* @param {string} options.url - Download url.
* @param {string} options.path - Relative path where the file needs to be saved.
* @param {number} [options.range=3] - Number of concurrent downloads.
* @param {number} [options.metaWrite=300] - Throttles the write frequency of meta data.
* @return {external:Observable}
* A {@link https://github.com/tusharmath/muxer multiplexed stream} containing ~
* - `written$` - Bytes being saved on disk.
* - `meta$` - Meta information about the download.
* - `remoteFileSize$` - Size of the content that is to be downloaded.
* - `fdW$` - File descriptor in `w` mode.
*/
export const CreateMTDFile = R.curry(({FILE, HTTP}, options) => {
/**
* Create a new file
Expand Down
13 changes: 13 additions & 0 deletions src/DownloadFromMTDFile.js
Expand Up @@ -20,6 +20,19 @@ import {
RxThrottleComplete
} from './Utils'

/**
* Reads a `.mtd` file and resumes the download from the last successfully saved
* byte.
* @function
* @param {String} mtdPath - Relative path to the `.mtd` file.
* @return {external:Observable}
* A {@link https://github.com/tusharmath/muxer multiplexed stream} containing ~
* - `metaWritten$` - Meta data buffer stream.
* - `response$` - HTTP response object.
* - `localFileSize$` - Size of the `.mtd` file on disk.
* - `fdR$` - File Descriptor in `r+` mode.
* - `meta$` - Download meta information.
*/
export const DownloadFromMTDFile = R.curry(({FILE, HTTP}, mtdPath) => {
/**
* Open file to read+append
Expand Down
16 changes: 9 additions & 7 deletions src/FinalizeDownload.js
Expand Up @@ -10,14 +10,16 @@ import R from 'ramda'
import {IsCompleted$} from './Utils'

/**
* Removes the appended meta data and the .mtd extension from the file. In case
* there still some data leftover to be downloaded, this step will be ignored.
* Removes the meta information and the `.mtd` extension from the file once the
* download is successfully completed.
* @function
* @private
* @param {Object} FILE - File transformer
* @param {Observable} fd$ - File descriptor observable
* @param {Observable} meta$ - Download meta information
* @returns {Observable}
* @param {object} params - `{fd$, meta$}`
* @param {external:Observable} params.fd$ - File descriptor Observable
* @param {external:Observable} params.meta$ - Download meta information
* @returns {external:Observable}
* A {@link https://github.com/tusharmath/muxer multiplexed stream} containing ~
* - `truncated$` - Fired when the meta data is removed.
* - `renamed$` - Fired when the `.mtd` extension is removed.
*/
export const FinalizeDownload = R.curry(({FILE}, {fd$, meta$}) => {
const [ok$, noop$] = IsCompleted$(meta$).partition(Boolean)
Expand Down
7 changes: 7 additions & 0 deletions src/Utils.js
Expand Up @@ -191,6 +191,13 @@ export const IsCompleted$ = (meta$) => {
export const TapBetween = R.curry((min, max, value) => {
return Math.min(max, Math.max(min, value))
})

/**
* Util method that calculates the total completion percentage (between 0-100).
* @function
* @param {Observable} meta$ Meta data stream ie. exposed by {@link DownloadFromMTDFile}
* @return {external:Observable} Value between 0-100
*/
export const Completion = (meta$) => {
const tap0To100 = TapBetween(0, 1)
return meta$.map(meta => {
Expand Down
35 changes: 0 additions & 35 deletions src/index.js
Expand Up @@ -16,51 +16,16 @@ export const HTTP = T.HTTP(request)
export const FILE = T.FILE(fs)
export const BAR = T.BAR(progress)

/**
* Creates a new .mtd file that is a little larger in size than the original
* file. The file is initially empty and has all the relevant meta
* information regarding the download appended to the end.
* @function
* @param {object} options - The `options` must have `mtdPath` and `url`.
* @param {string} options.url - Download url.
* @param {string} options.path - Relative path where the file needs to be saved.
* @param {number} [options.range=3] - Number of concurrent downloads.
* @param {number} [options.metaWrite=300] - Throttles the write frequency of meta data.
* @return {external:Observable} multiplexed stream
*/
export const CreateMTDFile = R.compose(_CreateMTDFile({
FILE,
HTTP
}), U.MergeDefaultOptions)

/**
* Reads a `.mtd` file and resumes the download from the last successfully saved
* byte.
* @function
* @param {String} mtdPath - Relative path to the `.mtd` file.
* @return {external:Observable} multiplexed stream
*/
export const DownloadFromMTDFile = _DownloadFromMTDFile({FILE, HTTP})

/**
* Removes the meta information and the `.mtd` extension from the file once the
* download is successfully completed.
* @function
* @param {Observable} meta$ - Meta data stream ie. exposed by {@link DownloadFromMTDFile}
* @return {external:Observable} multiplexed stream
*/
export const FinalizeDownload = _FinalizeDownload({FILE})

export const MTDPath = U.MTDPath
export const GetDownloadType = U.GetDownloadType(U.NormalizePath)
export const DOWNLOAD_TYPES = U.DOWNLOAD_TYPES

/**
* Util method that calculates the total completion percentage.
* @function
* @param {Observable} meta$ - Meta data stream ie. exposed by {@link DownloadFromMTDFile}
* @return {external:Observable} Value between 0 - 100
*/
export const Completion = U.Completion
export const CliValidOptions = U.CliValidOptions

Expand Down

0 comments on commit 999201a

Please sign in to comment.