A tiny CRDT implementation in Javascript.

Overview

Tiny Merge

A tiny CRDT implemented in Javascript.

The philosophy behind Tiny Merge is to strategically reduce the functionality of CRDT's in favour of simplicity.

What future usage will look like for Tiny Merge

Collections

const blogsCollection = collection.set(ram, root, 'blogs', {
  title: { type: PRIMITIVE.STRING },
  content: { type: PRIMITIVE.STRING },
  tags: { type: CRDT.SEQUENCER, options: { type: PRIMITIVE.STRING } },
}, userId, version)
const commentsCollection = collection.set(ram, root, 'comments', {
  blogId: { type: PRIMITIVE.STRING },
  message: { type: PRIMITIVE.STRING },
}, userId, version)
const likesCollection = collection.set(ram, root, 'likes', {
  blogId: { type: PRIMITIVE.STRING },
  users: { type: CRDT.KEY_STORE, options: { type: TYPE.BOOLEAN } }
}, userId, version)

Documents

  const blogDocument = document.set(ram, blogsCollection, 'first-post', {
    title: 'First blog post',
    content: '# Some blog content',
    tags: ['introduction'],
  }, userId, version)

  applyDocumentOperation(blogDocument, ['tags'], OPERATIONS.SEQUENCER.PUSH, value)

Used with React

Provider

const client = new TinyClient({
  uri: SOCKET_URL,
  accessToken: ACCESS_TOKEN,
})

const MyApp = ({ Component, pageProps }) => (
  <TinyProvider client={client}>
    <Component {...pageProps} />
  </TinyProvider>
)

Collections

const [collection, setCollection, type, isLoading] = useCollection(key)

Documents

const [blog, setBlog, applyOperation, isLoading] = useDocument(collection, key, initialValue)

License

MIT License

Copyright (c) 2022 James Addison

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You might also like...

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time.

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time.

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time. Dropdown, navigation bu

Nov 25, 2022

Vanilla JavaScript tabs - tiny and simple.

Vanilla JavaScript Tabs Vanilla JavaScript Tabs - simple and awesome. — Inspired by the blazing fast, lightweight, cross-platform and crazy popular Va

Dec 22, 2022

Javascript implementation of flasher tool for Espressif chips, running in web browser using WebSerial.

Javascript implementation of esptool This repository contains a Javascript implementation of esptool, a serial flasher utility for Espressif chips. Un

Dec 22, 2022

A JavaScript implementation of Michael Baker's Miner2149

miner2149-js A JavaScript implementation of Michael Baker's Miner2149. This repository is for personal use only. Not for commercial use or distributio

Jan 11, 2022

A fast simplex noise implementation in Javascript.

simplex-noise.js API Documentation simplex-noise.js is a simplex noise implementation in Javascript/TypeScript. It works in the browser and nodejs. Us

Jan 2, 2023

A javascript text differencing implementation.

jsdiff A javascript text differencing implementation. Based on the algorithm proposed in "An O(ND) Difference Algorithm and its Variations" (Myers, 19

Jan 7, 2023

javascript implementation of logistic regression/c4.5 decision tree

LearningJS: A Javascript Implementation of Logistic Regression and C4.5 Decision Tree Algorithms Author: Yandong Liu. Email: yandongl @ cs.cmu.edu Upd

Aug 19, 2022

ParkyDB - block based, linkable and verifiable document database -- javascript reference implementation

ParkyDB - block based, linkable and verifiable document database -- javascript reference implementation

Ancon ParkyDB A data mesh database using Web 3.0 technology Note: Requires Node v17.7.2 and up for development More about data mesh architecture Block

Aug 16, 2022

An implementation of (Untyped) Lambda Calculus in JavaScript.

Lambda Calculus More restraint and more pure, so functional and so reduced. -- Anonymous Bauhaus Student An implementation of (Untyped) Lambda Calculu

Nov 17, 2022
Owner
James Addison
🤖🎋🐵 Building playful, social, collaborative & offline-first software.
James Addison
Use Matrix as a backend for local-first applications with the Matrix-CRDT Yjs provider.

Matrix CRDT Matrix-CRDT enables you to use Matrix as a backend for distributed, real-time collaborative web applications that sync automatically. The

Yousef 604 Jan 7, 2023
Simple Library implemented using HTML, CSS and JavaScript. This is a simple implementation of JavaScript Modules of ES6.

Awesome-books A single page project with the porpuse of storing books' titles and authors. Built With CSS, HTML & Javascript. How to run in your local

Saadat Ali 7 Feb 21, 2022
Tiny and powerful JavaScript full-text search engine for browser and Node

MiniSearch MiniSearch is a tiny but powerful in-memory fulltext search engine written in JavaScript. It is respectful of resources, and it can comfort

Luca Ongaro 2k Jan 3, 2023
A tiny (108 bytes), secure, URL-friendly, unique string ID generator for JavaScript

Nano ID English | Русский | 简体中文 | Bahasa Indonesia A tiny, secure, URL-friendly, unique string ID generator for JavaScript. “An amazing level of sens

Andrey Sitnik 19.6k Jan 8, 2023
A tiny, reactive JavaScript library for structured state and tabular data.

A JavaScript library for structured state. Using plain old JavaScript objects to manage data gets old very quickly. It's error-prone, tricky to track

tinyplex 1.4k Jan 1, 2023
A tiny, plugin extendable JavaScript utility library with a JQuery-like syntax.

Tiny Friggin' Utility Zapper What is it? A tiny ~7kb extendable JavaScript utility library with a JQuery like syntax for getting work done fast! If yo

Bret 4 Jun 25, 2022
Javascript accordion - tiny and simple.

Javascript Accordion Javascript accordion - tiny and simple. Accordions are useful when you want to toggle between hiding and showing large amount of

Kenan Gündoğan 4 Dec 8, 2022
A super tiny Javascript library to make DOM elements draggable and movable. ~500 bytes and no dependencies.

dragmove.js A super tiny Javascript library to make DOM elements draggable and movable. Has touch screen support. Zero dependencies and 500 bytes Gzip

Kailash Nadh 814 Dec 29, 2022
Tiny JavaScript library (1kB) by CurrencyRate.today, providing simple way and advanced number, money and currency formatting and removes all formatting/cruft and returns the raw float value.

Zero dependency tiny JavaScript library (1kB bytes) by CurrencyRate.today, providing simple way and advanced number, money and currency formatting and removes all formatting/cruft and returns the raw float value.

Yurii De 11 Nov 8, 2022
A tiny JavaScript library to enable CSS animations when user scrolls.

A tiny JavaScript library to enable CSS animations when user scrolls. This library allows you to toggle one or more classes on an element when it appe

Matthieu Bué 35 Nov 24, 2022