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

libocc

v0.5.0

Published

Notice: _This is a work in progress_

Readme

libocc

Notice: This is a work in progress

The purpose of this project is to provide a simple library for occasionally connected computing.

It's supposed to be a little framework for event-sourced systems.

Usage

Create a class for every entity type you want to have event-sourced, and decorate it with the @Entity() decorator, and put the @Property() decorator on every field you want to persist.

Then, create a Repository for every such entity and use its create, update and delete methods to interact with the data, and use the various find methods to get a projection at a specified time.

Alternative to using repositories, a user of libocc may instead opt to use the Projector class (which is used internally by the Repository class) directly, if a more low-level approach is desired.

Example: A book store

Let's assume we want to keep an event-sourced record of the inventory of a book store.

For now, we'll only persist the books themselves (it is planned to eventually support relational entities as well):

Book.ts:

// Another entity
import { Person } from "./Person.js";

// The decorators from libocc
import { Entity } from "../../lib/decorators/Entity.js";
import { Property } from "../../lib/decorators/Property.js";

// The class is decorated with the `@Entity` decorator
@Entity()
export class Book {

  // The `uuid` field has the `idId` flag set, marking it as the ID property
  @Property({ isId: true })
  uuid: string = "some-uuid";

  // This number should be persisted
  @Property()
  someNumber: number = 1234;

  // This number is the result of a function, but it can still be preserved
  @Property()
  actualFunction: number = (() => (() => 234)())();

  // Relational data capabilities are subject to inclusion in a future version of libocc
  @Property()
  author: Person = new Person();

  // Does not have `@Property()`, so it should not be included
  hiddenProperty: string = "sneaky af";

  // The constructor does not need any decorators or parameters on it
  constructor() {}
}

main.ts:

// A utility class from libocc
import { Repository } from "../lib/core/Repository.js";

// An entity from the example
import { Book } from "./classes/Book.js";

/**
 * A demo application managing the inventory of a book store
 */
export function runDemo() {
  // Create a new book
  const myBook = new Book();

  // Create a new projector of type `Book`
  const books = new Repository(Book);

  console.log("Empty repository:");
  console.log(books.findAll());

  const oldDate = new Date();

  // Add a new book
  books.create(myBook);

  console.log("Repository after creating new book:");
  console.log(books.findAll());

  // Simulated delay
  for (let i = 0; i < 100000000; i++) {}

  // Modify the book
  books.update({
    uuid: myBook.uuid,
    someNumber: 42,
  });

  console.log("Repository after updating the book:");
  console.log(books.findAll());

  console.log("Repository before the book was updated:");
  console.log(books.findAll(oldDate));
}

Future plans

  • Merge features
  • Relational entities
  • Better persistance
  • Better loading