Gathering detailed insights and metrics for y-leveldb
Gathering detailed insights and metrics for y-leveldb
Gathering detailed insights and metrics for y-leveldb
Gathering detailed insights and metrics for y-leveldb
pouchdb-adapter-leveldb-core
Core PouchDB adapter code for LevelDOWN-based adapters
@types/pouchdb-adapter-leveldb
TypeScript definitions for pouchdb-adapter-leveldb
path-is-inside
Tests whether one path is inside another path
ansi-escapes
ANSI escape codes for manipulating the terminal
npm install y-leveldb
92.7
Supply Chain
98.6
Quality
74.7
Maintenance
100
Vulnerability
99.6
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
96 Stars
32 Commits
19 Forks
7 Watching
1 Branches
6 Contributors
Updated on 27 Nov 2024
JavaScript (99.4%)
HTML (0.6%)
Cumulative downloads
Total Downloads
Last day
3.7%
16,418
Compared to previous day
Last week
0.6%
90,476
Compared to previous week
Last month
7.5%
396,102
Compared to previous month
Last year
36%
3,965,282
Compared to previous year
1
LevelDB is a fast embedded database. It is the underlying technology of IndexedDB.
Internally, y-leveldb uses level
which
allows to exchange the storage medium for a different supported database.
Hence this adapter also supports rocksdb, lmdb, and many more..
1npm install y-leveldb --save
1import * as Y from 'yjs'
2import { LeveldbPersistence } from 'y-leveldb'
3
4const persistence = new LeveldbPersistence('./storage-location')
5
6const ydoc = new Y.Doc()
7ydoc.getArray('arr').insert(0, [1, 2, 3])
8ydoc.getArray('arr').toArray() // => [1, 2, 3]
9
10// store document updates retrieved from other clients
11persistence.storeUpdate('my-doc', Y.encodeStateAsUpdate(ydoc))
12
13// when you want to sync, or store data to a database,
14// retrieve the temporary Y.Doc to consume data
15const ydocPersisted = await persistence.getYDoc('my-doc')
16ydocPersisted.getArray('arr') // [1, 2, 3]
persistence = LeveldbPersistence(storageLocation, [{ [level] }])
Create a y-leveldb persistence instance.
You can use any levelup-compatible adapter.
1import { LeveldbPersistence } from 'y-leveldb' 2import level from 'level-mem' 3 4const persistence = new LeveldbPersistence('./storage-location', { level })
persistence.getYDoc(docName: string): Promise<Y.Doc>
Create a Y.Doc instance with the data persisted in leveldb. Use this to temporarily create a Yjs document to sync changes or extract data.
persistence.storeUpdate(docName: string, update: Uint8Array): Promise
Store a single document update to the database.
persistence.getStateVector(docName: string): Promise<Uint8Array>
The state vector (describing the state of the persisted document - see Yjs docs) is maintained in a separate field and constantly updated.
This allows you to sync changes without actually creating a Yjs document.
persistence.getDiff(docName: string, stateVector: Uint8Array): Promise<Uint8Array>
Get the differences directly from the database. The same as
Y.encodeStateAsUpdate(ydoc, stateVector)
.
persistence.clearDocument(docName: string): Promise
Delete a document, and all associated data from the database.
persistence.setMeta(docName: string, metaKey: string, value: any): Promise
Persist some meta information in the database and associate it with a document. It is up to you what you store here. You could, for example, store credentials here.
persistence.getMeta(docName: string, metaKey: string): Promise<any|undefined>
Retrieve a store meta value from the database. Returns undefined if the
metaKey
doesn't exist.
persistence.delMeta(docName: string, metaKey: string): Promise
Delete a store meta value.
persistence.getAllDocNames(docName: string): Promise<Array<string>>
Retrieve the names of all stored documents.
persistence.getAllDocStateVectors(docName: string): Promise<Array<{ name:string,clock:number,sv:Uint8Array}
Retrieve the state vectors of all stored documents. You can use this to sync two y-leveldb instances.
Note: The state vectors might be outdated if the associated document is not yet flushed. So use with caution.
persistence.flushDocument(docName: string): Promise
(dev only)Internally y-leveldb stores incremental updates. You can merge all document updates to a single entry. You probably never have to use this.
y-leveldb is licensed under the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/27 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More