Socket
Socket
Sign inDemoInstall

@geut/hypercore-promise

Package Overview
Dependencies
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@geut/hypercore-promise

An async/await based wrapper for hypercore (v8+)


Version published
Weekly downloads
21
increased by200%
Maintainers
5
Weekly downloads
 
Created
Source

hypercore-promise

Build Status JavaScript Style Guide standard-readme compliant

An async/await based wrapper for hypercore (v9+)

Install

$ npm install @geut/hypercore-promise

Usage

const hypercore = require('@geut/hypercore-promise')

;(async () => {
  const feed = hypercore('./my-first-dataset', {valueEncoding: 'utf-8'})

  await feed.append('hello')
  await feed.append('world')

  console.log(await feed.get(0)) // prints hello
  console.log(await feed.get(1)) // prints world
})

Differences with Hypercore

Some methods like get and download not only use callbacks but also returns a value directly.

const id = feed.get(0, (err, data) => {
  console.log(data)
})

Since our methods return promises what you need to do to get the internal value is to use our function helper getValue.

const { getValue } = require('hypercore-promise')

const promise = feed.get(0)
const id = getValue(promise)
promise.then(data => console.log(data))

hypercore-promise already detects the internal value so you don't need to use getValue in that case.

const promise = feed.get(0)
feed.cancel(promise)
promise.catch(err => {
  console.log('was canceled')
})

Issues

:bug: If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.

Contributing

:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this guideline.

License

MIT © A GEUT project

Keywords

FAQs

Package last updated on 24 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc