Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
hyoo_crowd_lib
Advanced tools
Conflict-free Reinterpretable Ordered Washed Data (Secure) - Delta based CRDT with additional abilities.
Conflict-free Reinterpretable Ordered Washed Data (Secure) - Delta based CRDT with additional abilities.
grab
, 🏅 give
, 🔑 join
, 📦 data
) with different acceptance criterias.auth
, data
).law
, mod
, add
, get
).law
level for Land.law
level in that Land by default.foo()
- read. foo(123)
- write and return written.type Unit = Readonly<{
land: int62
auth: int62
head: int62
self: int62
next: int62
prev: int62
time: int31
data: json | bin
sign: bin64
}>
type State = Unit[]
type Delta = readonly Unit[]
Internally Units may be stored in RDBMS. Example:
CREATE TABLE units (
land int(8),
auth int(8),
head int(8),
self int(8),
next int(8),
prev int(8),
time int(4),
data json,
sign byte(64),
)
Primary key for Units: [ Land, Head, Self ]
Delta is array of 8-byte aligned binary serialized Units of same Land ordered by Aeon+Time.
Unit contains data, it global position, time of creation, authorship and sign of all of this.
Contains last seen Times for each Peer+Group of already known Units.
Single value store. Just CvRDT LWW-Register. Value is any JSON or Binary data with size <= 32KB.
value( next?: unknown )
Channel for raw value. Returns null
by default.bool( next?: boolean )
Channel for boolean
value. Returns false
by default.numb( next?: number )
Channel for number
value. Returns NaN
by default.str( next?: string )
Channel for string
value. Returns ""
by default.Struct is completely virtual thing. No one Unit is stored for it. Only for field values (except it's structs too, etc).
field_head = hash_62bit( field_name, struct_self )
So each Peer writes to the same Node when uses the same key.
sub( key: string )
Returns inner Node for field name.yoke( key: string, Node, king_level, base_level )
Makes or reuse Land which Self is stored inside register.list( next?: unknown[] )
Channel for list of raw values. Uses insert
to replace content.set( next?: unknown[] )
Channel for list of unique raw values.insert( next?: unknown[], from?: number, to?: number )
Replaces range of items with reconciliation. Appends to the end when range isn't defined.move( from?: number, to?: number )
Moves item to another seat.cut( seat: number )
Removes item by seat.has( val: unknown )
Checks for value existence.add( val: unknown )
Adds value if doesn't exist.drop( val: unknown )
Removes value if exists.It's both Struct and List:
keys()
Channel for list of keys.sub( key: string, Node )
Returns inner Node for key.has( val: unknown )
Checks for key existence.add( val: unknown )
Adds key if doesn't exist.drop( val: unknown )
Removes key if exists.It's recursive version of Dictionary. Special values which marks inner structures:
{}
- inner JSON.[]
- inner List.json( json )
Channel for JSON.Under the hood, String is just List of Tokens. So, entering word letter by letter changes same Unit instead of creating new. Text is the List of Strings which represents multiline text.
<textarea>
with real-time synchronization.str( next?: string )
Channel for String representation. Uses write
to replace content.text( next?: string )
Channel for Text representation.selection( peer, next?: [ number, number ] )
Channel for selection Offsets of given Peer inside this Text. Stored inside Peer Home Land with anchoring to most inner token.write( next?: string, from?, to? )
Replaces range of String with reconciliation. Writes to the end when range isn't defined.Under the hood, tokens are stored in the same form as in plain text. There may be elements between them in form ["div"]
, which can contain the same content. Every token is represented as SPAN. Every DOM element has id
equal to Self. This id
is using to reuse existing Units and track Nodes moving.
dom( next?: Element | DocumentFragment )
Channel for DOM representation of subtree.html( next?: string )
Channel for XHTML serialization of DOM.Example with SQL:
SELECT *
FROM Unit
WHERE
NOT( peer = 1 AND time <= 123 )
AND NOT( peer = 2 AND time <= 456 )
AND NOT( peer = 3 AND time <= 789 )
...
ORDER BY
time ASC,
peer ASC
chief
Returns chief Node with Head = 0.delta( clocks? )
Returns delta between past clock and now.apply( delta )
Merges delta to current state.fork( peer )
Makes independent clone with another Peer for testing purposes.need update
What\As | Atom | Struct | List | Dictionary | Text | DOM |
---|---|---|---|---|---|---|
Atom | ✅ Same | ⭕ Nullish fields | ✅ As single item | ✅ As key | ✅ String as tokens, other ignored | ✅ String as tokens, other ignored |
Struct | ⭕ first field value | ✅ Same | ⭕ Field values | ❌ Field values as keys | ⭕ Empty | ⭕ Empty |
List | ⭕ fist item | ⭕ Nullish fields | ✅ Same | ✅ Items as keys | ⭕ Strings as tokens, other ignored | ⭕ Items as spans |
Dictionary | ⭕ first key | ✅ keys values as fields values | ✅ Keys | ✅ Same | ✅ Keys as tokens | ✅ Keys as tokens |
Text | ❌ first token | ⭕ Nullish fields | ✅ Tokens | ❌ Tokens as keys | ✅ Same | ✅ Tokens as spans |
DOM | ❌ first token | ⭕ Nullish fields | ✅ Top level items | ❌ Tokens as keys | ⭕ Text from top level tokens | ✅ Same |
// // Usage from NPM. Isn't required in MAM.
// import {
// $hyoo_crowd_land,
// $hyoo_crowd_reg,
// $hyoo_crowd_list,
// $hyoo_crowd_text,
// } from 'hyoo_crowd_lib'
// Create document
const base = new $hyoo_crowd_land;
// Make independent forks for testng
const alice = base.fork({ id: '1_1' });
const bob = base.fork({ id: '2_2' });
const carol = base.fork({ id: '3_3' });
// Twice change register named "foo"
alice.chief.sub("foo", $hyoo_crowd_reg).str("A1");
alice.chief.sub("foo", $hyoo_crowd_reg).str("A2");
// Change register named "foo"
// Then converts it to sequence and insert some values
bob.chief.sub("foo", $hyoo_crowd_reg).str("B1");
bob.chief.sub("foo", $hyoo_crowd_list).insert(["B2", "B3"]);
// Replace text named "foo"
carol.chief.sub("foo", $hyoo_crowd_text).str("C1 C2");
// Make deltas
const alice_delta = alice.delta(base.clock);
const bob_delta = bob.delta(base.clock);
const carol_delta = carol.delta(base.clock);
// Cross merge all of them
alice.apply(bob_delta).apply(carol_delta);
bob.apply(alice_delta).apply(carol_delta);
carol.apply(bob_delta).apply(alice_delta);
console.log(
["A2", "C1", " C2", "B1", "B2", "B3"],
alice.chief.sub("foo", $hyoo_crowd_list).list(),
bob.chief.sub("foo", $hyoo_crowd_list).list(),
carol.chief.sub("foo", $hyoo_crowd_list).list()
);
$hyoo_crowd | Automerge | YJS | delta-crdt | |
---|---|---|---|---|
Approach | delta-state | op-log | delta-state | delta-state |
Garbage Collection | Doesn't required | Stores full history | Enabled by default | ❓ |
Changes signing | ✅ Support | ❌ | ❌ | ❓ |
Merge without decrypt | ✅ Support | ❌ | ❌ | ❓ |
Gzipped Bundle Size | 15 KB | 46 KB | 24 KB | 43 KB |
Sequence: 500 Push + 500 Shift Perf | 17 ms | 420 ms | 21 ms | |
Sequence: 500 Push + 500 Shift Mem | 84 KB | 986 KB | 3.84 KB | |
Text: 500 Append + 500 Crop Perf | 21 ms | 480 ms | 18 ms | |
Text: 500 Append + 500 Crop Mem | 86 KB | 1_080 KB | 5 KB |
FAQs
Conflict-free Reinterpretable Ordered Washed Data (Secure) - Delta based CRDT with additional abilities.
The npm package hyoo_crowd_lib receives a total of 187 weekly downloads. As such, hyoo_crowd_lib popularity was classified as not popular.
We found that hyoo_crowd_lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.