diff --git a/assets/highlight.css b/assets/highlight.css index f3e56c01..a8e7b6dc 100644 --- a/assets/highlight.css +++ b/assets/highlight.css @@ -15,18 +15,18 @@ --dark-hl-6: #DCDCAA; --light-hl-7: #008000; --dark-hl-7: #6A9955; - --light-hl-8: #800000; - --dark-hl-8: #808080; + --light-hl-8: #098658; + --dark-hl-8: #B5CEA8; --light-hl-9: #800000; - --dark-hl-9: #569CD6; - --light-hl-10: #000000FF; - --dark-hl-10: #D4D4D4; - --light-hl-11: #E50000; - --dark-hl-11: #9CDCFE; - --light-hl-12: #0000FF; - --dark-hl-12: #CE9178; - --light-hl-13: #098658; - --dark-hl-13: #B5CEA8; + --dark-hl-9: #808080; + --light-hl-10: #800000; + --dark-hl-10: #569CD6; + --light-hl-11: #000000FF; + --dark-hl-11: #D4D4D4; + --light-hl-12: #E50000; + --dark-hl-12: #9CDCFE; + --light-hl-13: #0000FF; + --dark-hl-13: #CE9178; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } diff --git a/assets/navigation.js b/assets/navigation.js index fb81c07d..f4115c02 100644 --- a/assets/navigation.js +++ b/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA43UTVPCMBAG4P+Sc/0ABbU3PDjDQXCUG8OhNAtE06STbBkYx//uQEsT2rLk2r59utlNMv9lCDtkMUu12oJBFrE8wQ2LWaZ5IcHeVS9uN5hJFrEfoTiL+xFLN0JyA4rF88vIqlApCq0c08kNH/+iJjLTr3sEG2BVyRBynE8gpLwqGUJ+oRFqHWSW0Ra68FihOOzaQzg+DhrBeyFRJJybNyERjKNSmVhbU43YOd3rP3sljZba4DQ/rslxQiGYVZLWoh9rVDoYelz9Z8KqM0HQdPkNKYZwZZJCJ5rDiHMDllqrl6KwD6NRp1oS0ilCMZ9gtdwC1bBTJKhfY5UXXrtwn7c7dcw0tPuXp96g74nlfp4VuYRuzgtcswgl6HtTdcAb2zYxIlm641NHzq0Hn1kZnXXuAXesS6wRJG4KYTu2fJPzQiQ1STKglMN7AsiuV1JHbnoElFf7luhQHSEvvI65nS69C/O6cPFxZQ9Vtw+Lq8uBjXBHhYt/31rZvhsHAAA=" \ No newline at end of file +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA43UTVPCMBAG4P8Sr6iUL6U3PDjDQXCUG8OhNItE06STbBkYx//uQEsb2rLkSl+eSXazu/xlCHtkIYu12oFB1mFphFsWskTzTIJ9LD48bDGRrMN+hOIs7HVYvBWSG1AsXF5HNpmKUWhVMa3caPDXqSML/XJAsB5WkfQhp+kMfI5XJH3ITzRCfXmZebSBrhxWKA77ZhNOP3u14AOsljswlHHnhHJsEIwH/a57v7dMoog4N69CosvFMrK25GqxyyMGvWdHnKy1wXl6qk3FCYVgNlFcim6sduPhqO2AhFVmvKD5+hti9OHyJIXONIcJ5wYsdVcnRWHvRqOOtSSkc4Riiq7fbsFl0Kt2U5VmTunwkDardsrUtO74KRj2HDGfkUWWSmjnnMAti1C8/m+KMXFqtYuMiNbVOJWRS6vvMhujk9b3UK2KHKsFie0jbMvzr3NOiKRmUQKUcvxOAMntk5SR+4CA0uINExUqI+QSbenbeQle6Zf3MnVmpaLOMWpSuLLHAjTF6ooVWAu3XHb1DxXGYJO6BwAA" \ No newline at end of file diff --git a/assets/search.js b/assets/search.js index 6600e551..ce8384e8 100644 --- a/assets/search.js +++ b/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA62a227bRhCG32V9yzjek053aYACLlAnaIL2QjAKWqRtJhLJkpTT1PC7F8vjDDVDkaavmlrz7z+73+yBSz6LLPmRi832WXyP4kBslCdi/xCKjYjiIPxXeOKY7cVGHJLguA/z9+VfLx+Lw154Yrf38zzMxUaIF69pYWHaJu6z5HCTBOGHIMjCPG8buz/GuyJK4qa5XhzRvCdSPwvjos2L9IvyG/cPzqb6eUbrvx/3ReQHQTZg0ca82udw1qWNeCenuSi7aG0+Z0mR7JJ96xLFRZjd+7uWchM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cYUO7sNBH8GEV3XtWa6F5psYIAfrm+JwVh/ZdiKwKHDbTHUWKKovkIAdAKm4AQJaXAVwLeamaJF8y5MYeYJ0NTfBioQ60oKlRHNjSp17FFgQFFc/4LNLUAgAp+Qq/XRYQd0prtCJAQX7lCbh33oijdJwH8Wh2GxvX17+B1EJATxrMAAA"; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA62a247bRhKG36V1S0/UJ+pwl/ViAQeIHSRGciEMFrTI8TCRSC5JTewdzLsHzWMVVUWRw7mzR/X3X91f9Ynks8jTvwuxPzyLv+IkFHvliSQ4R2Iv4iSMvglPXPKT2ItzGl5OUfFD9de7x/J8Ep44noKiiAqxF+LFa1vwTdfEQ56eP6Zh9GMY5lFRdI09XJJjGadJ29wgjmjeE1mQR0nZ5UX6xcVH9w/Opv55Qes/X05lHIRhPmLRxbza53zTpYt4J+e5KOt3Nr/kaZke01PnEidllD8Ex45yGzHPQ65V35djGkYTDVZN7IhLJ+Dsivj/k+2a2CV2Cay2G3ZN7BK7PCrS01Pw5TTZFCmWWGdB+TjVtImdaQdLs5tDn778GR1L3ngQuKBQH4JzfPo+z2nVicb6OuwMk8BjWszs6KqRvIF5mQdJkaX53Ayg7g3SeEUGi8xhzVH71FUKr96kZtXa0GVancEOMMbB3P6tesVC63G0V74TsNKmar3bSKuul5IPSXbpMyi/Z9d1VYXM3FAHdp8vGVidoUv1y7LGfyvzOPnKW4DfX38s+PFLmpefsuq4wQODUQtmQhF/TYKRE8iVzapTjJUG6kNvrdVgK43yvotPQR67jbK17iJeP5S/1k3cHEwct2A4w5kuq1owNpSDPjDG5+Dbr9HxkhfxU/TvKBs7K1BpUPLlSd0qLioTorzKInwXF+/i5DHK4zIKZ6RDnmkmbHALSuDL9zIaKQJssWqjJ22faGUy2/7wkNYLz2RXIFho/NNvnz7OsG3CF5renM9Xvr1ikXXmTs3Tfbvw5abv03BGVSHJcnN3aZ9p3kqWkXYb6QzMbfgi06Lfw6dbD0S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0diRtaBMGQtWczIOhCWrCWLGdkdt4BZjMh3HCxZdD5G5DsOliw6HyPyHQdLlpKPEfmOgyUXBr9GVJ1T3Q06Cj/U59XDQQTuFWfavld4Fv9tjrJKtmfoZ6G02D+/vPRHV/c/Z9C91e91ctPr5JbRNa+LgBtQacmo6u+6epHfa3xWAu6UvdKue6nlkuyvOkCogCefZ/MYqdcZ0+vMzkV6wq7H9WV6NUwGdNmqW/I4SyKcBRhlyzHt5EXzgAroLdBzvUcP0XutBt5mgnYIW2+Bnut6OKhhkK/a8BpXxnl3QwS0ATWfGy/0zgLkC1AZjnT79BkMMZh2xjKy9jMeMOtAXUpV15fkeuy+knWPganZC5ph1F+jsv4wDyQNppMxI7ooyuMQjdIOKLkRrj9PA0lqkCUnqmOBCuTI4YgL8PQHJAnWJlZZX+5B7YHSY0XlY5z87R6CEygMsDXcGnUOvuXtBw9h/cEDSAGUoGJboHoMV6u6mPS6WbR2t9p5aJ4xgtYAZMsVZaeP6++rAG4w8xWHrpOnzZeeQA+LmqvqIT7gyY1c92QOLBjAyudS5aYeoCX9erQNN1rDGShBdUvOuP4WDojA8ihts2hwfJtHcSHekDQoc81twln3gTgYKVASN2R4AwazwucmVqVM6lf3IFc4j9mBbb51ADLAVHO5wu+jeymoe25YuzeBYLqAMTXcmDY66uAGJq+6IcfTFNS8bcrB3moAW4MRVm0L3H7QfiEF5HDNbNYdxQ1c/dV9LwbHC45tfaAp688egS2YO4orKaDF1QEKWXO5lumfRZogT1AamttUypTAq0G2mhtb6vCmAF7NdRN8hw3WCVBRkrUcDqsEXVTcsksMKDDT5NJ774kszqJTnERif7h/efkHLqjsTHw0AAA="; \ No newline at end of file diff --git a/assets/style.css b/assets/style.css index 98a43779..072daed8 100644 --- a/assets/style.css +++ b/assets/style.css @@ -405,7 +405,8 @@ dd { } body { background: var(--color-background); - font-family: "Segoe UI", sans-serif; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", + Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; color: var(--color-text); } diff --git a/classes/index.MultiaddrFilter.html b/classes/index.MultiaddrFilter.html index 205aefb5..d3124faa 100644 --- a/classes/index.MultiaddrFilter.html +++ b/classes/index.MultiaddrFilter.html @@ -4,8 +4,8 @@ multiaddr is in a ipcidr range.

Example

import { multiaddr, MultiaddrFilter } from '@multiformats/multiaddr'

const range = multiaddr('/ip4/192.168.10.10/ipcidr/24')
const filter = new MultiaddrFilter(range)

const input = multiaddr('/ip4/192.168.10.2/udp/60')
console.info(filter.contains(input)) // true
-

Constructors

Constructors

Properties

Methods

Constructors

Properties

multiaddr: Multiaddr
netmask: IpNet

Methods

Generated using TypeDoc

\ No newline at end of file +

Constructors

Properties

multiaddr: Multiaddr
netmask: IpNet

Methods

Generated using TypeDoc

\ No newline at end of file diff --git a/functions/convert.convert.html b/functions/convert.convert.html index 81d47cb3..e9a89c03 100644 --- a/functions/convert.convert.html +++ b/functions/convert.convert.html @@ -1,2 +1,2 @@ convert | @multiformats/multiaddr

Generated using TypeDoc

\ No newline at end of file +

Parameters

Returns Uint8Array

  • Parameters

    Returns string

  • Generated using TypeDoc

    \ No newline at end of file diff --git a/functions/convert.convertToBytes.html b/functions/convert.convertToBytes.html index 6b92bc2f..1583a2c2 100644 --- a/functions/convert.convertToBytes.html +++ b/functions/convert.convertToBytes.html @@ -1 +1 @@ -convertToBytes | @multiformats/multiaddr

    Generated using TypeDoc

    \ No newline at end of file +convertToBytes | @multiformats/multiaddr

    Generated using TypeDoc

    \ No newline at end of file diff --git a/functions/convert.convertToIpNet.html b/functions/convert.convertToIpNet.html index a18db518..66004660 100644 --- a/functions/convert.convertToIpNet.html +++ b/functions/convert.convertToIpNet.html @@ -1 +1 @@ -convertToIpNet | @multiformats/multiaddr

    Generated using TypeDoc

    \ No newline at end of file +convertToIpNet | @multiformats/multiaddr

    Generated using TypeDoc

    \ No newline at end of file diff --git a/functions/convert.convertToString.html b/functions/convert.convertToString.html index 4cf728d4..f837eb3a 100644 --- a/functions/convert.convertToString.html +++ b/functions/convert.convertToString.html @@ -1,2 +1,2 @@ convertToString | @multiformats/multiaddr
    • Convert [code,Uint8Array] to string

      -

      Parameters

      Returns string

    Generated using TypeDoc

    \ No newline at end of file +

    Parameters

    Returns string

    Generated using TypeDoc

    \ No newline at end of file diff --git a/functions/index.fromNodeAddress.html b/functions/index.fromNodeAddress.html index ba68a293..b89293fc 100644 --- a/functions/index.fromNodeAddress.html +++ b/functions/index.fromNodeAddress.html @@ -1,4 +1,4 @@ fromNodeAddress | @multiformats/multiaddr
    • Creates a Multiaddr from a node-friendly address object

      Parameters

      Returns Multiaddr

      Example

      import { fromNodeAddress } from '@multiformats/multiaddr'

      fromNodeAddress({address: '127.0.0.1', port: '4001'}, 'tcp')
      // Multiaddr(/ip4/127.0.0.1/tcp/4001)
      -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/functions/index.isMultiaddr.html b/functions/index.isMultiaddr.html index 36e2955e..db915527 100644 --- a/functions/index.isMultiaddr.html +++ b/functions/index.isMultiaddr.html @@ -1,4 +1,4 @@ isMultiaddr | @multiformats/multiaddr
    • Check if object is a Multiaddr instance

      -

      Parameters

      • value: any

      Returns value is Multiaddr

      Example

      import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'

      isMultiaddr(5)
      // false
      isMultiaddr(multiaddr('/ip4/127.0.0.1'))
      // true +

      Parameters

      • value: any

      Returns value is Multiaddr

      Example

      import { isMultiaddr, multiaddr } from '@multiformats/multiaddr'

      isMultiaddr(5)
      // false
      isMultiaddr(multiaddr('/ip4/127.0.0.1'))
      // true
      -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/functions/index.isName.html b/functions/index.isName.html index 8004495a..e455c653 100644 --- a/functions/index.isName.html +++ b/functions/index.isName.html @@ -1,4 +1,4 @@ isName | @multiformats/multiaddr
    • Returns if something is a Multiaddr that is a resolvable name

      Parameters

      Returns boolean

      Example

      import { isName, multiaddr } from '@multiformats/multiaddr'

      isName(multiaddr('/ip4/127.0.0.1'))
      // false
      isName(multiaddr('/dns/ipfs.io'))
      // true
      -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/functions/index.multiaddr-1.html b/functions/index.multiaddr-1.html index 6bc5a379..313ef41c 100644 --- a/functions/index.multiaddr-1.html +++ b/functions/index.multiaddr-1.html @@ -2,4 +2,4 @@

    Parameters

    Returns Multiaddr

    Example

    import { multiaddr } from '@libp2p/multiaddr'

    multiaddr('/ip4/127.0.0.1/tcp/4001')
    // Multiaddr(/ip4/127.0.0.1/tcp/4001)
    -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/functions/index.protocols.html b/functions/index.protocols.html index 879b951a..64fbf6b1 100644 --- a/functions/index.protocols.html +++ b/functions/index.protocols.html @@ -1,4 +1,4 @@ protocols | @multiformats/multiaddr
    • For the passed proto string or number, return a Protocol

      -

      Parameters

      • proto: string | number

      Returns Protocol

      Example

      import { protocol } from '@multiformats/multiaddr'

      console.info(protocol(4))
      // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false } +

      Parameters

      • proto: string | number

      Returns Protocol

      Example

      import { protocol } from '@multiformats/multiaddr'

      console.info(protocol(4))
      // { code: 4, size: 32, name: 'ip4', resolvable: false, path: false }
      -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/functions/resolvers.dnsaddrResolver.html b/functions/resolvers.dnsaddrResolver.html index 44236738..7d57e46c 100644 --- a/functions/resolvers.dnsaddrResolver.html +++ b/functions/resolvers.dnsaddrResolver.html @@ -1,4 +1 @@ -dnsaddrResolver | @multiformats/multiaddr
    • Resolver for dnsaddr addresses.

      -

      Parameters

      Returns Promise<string[]>

      Example

      import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
      import { multiaddr } from '@multiformats/multiaddr'

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

      console.info(addresses)
      //[
      // '/dnsaddr/am6.bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb',
      // '/dnsaddr/ny5.bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa',
      // '/dnsaddr/sg1.bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt',
      // '/dnsaddr/sv15.bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN'
      //] -
      -

    Generated using TypeDoc

    \ No newline at end of file +dnsaddrResolver | @multiformats/multiaddr

    Generated using TypeDoc

    \ No newline at end of file diff --git a/hierarchy.html b/hierarchy.html new file mode 100644 index 00000000..f1fa275f --- /dev/null +++ b/hierarchy.html @@ -0,0 +1 @@ +@multiformats/multiaddr

    @multiformats/multiaddr

    Class Hierarchy

    Generated using TypeDoc

    \ No newline at end of file diff --git a/index.html b/index.html index de917c45..207d9918 100644 --- a/index.html +++ b/index.html @@ -27,32 +27,20 @@
  • have a nice string representation
  • encapsulate well
  • -

    Example

    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")
    // Multiaddr(/ip4/127.0.0.1/udp/1234)

    addr.bytes
    // <Uint8Array 04 7f 00 00 01 11 04 d2>

    addr.toString()
    // '/ip4/127.0.0.1/udp/1234'

    addr.protos()
    // [
    // {code: 4, name: 'ip4', size: 32},
    // {code: 273, name: 'udp', size: 16}
    // ]

    // gives you an object that is friendly with what Node.js core modules expect for addresses
    addr.nodeAddress()
    // {
    // family: 4,
    // port: 1234,
    // address: "127.0.0.1"
    // }

    addr.encapsulate('/sctp/5678')
    // Multiaddr(/ip4/127.0.0.1/udp/1234/sctp/5678) +

    Example

    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")
    // Multiaddr(/ip4/127.0.0.1/udp/1234)

    addr.bytes
    // <Uint8Array 04 7f 00 00 01 11 04 d2>

    addr.toString()
    // '/ip4/127.0.0.1/udp/1234'

    addr.protos()
    // [
    // {code: 4, name: 'ip4', size: 32},
    // {code: 273, name: 'udp', size: 16}
    // ]

    // gives you an object that is friendly with what Node.js core modules expect for addresses
    addr.nodeAddress()
    // {
    // family: 4,
    // port: 1234,
    // address: "127.0.0.1"
    // }

    addr.encapsulate('/sctp/5678')
    // Multiaddr(/ip4/127.0.0.1/udp/1234/sctp/5678)
    -

    Resolvers

    multiaddr allows multiaddrs to be resolved when appropriate resolvers are provided. This module already has resolvers available, but you can also create your own. Resolvers should always be set in the same module that is calling multiaddr.resolve() to avoid conflicts if multiple versions of multiaddr are in your dependency tree.

    -

    To provide multiaddr resolvers you can do:

    -
    import { resolvers  } from '@multiformats/multiaddr'

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

    Resolving DNSADDR addresses

    DNSADDR is a spec that allows storing a TXT DNS record that contains a Multiaddr.

    +

    To resolve DNSADDR addresses, call the .resolve() function the multiaddr, optionally passing a DNS resolver.

    +

    DNSADDR addresses can resolve to multiple multiaddrs, since there is no limit to the number of TXT records that can be stored.

    +

    Example - Resolving DNSADDR Multiaddrs

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

    resolvers.set('dnsaddr', dnsaddr)

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

    // resolve with a 5s timeout
    const resolved = await ma.resolve({
    signal: AbortSignal.timeout(5000)
    })

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

    Example - Using a custom DNS resolver to resolve DNSADDR Multiaddrs

    See the docs for @multiformats/dns for a full breakdown of how to specify multiple resolvers or resolvers that can be used for specific TLDs.

    +
    import { multiaddr } from '@multiformats/multiaddr'
    import { dns } from '@multiformats/dns'
    import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'

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

    const ma = multiaddr('/dnsaddr/bootstrap.libp2p.io')
    const resolved = await ma.resolve({
    dns: resolver
    })

    console.info(resolved)
    // [Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...')...]
    -

    The available resolvers are:

    - - - - - - - - - - - - - -
    NametypeDescription
    dnsaddrResolverdnsaddrdnsaddr resolution with TXT Records
    -

    A resolver receives a Multiaddr as a parameter and returns a Promise<Array<string>>.

    Install

    $ npm i @multiformats/multiaddr
     

    Browser <script> tag

    Loading this module through a script tag will make it's exports available as MultiformatsMultiaddr in the global namespace.

    -
    <script src="https://unpkg.com/@multiformats/multiaddr/dist/index.min.js"></script>
    +
    <script src="https://unpkg.com/@multiformats/multiaddr/dist/index.min.js"></script>
     

    API Docs

    Contribution

    Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

    -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/interfaces/index.AbortOptions.html b/interfaces/index.AbortOptions.html index 54ec0580..a40d008f 100644 --- a/interfaces/index.AbortOptions.html +++ b/interfaces/index.AbortOptions.html @@ -1,3 +1,3 @@ AbortOptions | @multiformats/multiaddr

    Allows aborting long-lived operations

    -
    interface AbortOptions {
        signal?: AbortSignal;
    }

    Properties

    Properties

    signal?: AbortSignal

    Generated using TypeDoc

    \ No newline at end of file +
    interface AbortOptions {
        signal?: AbortSignal;
    }

    Hierarchy (view full)

    Properties

    Properties

    signal?: AbortSignal

    Generated using TypeDoc

    \ No newline at end of file diff --git a/interfaces/index.Multiaddr.html b/interfaces/index.Multiaddr.html index ad4cbaa7..c7d98004 100644 --- a/interfaces/index.Multiaddr.html +++ b/interfaces/index.Multiaddr.html @@ -1,4 +1,4 @@ -Multiaddr | @multiformats/multiaddr
    interface Multiaddr {
        bytes: Uint8Array;
        decapsulate(addr): Multiaddr;
        decapsulateCode(code): Multiaddr;
        encapsulate(addr): Multiaddr;
        equals(addr): boolean;
        getPath(): null | string;
        getPeerId(): null | string;
        isThinWaistAddress(addr?): boolean;
        nodeAddress(): NodeAddress;
        protoCodes(): number[];
        protoNames(): string[];
        protos(): Protocol[];
        resolve(options?): Promise<Multiaddr[]>;
        stringTuples(): StringTuple[];
        toJSON(): string;
        toOptions(): MultiaddrObject;
        toString(): string;
        tuples(): Tuple[];
    }

    Properties

    bytes +Multiaddr | @multiformats/multiaddr
    interface Multiaddr {
        bytes: Uint8Array;
        decapsulate(addr): Multiaddr;
        decapsulateCode(code): Multiaddr;
        encapsulate(addr): Multiaddr;
        equals(addr): boolean;
        getPath(): null | string;
        getPeerId(): null | string;
        isThinWaistAddress(addr?): boolean;
        nodeAddress(): NodeAddress;
        protoCodes(): number[];
        protoNames(): string[];
        protos(): Protocol[];
        resolve(options?): Promise<Multiaddr[]>;
        stringTuples(): StringTuple[];
        toJSON(): string;
        toOptions(): MultiaddrObject;
        toString(): string;
        tuples(): Tuple[];
    }

    Properties

    Methods

    Properties

    bytes: Uint8Array

    Methods

    • Decapsulates a Multiaddr from another Multiaddr

      +

    Properties

    bytes: Uint8Array

    Methods

    • Decapsulates a Multiaddr from another Multiaddr

      Parameters

      • addr: string | Multiaddr

        Multiaddr to remove from this Multiaddr

      Returns Multiaddr

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      const mh1 = multiaddr('/ip4/8.8.8.8/tcp/1080')
      // Multiaddr(/ip4/8.8.8.8/tcp/1080)

      const mh2 = multiaddr('/ip4/127.0.0.1/tcp/4001')
      // Multiaddr(/ip4/127.0.0.1/tcp/4001)

      const mh3 = mh1.encapsulate(mh2)
      // Multiaddr(/ip4/8.8.8.8/tcp/1080/ip4/127.0.0.1/tcp/4001)

      mh3.decapsulate(mh2).toString()
      // '/ip4/8.8.8.8/tcp/1080'
      -
    • A more reliable version of decapsulate if you are targeting a +

    • A more reliable version of decapsulate if you are targeting a specific code, such as 421 (the p2p protocol code). The last index of the code will be removed from the Multiaddr, and a new instance will be returned. If the code is not present, the original Multiaddr is returned.

      -

      Parameters

      • code: number

      Returns Multiaddr

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      const addr = multiaddr('/ip4/0.0.0.0/tcp/8080/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC')
      // Multiaddr(/ip4/0.0.0.0/tcp/8080/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC)

      addr.decapsulateCode(421).toString()
      // '/ip4/0.0.0.0/tcp/8080'

      multiaddr('/ip4/127.0.0.1/tcp/8080').decapsulateCode(421).toString()
      // '/ip4/127.0.0.1/tcp/8080' +

      Parameters

      • code: number

      Returns Multiaddr

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      const addr = multiaddr('/ip4/0.0.0.0/tcp/8080/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC')
      // Multiaddr(/ip4/0.0.0.0/tcp/8080/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC)

      addr.decapsulateCode(421).toString()
      // '/ip4/0.0.0.0/tcp/8080'

      multiaddr('/ip4/127.0.0.1/tcp/8080').decapsulateCode(421).toString()
      // '/ip4/127.0.0.1/tcp/8080'
      -
    • Encapsulates a Multiaddr in another Multiaddr

      Parameters

      Returns Multiaddr

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      const mh1 = multiaddr('/ip4/8.8.8.8/tcp/1080')
      // Multiaddr(/ip4/8.8.8.8/tcp/1080)

      const mh2 = multiaddr('/ip4/127.0.0.1/tcp/4001')
      // Multiaddr(/ip4/127.0.0.1/tcp/4001)

      const mh3 = mh1.encapsulate(mh2)
      // Multiaddr(/ip4/8.8.8.8/tcp/1080/ip4/127.0.0.1/tcp/4001)

      mh3.toString()
      // '/ip4/8.8.8.8/tcp/1080/ip4/127.0.0.1/tcp/4001'
      -
    • Checks if two Multiaddrs are the same

      +
    • Checks if two Multiaddrs are the same

      Parameters

      Returns boolean

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      const mh1 = multiaddr('/ip4/8.8.8.8/tcp/1080')
      // Multiaddr(/ip4/8.8.8.8/tcp/1080)

      const mh2 = multiaddr('/ip4/127.0.0.1/tcp/4001')
      // Multiaddr(/ip4/127.0.0.1/tcp/4001)

      mh1.equals(mh1)
      // true

      mh1.equals(mh2)
      // false
      -
    • Extract the path if the multiaddr contains one

      +
    • Extract the path if the multiaddr contains one

      Returns null | string

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      const mh1 = multiaddr('/ip4/8.8.8.8/tcp/1080/unix/tmp/p2p.sock')
      // Multiaddr(/ip4/8.8.8.8/tcp/1080/unix/tmp/p2p.sock)

      // should return utf8 string or null if the id is missing or invalid
      const path = mh1.getPath()
      -
    • Extract the peerId if the multiaddr contains one

      +
    • Extract the peerId if the multiaddr contains one

      Returns null | string

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      const mh1 = multiaddr('/ip4/8.8.8.8/tcp/1080/ipfs/QmValidBase58string')
      // Multiaddr(/ip4/8.8.8.8/tcp/1080/ipfs/QmValidBase58string)

      // should return QmValidBase58string or null if the id is missing or invalid
      const peerId = mh1.getPeerId()
      -
    • Returns if a Multiaddr is a Thin Waist address or not.

      +
    • Returns if a Multiaddr is a Thin Waist address or not.

      Thin Waist is if a Multiaddr adheres to the standard combination of:

      {IPv4, IPv6}/{TCP, UDP}

      Parameters

      Returns boolean

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      const mh1 = multiaddr('/ip4/127.0.0.1/tcp/4001')
      // Multiaddr(/ip4/127.0.0.1/tcp/4001)
      const mh2 = multiaddr('/ip4/192.168.2.1/tcp/5001')
      // Multiaddr(/ip4/192.168.2.1/tcp/5001)
      const mh3 = mh1.encapsulate(mh2)
      // Multiaddr(/ip4/127.0.0.1/tcp/4001/ip4/192.168.2.1/tcp/5001)
      const mh4 = multiaddr('/ip4/127.0.0.1/tcp/2000/wss/p2p-webrtc-star/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2a')
      // Multiaddr(/ip4/127.0.0.1/tcp/2000/wss/p2p-webrtc-star/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2a)
      mh1.isThinWaistAddress()
      // true
      mh2.isThinWaistAddress()
      // true
      mh3.isThinWaistAddress()
      // false
      mh4.isThinWaistAddress()
      // false
      -
    • Gets a Multiaddrs node-friendly address object. Note that protocol information +

    • Gets a Multiaddrs node-friendly address object. Note that protocol information is left out: in Node (and most network systems) the protocol is unknowable given only the address.

      Has to be a ThinWaist Address, otherwise throws error

      Returns NodeAddress

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      multiaddr('/ip4/127.0.0.1/tcp/4001').nodeAddress()
      // {family: 4, address: '127.0.0.1', port: 4001}
      -
    • Returns the codes of the protocols in left-to-right order. +

    • Returns the codes of the protocols in left-to-right order. See list of protocols

      Returns number[]

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      multiaddr('/ip4/127.0.0.1/tcp/4001').protoCodes()
      // [ 4, 6 ]
      -
    • Returns the names of the protocols in left-to-right order. +

    • Returns the names of the protocols in left-to-right order. See list of protocols

      Returns string[]

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      multiaddr('/ip4/127.0.0.1/tcp/4001').protoNames()
      // [ 'ip4', 'tcp' ]
      -
    • Returns the protocols the Multiaddr is defined with, as an array of objects, in +

    • Returns the protocols the Multiaddr is defined with, as an array of objects, in left-to-right order. Each object contains the protocol code, protocol name, and the size of its address space in bits. See list of protocols

      Returns Protocol[]

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      multiaddr('/ip4/127.0.0.1/tcp/4001').protos()
      // [ { code: 4, size: 32, name: 'ip4' },
      // { code: 6, size: 16, name: 'tcp' } ]
      -
    • Resolve multiaddr if containing resolvable hostname.

      -

      Parameters

      Returns Promise<Multiaddr[]>

      Example

      import { multiaddr, resolvers } from '@multiformats/multiaddr'

      resolvers.set('dnsaddr', resolverFunction)
      const mh1 = multiaddr('/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb')
      const resolvedMultiaddrs = await mh1.resolve()
      // [
      // Multiaddr(/ip4/147.75.83.83/tcp/4001/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb),
      // Multiaddr(/ip4/147.75.83.83/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb),
      // Multiaddr(/ip4/147.75.83.83/udp/4001/quic/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb)
      // ] +
    • Resolve multiaddr if containing resolvable hostname.

      +

      Parameters

      Returns Promise<Multiaddr[]>

      Example

      import { multiaddr, resolvers } from '@multiformats/multiaddr'

      resolvers.set('dnsaddr', resolverFunction)
      const mh1 = multiaddr('/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb')
      const resolvedMultiaddrs = await mh1.resolve()
      // [
      // Multiaddr(/ip4/147.75.83.83/tcp/4001/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb),
      // Multiaddr(/ip4/147.75.83.83/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb),
      // Multiaddr(/ip4/147.75.83.83/udp/4001/quic/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb)
      // ]
      -
    • Returns a tuple of string/number parts

      • tuples[][0] = code of protocol
      • tuples[][1] = contents of address

      Returns StringTuple[]

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      multiaddr('/ip4/127.0.0.1/tcp/4001').stringTuples()
      // [ [ 4, '127.0.0.1' ], [ 6, '4001' ] ]
      -
    • Returns Multiaddr as a JSON encoded object

      +
    • Returns Multiaddr as a JSON encoded object

      Returns string

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      JSON.stringify(multiaddr('/ip4/127.0.0.1/tcp/4001'))
      // '/ip4/127.0.0.1/tcp/4001'
      -
    • Returns Multiaddr as a convinient options object to be used with net.createConnection

      +
    • Returns Multiaddr as a convinient options object to be used with net.createConnection

      Returns MultiaddrObject

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      multiaddr('/ip4/127.0.0.1/tcp/4001').toOptions()
      // { family: 4, host: '127.0.0.1', transport: 'tcp', port: 4001 }
      -
    • Returns Multiaddr as a String

      +
    • Returns Multiaddr as a String

      Returns string

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      multiaddr('/ip4/127.0.0.1/tcp/4001').toString()
      // '/ip4/127.0.0.1/tcp/4001'
      -
    • Returns a tuple of parts

      Returns Tuple[]

      Example

      import { multiaddr } from '@multiformats/multiaddr'

      multiaddr('/ip4/127.0.0.1/tcp/4001').tuples()
      // [ [ 4, <Buffer 7f 00 00 01> ], [ 6, <Buffer 0f a1> ] ]
      -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/interfaces/index.MultiaddrObject.html b/interfaces/index.MultiaddrObject.html index 53424bb4..d71c743d 100644 --- a/interfaces/index.MultiaddrObject.html +++ b/interfaces/index.MultiaddrObject.html @@ -1,6 +1,6 @@ MultiaddrObject | @multiformats/multiaddr

    A plain JavaScript object representation of a Multiaddr

    -
    interface MultiaddrObject {
        family: 4 | 6;
        host: string;
        port: number;
        transport: string;
    }

    Properties

    interface MultiaddrObject {
        family: 4 | 6;
        host: string;
        port: number;
        transport: string;
    }

    Properties

    family: 4 | 6
    host: string
    port: number
    transport: string

    Generated using TypeDoc

    \ No newline at end of file +

    Properties

    family: 4 | 6
    host: string
    port: number
    transport: string

    Generated using TypeDoc

    \ No newline at end of file diff --git a/interfaces/index.NodeAddress.html b/interfaces/index.NodeAddress.html index ffef42c3..e7b98419 100644 --- a/interfaces/index.NodeAddress.html +++ b/interfaces/index.NodeAddress.html @@ -1,5 +1,5 @@ NodeAddress | @multiformats/multiaddr

    A NodeAddress is an IPv4/IPv6 address/TCP port combination

    -
    interface NodeAddress {
        address: string;
        family: 4 | 6;
        port: number;
    }

    Properties

    interface NodeAddress {
        address: string;
        family: 4 | 6;
        port: number;
    }

    Properties

    Properties

    address: string
    family: 4 | 6
    port: number

    Generated using TypeDoc

    \ No newline at end of file +

    Properties

    address: string
    family: 4 | 6
    port: number

    Generated using TypeDoc

    \ No newline at end of file diff --git a/interfaces/index.Protocol.html b/interfaces/index.Protocol.html index 5ffd867c..06064229 100644 --- a/interfaces/index.Protocol.html +++ b/interfaces/index.Protocol.html @@ -1,7 +1,7 @@ Protocol | @multiformats/multiaddr

    Protocols are present in the protocol table

    -
    interface Protocol {
        code: number;
        name: string;
        path?: boolean;
        resolvable?: boolean;
        size: number;
    }

    Properties

    interface Protocol {
        code: number;
        name: string;
        path?: boolean;
        resolvable?: boolean;
        size: number;
    }

    Properties

    code: number
    name: string
    path?: boolean
    resolvable?: boolean
    size: number

    Generated using TypeDoc

    \ No newline at end of file +

    Properties

    code: number
    name: string
    path?: boolean
    resolvable?: boolean
    size: number

    Generated using TypeDoc

    \ No newline at end of file diff --git a/interfaces/index.ResolveOptions.html b/interfaces/index.ResolveOptions.html new file mode 100644 index 00000000..52394ee3 --- /dev/null +++ b/interfaces/index.ResolveOptions.html @@ -0,0 +1,10 @@ +ResolveOptions | @multiformats/multiaddr

    Allows aborting long-lived operations

    +
    interface ResolveOptions {
        dns?: DNS;
        maxRecursiveDepth?: number;
        signal?: AbortSignal;
    }

    Hierarchy (view full)

    Properties

    dns?: DNS

    An optional DNS resolver

    +
    maxRecursiveDepth?: number

    When resolving DNSADDR Multiaddrs that resolve to other DNSADDR Multiaddrs, +limit how many times we will recursively resolve them.

    +

    Default

    32
    +
    +
    signal?: AbortSignal

    Generated using TypeDoc

    \ No newline at end of file diff --git a/interfaces/index.Resolver.html b/interfaces/index.Resolver.html deleted file mode 100644 index 46a3c25f..00000000 --- a/interfaces/index.Resolver.html +++ /dev/null @@ -1,3 +0,0 @@ -Resolver | @multiformats/multiaddr

    A Resolver is a function that takes a Multiaddr and resolves it into one -or more string representations of that Multiaddr.

    -
    interface Resolver ((addr, options?) => Promise<string[]>)

    Generated using TypeDoc

    \ No newline at end of file diff --git a/interfaces/resolvers.Resolver.html b/interfaces/resolvers.Resolver.html new file mode 100644 index 00000000..3c269359 --- /dev/null +++ b/interfaces/resolvers.Resolver.html @@ -0,0 +1 @@ +Resolver | @multiformats/multiaddr

    Interface Resolver<ResolveOptions>

    interface Resolver<ResolveOptions> ((ma, options?) => Promise<string[]>)

    Type Parameters

    Generated using TypeDoc

    \ No newline at end of file diff --git a/modules/convert.html b/modules/convert.html index 4131f228..d755cd5c 100644 --- a/modules/convert.html +++ b/modules/convert.html @@ -1,5 +1,5 @@ convert | @multiformats/multiaddr

    Provides methods for converting

    -

    Index

    Functions

    Index

    Functions

    convert convertToBytes convertToIpNet convertToString diff --git a/modules/index.html b/modules/index.html index c07c37c3..2bc419dd 100644 --- a/modules/index.html +++ b/modules/index.html @@ -6,35 +6,24 @@
  • have a nice string representation
  • encapsulate well
  • -

    Example

    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")
    // Multiaddr(/ip4/127.0.0.1/udp/1234)

    addr.bytes
    // <Uint8Array 04 7f 00 00 01 11 04 d2>

    addr.toString()
    // '/ip4/127.0.0.1/udp/1234'

    addr.protos()
    // [
    // {code: 4, name: 'ip4', size: 32},
    // {code: 273, name: 'udp', size: 16}
    // ]

    // gives you an object that is friendly with what Node.js core modules expect for addresses
    addr.nodeAddress()
    // {
    // family: 4,
    // port: 1234,
    // address: "127.0.0.1"
    // }

    addr.encapsulate('/sctp/5678')
    // Multiaddr(/ip4/127.0.0.1/udp/1234/sctp/5678) +

    Example

    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")
    // Multiaddr(/ip4/127.0.0.1/udp/1234)

    addr.bytes
    // <Uint8Array 04 7f 00 00 01 11 04 d2>

    addr.toString()
    // '/ip4/127.0.0.1/udp/1234'

    addr.protos()
    // [
    // {code: 4, name: 'ip4', size: 32},
    // {code: 273, name: 'udp', size: 16}
    // ]

    // gives you an object that is friendly with what Node.js core modules expect for addresses
    addr.nodeAddress()
    // {
    // family: 4,
    // port: 1234,
    // address: "127.0.0.1"
    // }

    addr.encapsulate('/sctp/5678')
    // Multiaddr(/ip4/127.0.0.1/udp/1234/sctp/5678)
    -

    Resolvers

    multiaddr allows multiaddrs to be resolved when appropriate resolvers are provided. This module already has resolvers available, but you can also create your own. Resolvers should always be set in the same module that is calling multiaddr.resolve() to avoid conflicts if multiple versions of multiaddr are in your dependency tree.

    -

    To provide multiaddr resolvers you can do:

    -
    import { resolvers  } from '@multiformats/multiaddr'

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

    Resolving DNSADDR addresses

    DNSADDR is a spec that allows storing a TXT DNS record that contains a Multiaddr.

    +

    To resolve DNSADDR addresses, call the .resolve() function the multiaddr, optionally passing a DNS resolver.

    +

    DNSADDR addresses can resolve to multiple multiaddrs, since there is no limit to the number of TXT records that can be stored.

    +

    Example: Resolving DNSADDR Multiaddrs

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

    resolvers.set('dnsaddr', dnsaddr)

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

    // resolve with a 5s timeout
    const resolved = await ma.resolve({
    signal: AbortSignal.timeout(5000)
    })

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

    The available resolvers are:

    - - - - - - - - - - - - - -
    NametypeDescription
    dnsaddrResolverdnsaddrdnsaddr resolution with TXT Records
    -

    A resolver receives a Multiaddr as a parameter and returns a Promise<Array<string>>.

    -

    Index

    Classes

    MultiaddrFilter +

    Example: Using a custom DNS resolver to resolve DNSADDR Multiaddrs

    See the docs for @multiformats/dns for a full breakdown of how to specify multiple resolvers or resolvers that can be used for specific TLDs.

    +
    import { multiaddr } from '@multiformats/multiaddr'
    import { dns } from '@multiformats/dns'
    import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'

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

    const ma = multiaddr('/dnsaddr/bootstrap.libp2p.io')
    const resolved = await ma.resolve({
    dns: resolver
    })

    console.info(resolved)
    // [Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...'), Multiaddr('/ip4/147.75...')...] +
    +

    Generated using TypeDoc

    \ No newline at end of file +

    References

    Re-exports Resolver

    Generated using TypeDoc

    \ No newline at end of file diff --git a/modules/resolvers.html b/modules/resolvers.html index daaa3f59..d37a890b 100644 --- a/modules/resolvers.html +++ b/modules/resolvers.html @@ -1,3 +1,3 @@ -resolvers | @multiformats/multiaddr

    Provides strategies for resolving multiaddrs.

    -

    Index

    Functions

    dnsaddrResolver +resolvers | @multiformats/multiaddr

    Index

    Interfaces

    Functions

    Generated using TypeDoc

    \ No newline at end of file diff --git a/types/index.MultiaddrInput.html b/types/index.MultiaddrInput.html index 0cc94921..70403dad 100644 --- a/types/index.MultiaddrInput.html +++ b/types/index.MultiaddrInput.html @@ -1,2 +1,2 @@ MultiaddrInput | @multiformats/multiaddr
    MultiaddrInput: string | Multiaddr | Uint8Array | null

    These types can be parsed into a Multiaddr object

    -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/types/index.StringTuple.html b/types/index.StringTuple.html index 959f44d7..25d5b782 100644 --- a/types/index.StringTuple.html +++ b/types/index.StringTuple.html @@ -1,2 +1,2 @@ StringTuple | @multiformats/multiaddr
    StringTuple: [number, string?]

    A code/value pair with the value as a string

    -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/types/index.Tuple.html b/types/index.Tuple.html index b589daa1..325a51e1 100644 --- a/types/index.Tuple.html +++ b/types/index.Tuple.html @@ -1,2 +1,2 @@ Tuple | @multiformats/multiaddr
    Tuple: [number, Uint8Array?]

    A code/value pair

    -

    Generated using TypeDoc

    \ No newline at end of file +

    Generated using TypeDoc

    \ No newline at end of file diff --git a/variables/index.resolvers.html b/variables/index.resolvers.html index ddd6e304..ce5c00dd 100644 --- a/variables/index.resolvers.html +++ b/variables/index.resolvers.html @@ -1,2 +1,2 @@ -resolvers | @multiformats/multiaddr
    resolvers: Map<string, Resolver> = ...

    All configured Resolvers

    -

    Generated using TypeDoc

    \ No newline at end of file +resolvers | @multiformats/multiaddr
    resolvers: Map<string, Resolver<AbortOptions>> = ...

    All configured Resolvers

    +

    Generated using TypeDoc

    \ No newline at end of file