Skip to content

Commit

Permalink
chore: Update typescript and fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaclennan committed Jul 4, 2023
1 parent 851d0d9 commit 64ebac5
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 444 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,5 @@ dist
.yarn/build-state.yml
.pnp.*

# Type declarations
# Dist
/dist
10 changes: 5 additions & 5 deletions lib/core-index-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const kUpdateState = Symbol('updateState')
* @extends {Readable<Entry<T>, Entry<T>, Entry<T>, true, false, Omit<import('./types').IndexStreamEvents<Entry<T>>, 'index-state'>>}
*/
class CoreIndexStream extends Readable {
/** @type {Bitfield} */
/** @type {Bitfield | undefined} */
#bitfield
#core
#storage
Expand Down Expand Up @@ -100,7 +100,7 @@ class CoreIndexStream extends Readable {
async [kDestroyPromise]() {
this.#core.removeListener('append', this[kHandleAppend])
this.#core.removeListener('download', this[kHandleDownload])
await this.#bitfield.flush()
await this.#bitfield?.flush()
}

async [kOpenPromise]() {
Expand Down Expand Up @@ -141,7 +141,7 @@ class CoreIndexStream extends Readable {
// If nothing was pushed, queue up another read
await this[kReadPromise]()
}
await this.#bitfield.flush()
await this.#bitfield?.flush()
}

/**
Expand All @@ -151,11 +151,11 @@ class CoreIndexStream extends Readable {
* @returns {Promise<boolean>}
*/
async [kPushEntry](index) {
const isIndexed = this.#bitfield.get(index)
const isIndexed = this.#bitfield?.get(index)
if (isIndexed) return false
const block = await this.#core.get(index, { wait: false })
if (block === null) return false
this.#bitfield.set(index, true)
this.#bitfield?.set(index, true)
const entry = { key: this.#core.key, block, index }
this.#readBufferAvailable = this.push(entry)
return true
Expand Down
2 changes: 0 additions & 2 deletions lib/multi-core-index-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class MultiCoreIndexStream extends Readable {
/** @type {Set<CoreIndexStream<T>>} */
#readable = new Set()
#pending = pDefer()
/** @type {ReturnType<typeof setTimeout>} */
#timeoutId
#destroying = false
/** @type {import('./types').IndexStateCurrent} */
#state = 'idle'
Expand Down
Loading

0 comments on commit 64ebac5

Please sign in to comment.