OverviewFilesCommitsIssuesDocsReleasesPeers

holepunchto-kb / skills / hyperdht / api-extract.json

88 lines · json ref:
{
  "repo": "hyperdht",
  "timestamp": "2026-01-16T23:00:28.520Z",
  "entryPoint": "index.js",
  "exports": {
    "packageJson": {
      "main": "index.js"
    }
  },
  "api": {
    "file": "index.js",
    "exports": [
      {
        "type": "default",
        "name": "HyperDHT"
      }
    ],
    "classes": [
      {
        "name": "HyperDHT"
      }
    ],
    "functions": [
      {
        "name": "commit"
      },
      {
        "name": "map"
      },
      {
        "name": "commit"
      },
      {
        "name": "commit"
      },
      {
        "name": "mapLookup"
      },
      {
        "name": "mapFindPeer"
      },
      {
        "name": "mapImmutable"
      },
      {
        "name": "mapMutable"
      },
      {
        "name": "noop"
      },
      {
        "name": "filterNode"
      },
      {
        "name": "defaultCacheOpts"
      }
    ]
  },
  "readme": {
    "content": "# hyperdht\n\n### [See the full API docs at docs.pears.com](https://docs.pears.com/building-blocks/hyperdht)\n\nThe DHT powering Hyperswarm\n\n```\nnpm install hyperdht\n```\n\nBuilt on top of [dht-rpc](https://github.com/mafintosh/dht-rpc).\n\nThe Hyperswarm DHT uses a series of holepunching techniques to make sure connectivity works on most networks,\nand is mainly used to facilitate finding and connecting to peers using end to end encrypted Noise streams.\n\n## Usage\n\nTo try it out, first instantiate a DHT instance\n\n```js\nimport DHT from 'hyperdht'\n\nconst node = new DHT()\n```\n\nThen on one computer listen for connections\n\n```js\n// create a server to listen for secure connections\nconst server = node.createServer()\n\nserver.on('connection', function (socket) {\n  // socket is E2E encrypted between you and the other peer\n  console.log('Remote public key', socket.remotePublicKey)\n\n  // pipe it somewhere like any duplex stream\n  process.stdin.pipe(socket).pipe(process.stdout)\n})\n\n// make a ed25519 keypair",
    "sections": [
      "intro",
      "usage",
      "api",
      "creating p2p servers",
      "connecting to p2p servers",
      "additional peer discovery",
      "mutable/immutable records",
      "additional api",
      "cli",
      "license"
    ],
    "hasApi": true,
    "hasExamples": true,
    "exampleCount": 14,
    "examples": [
      "npm install hyperdht",
      "import DHT from 'hyperdht'\n\nconst node = new DHT()",
      "// create a server to listen for secure connections\nconst server = node.createServer()\n\nserver.on('connection', function (socket) {\n  // socket is E2E encrypted between you and the other peer\n  console.log('Remote public key', socket.remotePublicKey)\n\n  // pipe it somewhere like any duplex stream\n  process.stdin.pipe(socket).pipe(process.stdout)\n})\n\n// make a ed25519 keypair to listen on\nconst keyPair = DHT.keyPair()\n\n// this makes the server accept connections on this keypair\nawait server.listen(keyPair)"
    ]
  },
  "patterns": [
    "dht-discovery",
    "binary-encoding",
    "cryptography",
    "streaming"
  ]
}