-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathInMemoryDarBuffer.js
58 lines (48 loc) · 1.04 KB
/
InMemoryDarBuffer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
export default class InMemoryDarBuffer {
constructor () {
this._version = null
this._changes = []
this._isDirty = {}
this._blobs = {}
}
getVersion () {
return this._version
}
load(archiveId, cb) { // eslint-disable-line
cb()
}
addChange (docId, change) {
// HACK: if there are no ops we skip
if (change.ops.length === 0) return
// console.log('RECORD CHANGE', docId, change)
this._isDirty[docId] = true
this._changes.push({
docId, change
})
}
hasPendingChanges () {
return this._changes.length > 0
}
getChanges () {
return this._changes.slice()
}
hasResourceChanged (docId) {
return this._isDirty[docId]
}
hasBlobChanged (assetId) {
return Boolean(this._isDirty[assetId])
}
addBlob (assetId, blob) {
this._isDirty[assetId] = true
this._blobs[assetId] = blob
}
getBlob (assetId) {
return this._blobs[assetId]
}
reset (version) {
this._version = version
this._changes = []
this._blobs = {}
this._isDirty = {}
}
}