Skip to content

Commit df52ded

Browse files
committed
Rename to crdtmap
1 parent 0eff432 commit df52ded

File tree

5 files changed

+56
-51
lines changed

5 files changed

+56
-51
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CrdtMap
2+
3+
Inspired by [yjs](https://github.com/yjs/yjs) and the CRDT-variant LWW-Element-Set, this is a simple key-value map that can sync between different clients by letting latest timestamp always win.
4+
5+
Key is always a string but value could be anything as long as it's just primitive values.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "vjs",
2+
"name": "crdtmap",
33
"version": "0.1.0",
44
"license": "MIT",
5-
"main": "./dist/vjs.cjs",
5+
"main": "./dist/crdtmap.cjs",
66
"scripts": {
77
"dist": "rm -rf dist && rollup -c",
88
"prepare": "npm run dist",

rollup.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ export default [
55
{
66
input: 'src/index.js',
77
output: {
8-
name: 'V',
9-
file: 'dist/vjs.cjs',
8+
name: 'CrdtMap',
9+
file: 'dist/crdtmap.cjs',
1010
format: 'cjs',
1111
sourcemap: true,
1212
exports: 'default'

src/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const set = require('lib0/dist/set.cjs')
77
const encoding = require('lib0/dist/encoding.cjs')
88
const decoding = require('lib0/dist/decoding.cjs')
99

10-
function VDoc (options) {
10+
function CrdtMap (options) {
1111
const map = new Map()
1212
const stateVectors = new Map()
1313
const observers = new Map()
@@ -197,7 +197,7 @@ function VDoc (options) {
197197
}
198198
}
199199

200-
VDoc.encodeSnapshot = function encodeSnapshot (snapshot) {
200+
CrdtMap.encodeSnapshot = function encodeSnapshot (snapshot) {
201201
const encoder = encoding.createEncoder()
202202

203203
for (const [key, value] of Object.entries(snapshot)) {
@@ -218,7 +218,7 @@ VDoc.encodeSnapshot = function encodeSnapshot (snapshot) {
218218
return encoding.toUint8Array(encoder)
219219
}
220220

221-
VDoc.decodeSnapshot = function decodeSnapshot (byteArray) {
221+
CrdtMap.decodeSnapshot = function decodeSnapshot (byteArray) {
222222
const decoder = decoding.createDecoder(byteArray)
223223
const snapshot = {}
224224

@@ -243,7 +243,7 @@ VDoc.decodeSnapshot = function decodeSnapshot (byteArray) {
243243
return snapshot
244244
}
245245

246-
VDoc.encodeStateVectors = function encodeStateVectors (stateVectors) {
246+
CrdtMap.encodeStateVectors = function encodeStateVectors (stateVectors) {
247247
const encoder = encoding.createEncoder()
248248

249249
for (const [key, vector] of Object.entries(stateVectors)) {
@@ -254,7 +254,7 @@ VDoc.encodeStateVectors = function encodeStateVectors (stateVectors) {
254254
return encoding.toUint8Array(encoder)
255255
}
256256

257-
VDoc.decodeStateVectors = function decodeStateVectors (byteArray) {
257+
CrdtMap.decodeStateVectors = function decodeStateVectors (byteArray) {
258258
const decoder = decoding.createDecoder(byteArray)
259259
const stateVectors = {}
260260

@@ -268,4 +268,4 @@ VDoc.decodeStateVectors = function decodeStateVectors (byteArray) {
268268
return stateVectors
269269
}
270270

271-
module.exports = VDoc
271+
module.exports = CrdtMap

0 commit comments

Comments
 (0)