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 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-offline-first

v1.0.66

Published

This is a minimal example library implementing an offline-first infrastructure supporting developers to apply the offline-first philosophy to their existing synchronized projects. The Client implements an stateful auto synchronization to a server with con

Downloads

83

Readme

Simple Offline-First Library

This is a minimal example library implementing an offline-first infrastructure supporting developers to apply the offline-first philosophy to their existing synchronized projects. The Client implements an stateful auto synchronization to a server with conflict resolution using an own json-based CRDT datatype, while the Server provides the necessary RESTful API interface for the server. It also utilizes privacy reinforcing techniques to hide sensitive information to third parties.

Installation

You can install the library (which is still in an early development stage) using the node package manager (npm):

npm init -y && npm install simple-offline-first

Alternatively, pull the project using git:

cd my-project && git clone https://github.com/david-prv/offline-first-lib && cd offline-first-lib && npm install

Example Usage

Import & setup Client from library:

const { Client: OfflineFirstClient } = require("simple-offline-first");
const client = new OfflineFirstClient(
  // server to sync with -> MUST use our server API
  "localhost:3600",
  // the database name to work on
  "todo_application"
);

Log changes to local CRDT:

// I don't have any milk...
let change = new TodoWrapper(TodoType.SHOPPING, "Buy some milk");
client.insert(change.toString());

// Hm, this wasn't polite, let's change that...
let updatedChange = new TodoWrapper(TodoType.SHOPPING, "Buy some milk, please");
client.update(updatedChange.toString(), (entry) => entry.hash == hashToChange);

// Know what, I've found some, let's delete that...
client.delete((entry) => entry.hash == hashToChange);

It's as easy as that!

Changelog using CRDT

{
  "example": [
    {
      "hash": "ad35e2a737129acd2146bf2bfa09e0ff62c55fe029e5c34672bfae0f1195981c",
      "type": "insert",
      "timestamp": "2024-01-21T17:11:52.214Z",
      "data": "{\"title\":\"Entry title\",\"content\":\"This is an example\"}"
    },
    {
      "hash": "5b33bf76622b22b2318826d913f3050f65a7d5f433944edd6f656c610348ac19",
      "type": "update(ad35e2a737129acd2146bf2bfa09e0ff62c55fe029e5c34672bfae0f1195981c)",
      "timestamp": "2024-01-21T17:11:52.214Z",
      "data": "{\"title\":\"Entry title\",\"content\":\"This is an changed example\"}"
    },
    {
      "hash": "4ea13a0c514c91814cfc61108f789e64701ef9b5b3caa855c89eed2c16ec0e93",
      "type": "delete(ad35e2a737129acd2146bf2bfa09e0ff62c55fe029e5c34672bfae0f1195981c)",
      "timestamp": "2024-01-21T17:11:57.964Z",
      "data": null
    },
    {
      "hash": "05caab73cb56ecd0197454ef22dc77c5a6fddcba1f55d51c4650de6bfa18280e",
      "type": "insert",
      "timestamp": "2024-01-21T17:10:25.343Z",
      "data": "{\"title\":\"Entry title\",\"content\":\"This is another example\"}"
    }
  ]
}