Socket
Book a DemoInstallSign in
Socket

hypercore-detector

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypercore-detector

Detect the type of a Hypercore

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Hypercore Detector

Detect the type of a Hypercore (Hypercore, Hyperbee or Hyperdrive)

Install

npm i hypercore-detector

Usage

const detect = require('hypercore-detector')

let type = await detect(aHypercore)

if (!type) {
  type = detect(aHypercore, { wait: true })
}

if (type === 'bee') {
  console.log('I am a bee')
} else if (type === 'drive') {
  console.log('I am the db core of a drive')
} else {
  console.log('I am a basic hypercore')
}

API

const type = await detect(hypercore, opts?)

Detect the type of the hypercore.

returns either 'core', 'bee', 'drive' or null.

null is returned when it is not yet possible to determine the type. Set opts.wait = true if instead you want to wait until the type can be determined.

Do note that this will wait until the first block of the hypercore becomes locally available, so make sure you are either the writer, or are swarming on this core.

Keywords

Hypercore

FAQs

Package last updated on 12 Jun 2023

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