1.1.0 • Published 3 years ago

@hyperswarm/immutable-record v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

@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