Skip to content

Commit

Permalink
reviewing documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JiPaix committed Aug 18, 2020
1 parent 26e0d93 commit 82d45d9
Show file tree
Hide file tree
Showing 29 changed files with 1,355 additions and 29,770 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -112,6 +112,7 @@ Each `Job` can :
```js
job.cancel()
```
- Emit events (see event documentation below)

### Events
Some events are accessible globally from `xdccJS` and from `Jobs`
Expand Down Expand Up @@ -152,7 +153,7 @@ Some events are accessible globally from `xdccJS` and from `Jobs`
//=> { name: 'a-bot', queue: [98], now: 62, sucess: ['file.txt'], failed: [50] }
})
```
- >[<span style="color:#37bd80">xdccJS</span> | <span style="color:#37bd80">Job</span>].<span style="color:#9865a3">on</span>(<span style="color:#1a3ea1">'pipe'</span>) : <span style="color:black">When a file is getting piped (see <a href="#Pipes">Pipe documentation</a>)</span>
- >[<span style="color:#37bd80">xdccJS</span> | <span style="color:#37bd80">Job</span>].<span style="color:#9865a3">on</span>(<span style="color:#1a3ea1">'pipe'</span>) : <span style="color:black">When a file is getting piped (see <a href="#pipes">Pipe documentation</a>)</span>
```js
xdccJS.on('pipe', (stream, fileInfo) => {
stream.pipe(somewhere)
Expand Down
77 changes: 77 additions & 0 deletions build/index.js
Expand Up @@ -8,6 +8,83 @@ fs.createReadStream('./lib/progress/index.d.ts').pipe(fs.createWriteStream('./di
const jsPath = './dist/index.js'
const tsPath = './dist/index.d.ts'

// lazy typing :

let dts = fs.readFileSync('./dist/index.d.ts').toString()
const LazyString = `declare class Controller extends EventEmitter {
on(eventType: string | symbol, cb: (event?: unknown, another?: unknown) => void): this
/**
* @description Event triggered when .download() has finished downloading all files
* @example
* xdccJS.on('ready', () => {
* xdccJS.download('XDCC|BLUE', '23-25, 102, 300')
* xdccJS.download('XDCC|RED', 1152)
* })
*
* xdccJS.on('done', job => {
* console.log(job)
* console.log('-----')
* })
*
* // console output :
*
* {
* nick: 'XDCC|RED',
* success: ['file.txt'],
* failures: []
* }
* -----
* {
* nick: 'XDCC|BLUE',
* success: [ 'file.pdf', 'video.mp4', 'audio.wav' ],
* failures: [ 24, 300 ]
* }
*/
on(eventType: 'done', cb: (job: Job) => void): this
/**
* @description Event triggered when a file is downloaded
* @example
* xdccJS.on('downloaded', fileInfo => {
* console.log('file available @: ' + fileInfo.filePath)
* })
*/
on(eventType: 'downloaded', cb: (fileInfo: FileInfo) => void): this
/**
* @description Event triggered when all downloads are done
* @example
* xdccJS.on('can-quit', () => {
* xdccJS.quit()
* })
*/
on(eventType: 'can-quit', cb: () => void): this
/**
* @description Event triggered when a download/connection error happens
* @remark This event doesn't skip retries
* @remark fileInfo isn't provided in case of an error not related to a download
* @example
* xdccJS.on('error', (error, fileInfo) => {
* console.log('failed to download: ' + fileInfo.file)
* console.log(error)
* })
* // CONSOLE OUTPUT
* //=> failed to download myfile.mp'
* //=> timeout: no response from BOT-NICKNAME
*/
on(eventType: 'error', cb: (error: Error, fileInfo: FileInfo) => void): this
/**
* @description Event triggered when xdccJS is ready to download
* @example
*
* xdccJS.on('ready', () => {
* xdccJS.download('BOT', '1-5, 22-35, 100, 132')
* })
*/
on(eventType: 'ready', cb: () => void): this
`
dts = dts.replace(`declare class Controller extends EventEmitter {`, LazyString)
fs.writeFileSync(tsPath, dts)

// pattern to replace
const strings = [
{ match: /\s+\*\s```js/gi, replace: '' },
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/search.json

Large diffs are not rendered by default.

0 comments on commit 82d45d9

Please sign in to comment.