Skip to content

Commit

Permalink
refactor: simplify naming
Browse files Browse the repository at this point in the history
  • Loading branch information
2color committed Nov 6, 2024
1 parent 5de4bff commit 7bf29f3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/verified-fetch/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,21 +650,21 @@ export interface CreateVerifiedFetchInit {
*
* @default false
*/
webSocketsProviders?: boolean
webSockets?: boolean

/**
* Whether to enable WebTransport providers.
*
* @default false
*/
webTransportProviders?: boolean
webTransport?: boolean

/**
* Whether to enable WebRTC providers.
*
* @default false
*/
webRTCProviders?: boolean
webRTC?: boolean

/**
* In order to parse DNSLink records, we need to resolve DNS queries. You can
Expand Down Expand Up @@ -816,18 +816,18 @@ export interface VerifiedFetchInit extends RequestInit, ProgressOptions<BubbledP
*/
export async function createVerifiedFetch (init?: Helia | CreateVerifiedFetchInit, options?: CreateVerifiedFetchOptions): Promise<VerifiedFetch> {
if (!isHelia(init)) {
if (init?.webTransportProviders ?? init?.webSocketsProviders ?? init?.webRTCProviders ?? false) {
if (init?.webTransport ?? init?.webSockets ?? init?.webRTC ?? false) {
const libp2pConfig = libp2pDefaults()

libp2pConfig.transports = []

if (init?.webTransportProviders === true) {
if (init?.webTransport === true) {
libp2pConfig.transports.push(webTransport())
}
if (init?.webSocketsProviders === true) {
if (init?.webSockets === true) {
libp2pConfig.transports.push(webSockets())
}
if (init?.webRTCProviders === true) {
if (init?.webRTC === true) {
libp2pConfig.transports.push(webRTCDirect())
}

Expand Down

0 comments on commit 7bf29f3

Please sign in to comment.