Skip to content

Commit

Permalink
docs: fix dnsaddrResolver name (#392)
Browse files Browse the repository at this point in the history
Fixes documentation errors and adds doc-check to prevent regressions.

Fixes #388
  • Loading branch information
achingbrain authored Nov 21, 2024
1 parent d4164fb commit 823b45f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 63 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ A standard way to represent addresses that

```TypeScript
import { multiaddr } from '@multiformats/multiaddr'
const addr = multiaddr("/ip4/127.0.0.1/udp/1234")
// Multiaddr(/ip4/127.0.0.1/udp/1234)

const addr = multiaddr("/ip4/127.0.0.1/udp/1234")
const addr = multiaddr('/ip4/127.0.0.1/udp/1234')
// Multiaddr(/ip4/127.0.0.1/udp/1234)

addr.bytes
Expand Down Expand Up @@ -77,9 +75,9 @@ DNSADDR addresses can resolve to multiple multiaddrs, since there is no limit to

```TypeScript
import { multiaddr, resolvers } from '@multiformats/multiaddr'
import { dnsaddr } from '@multiformats/multiaddr/resolvers'
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'

resolvers.set('dnsaddr', dnsaddr)
resolvers.set('dnsaddr', dnsaddrResolver)

const ma = multiaddr('/dnsaddr/bootstrap.libp2p.io')

Expand All @@ -88,7 +86,7 @@ const resolved = await ma.resolve({
signal: AbortSignal.timeout(5000)
})

console.info(await ma.resolve(resolved)
console.info(resolved)
// [Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...')...]
```

Expand All @@ -102,7 +100,9 @@ import { dns } from '@multiformats/dns'
import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'

const resolver = dns({
'.': dnsJsonOverHttps('https://cloudflare-dns.com/dns-query')
resolvers: {
'.': dnsJsonOverHttps('https://cloudflare-dns.com/dns-query')
}
})

const ma = multiaddr('/dnsaddr/bootstrap.libp2p.io')
Expand Down
29 changes: 0 additions & 29 deletions examples/try.js

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"clean": "aegir clean",
"lint": "aegir lint",
"dep-check": "aegir dep-check",
"doc-check": "aegir doc-check",
"build": "aegir build",
"test": "aegir test -f",
"test:chrome": "aegir test -t browser --cov",
Expand Down
6 changes: 0 additions & 6 deletions src/convert.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/**
* @packageDocumentation
*
* Provides methods for converting
*/

import { IpNet } from '@chainsafe/netmask'
import { base32 } from 'multiformats/bases/base32'
import { base58btc } from 'multiformats/bases/base58'
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
*
* ```TypeScript
* import { multiaddr } from '@multiformats/multiaddr'
* const addr = multiaddr("/ip4/127.0.0.1/udp/1234")
* // Multiaddr(/ip4/127.0.0.1/udp/1234)
*
* const addr = multiaddr("/ip4/127.0.0.1/udp/1234")
* const addr = multiaddr('/ip4/127.0.0.1/udp/1234')
* // Multiaddr(/ip4/127.0.0.1/udp/1234)
*
* addr.bytes
Expand Down Expand Up @@ -55,9 +53,9 @@
*
* ```TypeScript
* import { multiaddr, resolvers } from '@multiformats/multiaddr'
* import { dnsaddr } from '@multiformats/multiaddr/resolvers'
* import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
*
* resolvers.set('dnsaddr', dnsaddr)
* resolvers.set('dnsaddr', dnsaddrResolver)
*
* const ma = multiaddr('/dnsaddr/bootstrap.libp2p.io')
*
Expand All @@ -66,7 +64,7 @@
* signal: AbortSignal.timeout(5000)
* })
*
* console.info(await ma.resolve(resolved)
* console.info(resolved)
* // [Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...')...]
* ```
*
Expand All @@ -80,7 +78,9 @@
* import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'
*
* const resolver = dns({
* '.': dnsJsonOverHttps('https://cloudflare-dns.com/dns-query')
* resolvers: {
* '.': dnsJsonOverHttps('https://cloudflare-dns.com/dns-query')
* }
* })
*
* const ma = multiaddr('/dnsaddr/bootstrap.libp2p.io')
Expand Down
14 changes: 0 additions & 14 deletions src/multiaddr.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
/**
* @packageDocumentation
*
* An implementation of a Multiaddr in JavaScript
*
* @example
*
* ```js
* import { multiaddr } from '@multiformats/multiaddr'
*
* const ma = multiaddr('/ip4/127.0.0.1/tcp/1234')
* ```
*/

import { base58btc } from 'multiformats/bases/base58'
import { CID } from 'multiformats/cid'
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
Expand Down
1 change: 1 addition & 0 deletions src/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export interface Resolver<ResolveOptions extends AbortOptions = AbortOptions> {
}

export { dnsaddrResolver } from './dnsaddr.js'
export type { DNSADDROptions } from './dnsaddr.js'

0 comments on commit 823b45f

Please sign in to comment.