@hyperswarm/immutable-record

1.1.0 • Public • Published

@hyperswarm/immutable-record

Stateful Immutable record that can reannounce itself and more.

npm install @hyperswarm/immutable-record

Usage

const ImmutableRecord = require('@hyperswarm/immutable-record')

Inserting values in the DHT

const record = ImmutableRecord.put(dhtNode, Buffer.from('some value'))

// To announce it ~every 15-20 min
// Returns a promise that will resolve when its unannounced
record.announce()

// Call unannounce to stop announcing
// Resolves the promises returned above
record.unannounce()

Retrieving them

const record = ImmutableRecord.get(dhtNode, keyBufferOrHex)

console.log('value is', await record.get())

// Similar to the insertion above you can reinsert this as well
// with the announce/unannounce methods
record.announce()

Note that unannounce does not destroy the DHT instance.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @hyperswarm/immutable-record

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

6.53 kB

Total Files

5

Last publish

Collaborators

  • kasperisager
  • mafintosh
  • davidmarkclements