Skip to content

Commit

Permalink
chore: lint the fetch service
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed Mar 3, 2023
1 parent 00186cc commit 528a65a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class FetchService implements Startable {
this.init = init
}

async start () {
async start (): Promise<void> {
await this.components.registrar.handle(this.protocol, (data) => {
void this.handleMessage(data)
.catch(err => {
Expand All @@ -83,12 +83,12 @@ export class FetchService implements Startable {
this.started = true
}

async stop () {
async stop (): Promise<void> {
await this.components.registrar.unhandle(this.protocol)
this.started = false
}

isStarted () {
isStarted (): boolean {
return this.started
}

Expand Down Expand Up @@ -178,7 +178,7 @@ export class FetchService implements Startable {
* responds based on looking up the key in the request via the lookup callback that corresponds
* to the key's prefix.
*/
async handleMessage (data: IncomingStreamData) {
async handleMessage (data: IncomingStreamData): Promise<void> {
const { stream } = data
const self = this

Expand Down Expand Up @@ -224,7 +224,7 @@ export class FetchService implements Startable {
* Given a key, finds the appropriate function for looking up its corresponding value, based on
* the key's prefix.
*/
_getLookupFunction (key: string) {
_getLookupFunction (key: string): LookupFunction | undefined {
for (const prefix of this.lookupFunctions.keys()) {
if (key.startsWith(prefix)) {
return this.lookupFunctions.get(prefix)
Expand All @@ -243,7 +243,7 @@ export class FetchService implements Startable {
* libp2p.fetchService.registerLookupFunction('/prefix', (key) => { ... })
* ```
*/
registerLookupFunction (prefix: string, lookup: LookupFunction) {
registerLookupFunction (prefix: string, lookup: LookupFunction): void {
if (this.lookupFunctions.has(prefix)) {
throw errCode(new Error("Fetch protocol handler for key prefix '" + prefix + "' already registered"), codes.ERR_KEY_ALREADY_EXISTS)
}
Expand All @@ -262,7 +262,7 @@ export class FetchService implements Startable {
* libp2p.fetchService.unregisterLookupFunction('/prefix')
* ```
*/
unregisterLookupFunction (prefix: string, lookup?: LookupFunction) {
unregisterLookupFunction (prefix: string, lookup?: LookupFunction): void {
if (lookup != null) {
const existingLookup = this.lookupFunctions.get(prefix)

Expand Down

0 comments on commit 528a65a

Please sign in to comment.