npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

peer-pad-core

v0.13.0

Published

[![made by Protocol Labs](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.io) [![Freenode](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channel

Readme

peerpad-core

made by Protocol Labs Freenode

Peerpad core API

Install

$ npm install peerpad-core --save

Import

const PeerpadBackend = require('peerpad-core')

PeerpadBackend.generateRandomName()

Returns a random pad name (string).

PeerpadBackend.generateRandomKeys()

Generates a set of read and write random keys.

Returns a promise that resolves to:

{
  "read": "base58-encoded string",
  "write": "base58-encoded string",
}

PeerpadBackend(options)

Creates a Peerpad backend.

const backend = PeerpadBackend(options)

Options:

  • ipfs: IPFS (version 0.27 or higher) node that is already created (optional). If not passed in, one will be created for you.

PeerpadBackend

backend.ipfs

The IPFS node.

async backend.start()

Starts the backend. Returns a promise that resolves once the backend has started.

async backend.stop()

Stops the backend.

Network: backend.network

backend.network.hasStarted()

Returns a boolean, true if the IPFS node has started.

backend.network.once('started', fn)

Emitted once the IPFS node starts. If you passed in an IPFS node that is already started (via options.ipfs), this event doesn't get emitted.

backend.createDocument(options)

const options = {
  name: 'name of the pad',
  type: 'richtext',
  readKey: 'gobelegook',
  writeKey: 'moregobelegook'
}

const document = backend.createDocument(options)

options:

  • name: string that uniquely identifies this
  • type: string that identifies type of document. Currently supports text, richtext or math.
  • readKey: string containing the read key
  • writeKey: string containing the write key (optional)
  • peerAlias: string identifying the current author. Defaults to the IPFS peerId

Document

Peers: document.peers

document.peers.all()

Returns an array of peers:

document.peers.all()
// returns:
[
  {
    id: 'QmHashHash1',
    permissions: {
      admin: false,
      write: true,
      read: true
    }
  },
  {
    id: 'QmHashHash2',
    permissions: {
      admin: false,
      write: false,
      read: true
    }
  }
]

document.peers.on('change', fn)

Emitted when there is a change in the peer list:

document.peers.on('change', () => {
  console.log('peers changed and now are', peerpad.peers.all())
})

document.setPeerAlias(peerAlias)

Sets the current peer alias. peerAlias must be a string.

document.bindEditor(editor)

Bind CodeMirror editor (for pad of type markdown or text) or Quill editor (for pad of type richtext).

Two-way bind to a editor. Example for Quill:

import Quill from 'quill'

const editor = new Quill('#editor')

document.bindEditor(editor)

Example for CodeMirror:

import Codemirror from 'codemirror'

const editor = CodeMirror.fromTextArea(myTextArea)

document.bindEditor(editor)

document.unbindEditor(editor)

Unbinds editor.

document.bindTitle(element)

Bind the document title to an editing element (like a textarea or a text input field).

document.unbindTitle(element)

Unbind the document title from an editing element.

async document.convertMarkdown(markdown, type)

Converts markdown to HTML.

document.on('change', fn)

Emitted when the document changes. fn is called with the arguments:

  • peer (a Peer object)
  • operation (object of type Operation, see further down)

document.snapshots

document.snapshots.take()

Returns a promise

peerpad.snapshots.take().then((hash) => {
  console.log('snapshot hash: ', hash)
})

document.network

document.network.observe()

Returns an Event Emitter that emits the following events:

received message

const emitter = document.network.observe()
emitter.on('received message', (fromPeer, message) => {
  console.log('received message from %s: %j', fromPeer, message)
})

sent message

const emitter = document.network.observe()
emitter.on('sent message', (toPeer, message) => {
  console.log('sent message to %s: %j', toPeer, message)
})

peer joined

const emitter = document.network.observe()
emitter.on('peer joined', (peer) => {
  console.log('peer %s joined room', peer)
})

peer left

const emitter = document.network.observe()
emitter.on('peer left', (peer) => {
  console.log('peer %s left room', peer)
})

emitter.stop()

Stop observing events. No network events get emitted after calling this.

Want to hack on Peerpad?

License

MIT