@libp2p/memory
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@libp2p/tcp

@libp2p/memory

libp2p.io Discuss codecov CI

A memory transport for libp2p

About

A libp2p transport that operates in-memory only.

This is intended for testing and can only be used to connect two libp2p nodes that are running in the same process.

Example

import { createLibp2p } from 'libp2p'
import { memory } from '@libp2p/memory'
import { multiaddr } from '@multiformats/multiaddr'

const listener = await createLibp2p({
  addresses: {
    listen: [
      '/memory/address-a'
    ]
  },
  transports: [
    memory()
  ]
})

const dialer = await createLibp2p({
  transports: [
    memory()
  ]
})

const ma = multiaddr('/memory/address-a')

// dial the listener, timing out after 10s
const connection = await dialer.dial(ma, {
  signal: AbortSignal.timeout(10_000)
})

// use connection...

Install

$ npm i @libp2p/memory

Browser <script> tag

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

<script src="https://unpkg.com/@libp2p/memory/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.

Dependents (1)

Package Sidebar

Install

npm i @libp2p/memory

Weekly Downloads

144

Version

1.0.2

License

Apache-2.0 OR MIT

Unpacked Size

90.3 kB

Total Files

24

Last publish

Collaborators

  • daviddias
  • alanshaw
  • achingbrain
  • vascosantos
  • npm-service-account-libp2p
  • jacobheun