libp2p
    Preparing search index...

    Module @libp2p/utils

    @libp2p/utils

    libp2p.io Discuss codecov CI

    Package to aggregate shared logic and dependencies for the libp2p ecosystem

    About

    The libp2p ecosystem has lots of repos with it comes several problems like:

    • Domain logic dedupe - all modules shared a lot of logic like validation, streams handling, etc.
    • Dependencies management - it's really easy with so many repos for dependencies to go out of control, they become outdated, different repos use different modules to do the same thing (like merging defaults options), browser bundles ends up with multiple versions of the same package, bumping versions is cumbersome to do because we need to go through several repos, etc.

    These problems are the motivation for this package, having shared logic in this package avoids creating cyclic dependencies, centralizes common use modules/functions (exactly like aegir does for the tooling), semantic versioning for 3rd party dependencies is handled in one single place (a good example is going from streams 2 to 3) and maintainers should only care about having libp2p-utils updated.

    Each function should be imported directly.

    import { ipPortToMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr'

    const ma = ipPortToMultiaddr('127.0.0.1', 9000)

    Install

    $ npm i @libp2p/utils
    

    Loading this module through a script tag will make its exports available as Libp2pUtils in the global namespace.

    <script src="https://unpkg.com/@libp2p/utils/dist/index.min.js"></script>
    

    API Docs

    License

    Licensed under either of

    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.

    Modules

    abort-options
    abstract-stream
    adaptive-timeout
    array-equals
    close
    close-source
    debounce
    filters
    get-thin-waist-addresses
    global-unicast-ip
    index
    ip-port-to-multiaddr
    is-async-generator
    is-generator
    is-promise
    merge-options
    moving-average
    multiaddr/is-global-unicast
    multiaddr/is-ip-based
    multiaddr/is-loopback
    multiaddr/is-network-address
    multiaddr/is-private
    peer-queue
    priority-queue
    private-ip
    queue
    rate-limiter
    repeating-task
    stream-to-ma-conn
    tracked-list
    tracked-map