diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-18 14:35:31 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-18 14:35:31 +0200 |
commit | c199c427d4ae586339822320f20f512a7a19dc3f (patch) | |
tree | 9cbe8bebc25e97d2e8086c41bcd7180dd752dbac /client/src/assets/player/peertube-chunk-store.ts | |
parent | cdf4cb9eaf5f6bc71f7c1e1963c07575f1d2593d (diff) | |
download | PeerTube-c199c427d4ae586339822320f20f512a7a19dc3f.tar.gz PeerTube-c199c427d4ae586339822320f20f512a7a19dc3f.tar.zst PeerTube-c199c427d4ae586339822320f20f512a7a19dc3f.zip |
Better typings
Diffstat (limited to 'client/src/assets/player/peertube-chunk-store.ts')
-rw-r--r-- | client/src/assets/player/peertube-chunk-store.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/client/src/assets/player/peertube-chunk-store.ts b/client/src/assets/player/peertube-chunk-store.ts index ac3f9e654..54cc0ea64 100644 --- a/client/src/assets/player/peertube-chunk-store.ts +++ b/client/src/assets/player/peertube-chunk-store.ts | |||
@@ -76,7 +76,7 @@ export class PeertubeChunkStore extends EventEmitter { | |||
76 | this.runCleaner() | 76 | this.runCleaner() |
77 | } | 77 | } |
78 | 78 | ||
79 | put (index: number, buf: Buffer, cb: Function) { | 79 | put (index: number, buf: Buffer, cb: (err?: Error) => void) { |
80 | const isLastChunk = (index === this.lastChunkIndex) | 80 | const isLastChunk = (index === this.lastChunkIndex) |
81 | if (isLastChunk && buf.length !== this.lastChunkLength) { | 81 | if (isLastChunk && buf.length !== this.lastChunkLength) { |
82 | return this.nextTick(cb, new Error('Last chunk length must be ' + this.lastChunkLength)) | 82 | return this.nextTick(cb, new Error('Last chunk length must be ' + this.lastChunkLength)) |
@@ -113,7 +113,7 @@ export class PeertubeChunkStore extends EventEmitter { | |||
113 | }, PeertubeChunkStore.BUFFERING_PUT_MS) | 113 | }, PeertubeChunkStore.BUFFERING_PUT_MS) |
114 | } | 114 | } |
115 | 115 | ||
116 | get (index: number, opts: any, cb: any): any { | 116 | get (index: number, opts: any, cb: (err?: Error, buf?: Buffer) => void): void { |
117 | if (typeof opts === 'function') return this.get(index, null, opts) | 117 | if (typeof opts === 'function') return this.get(index, null, opts) |
118 | 118 | ||
119 | // IndexDB could be slow, use our memory index first | 119 | // IndexDB could be slow, use our memory index first |
@@ -146,11 +146,11 @@ export class PeertubeChunkStore extends EventEmitter { | |||
146 | }) | 146 | }) |
147 | } | 147 | } |
148 | 148 | ||
149 | close (db: any) { | 149 | close (cb: (err?: Error) => void) { |
150 | return this.destroy(db) | 150 | return this.destroy(cb) |
151 | } | 151 | } |
152 | 152 | ||
153 | async destroy (cb: any) { | 153 | async destroy (cb: (err?: Error) => void) { |
154 | try { | 154 | try { |
155 | if (this.pendingPut) { | 155 | if (this.pendingPut) { |
156 | clearTimeout(this.putBulkTimeout) | 156 | clearTimeout(this.putBulkTimeout) |
@@ -225,7 +225,7 @@ export class PeertubeChunkStore extends EventEmitter { | |||
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | private nextTick (cb: any, err: Error, val?: any) { | 228 | private nextTick <T> (cb: (err?: Error, val?: T) => void, err: Error, val?: T) { |
229 | process.nextTick(() => cb(err, val), undefined) | 229 | process.nextTick(() => cb(err, val), undefined) |
230 | } | 230 | } |
231 | } | 231 | } |