Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

import { stringTuplesToTuples, tuplesToBytes } from './codec.js'
import { Multiaddr as MultiaddrClass, symbol } from './multiaddr.js'
import { getProtocol } from './protocols-table.js'
import { getProtocol, registerProtocol } from './protocols-table.js'
import type { Resolver } from './resolvers/index.js'
import type { DNS } from '@multiformats/dns'

Expand Down Expand Up @@ -627,4 +627,4 @@ export function multiaddr (addr?: MultiaddrInput): Multiaddr {
return new MultiaddrClass(addr)
}

export { getProtocol as protocols }
export { getProtocol as protocols, registerProtocol }
5 changes: 5 additions & 0 deletions src/protocols-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ export function getProtocol (proto: number | string): Protocol {

throw new Error(`invalid protocol id type: ${typeof proto}`)
}

export function registerProtocol (protocol: Protocol): void {
codes[protocol.code] = protocol
names[protocol.name] = protocol
}