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 🙏

© 2026 – Pkg Stats / Ryan Hefner

cero-base

v1.1.1

Published

P2P database with collection-based CRUD, RPC proxy, and React hooks

Readme

cero-base

Collection-based CRUD layer on top of cero. Define your schema, get put/get/del/sub across three scopes with built-in pagination.

Install

npm install cero-base

Schema

import { t } from 'cero-base'

export const schema = t.schema(
  {
    drafts: { fields: { id: t.string, content: t.string }, key: ['id'], scope: 'local' },
    settings: { fields: { key: t.string, value: t.json }, key: ['key'] },
    messages: {
      fields: { id: t.string, text: t.string, memberId: t.string },
      key: ['id'],
      scope: 'shared',
      timestamps: true
    }
  },
  { namespace: 'chat' }
)

| Scope | Replication | | ------------------- | --------------------- | | local | Device-only | | private (default) | Across paired devices | | shared | Between room members |

Build & Use

import { build } from 'cero-base'
await build('./spec', schema)
import { Cero } from 'cero-base'

const db = new Cero('./data', schema, spec)
await db.ready()

const drafts = db.collection('drafts')
await drafts.put({ content: 'WIP' })

const room = await db.rooms.open()
const messages = room.collection('messages')
await messages.put({ text: 'Hello!', memberId: db.id })

Collections

await col.put({ text: 'Hello' }) // upsert (auto-generates id)
await col.get() // all
await col.get({ done: false }) // filter
await col.del({ id: 'abc' }) // delete
col.sub().on('data', console.log) // subscribe

Pagination

Every non-local collection gets a monotonic index on insert.

await col.get({ gte: 50, lte: 80 }) // range query
await col.get({ gte: 0 }, { reverse: true, limit: 30 })
await col.total() // count (no full scan)

Rooms

const room = await db.rooms.open() // create
const room = await db.rooms.open(roomId) // open
const room = await db.rooms.open(invite) // join

room.collection('messages')
room.id
room.members
room.invites
room.profile

Batch

const batch = db.batch()
batch.put('settings', { key: 'a', value: '1' })
batch.put('settings', { key: 'b', value: '2' })
await batch.flush()

Device Pairing

const invite = await db.devices.invite() // Device A
await db2.join(invite) // Device B

Recovery

Restore an identity on a new device using the seed phrase. Requires an existing device online.

const seed = db.seed() // save this securely
await db2.join(seed) // recover on new device

React

import {
  Cero,
  Room,
  useCero,
  useRoom,
  useProfile,
  useRooms,
  useCollection,
  useMembers
} from 'cero-base/react'

function App() {
  return (
    <Cero db={db}>
      <Room id={roomId}>
        <Chat />
      </Room>
    </Cero>
  )
}

function Chat() {
  const { data, put, sub } = useCollection('messages')
  return (
    <div>
      {data.map((m) => (
        <p key={m.id}>{m.text}</p>
      ))}
    </div>
  )
}

| Hook | Returns | | --------------------- | ------------------------------------------- | | useCero() | db | | useRoom() | room | | useProfile() | { data, busy, error, set } | | useRooms() | { data, busy, error } | | useCollection(name) | { data, busy, error, put, del, get, sub } | | useMembers() | { data, busy, error } |

RPC Proxy

For process isolation (Pear/Electron). Worker runs cero, renderer uses the same API over IPC.

// Worker
import { serve } from 'cero-base/rpc'
serve(Chats, Bare.IPC, storage)

// Renderer
import { Cero } from 'cero-base/rpc/proxy'
const db = new Cero(ipc, schema, spec)
await db.ready()

Types

| Helper | Type | | ---------------------- | ------------ | | t.string | String | | t.uint | Unsigned int | | t.int | Signed int | | t.float | Float | | t.bool | Boolean | | t.buffer | Buffer | | t.json | JSON | | t.optional(t.string) | Optional | | t.array(t.string) | Array | | t.ref('tasks') | Reference |

License

Apache-2.0