save state in FilePersistence

This commit is contained in:
Kevin Jahns
2018-06-02 13:33:04 +02:00
parent 9be256231b
commit 417d0ef3b5
12 changed files with 154 additions and 2331 deletions

View File

@@ -117,12 +117,16 @@ export default class BinaryDecoder {
*/
readVarString () {
let len = this.readVarUint()
let bytes = new Array(len)
let encodedString = ''
//let bytes = new Array(len)
for (let i = 0; i < len; i++) {
bytes[i] = this.uint8arr[this.pos++]
//bytes[i] = this.uint8arr[this.pos++]
// encodedString += String.fromCodePoint(this.uint8arr[this.pos++])
encodedString += String(this.uint8arr[this.pos++])
}
let encodedString = bytes.map(b => String.fromCodePoint(b)).join('')
return decodeURIComponent(escape(encodedString))
//let encodedString = String.fromCodePoint.apply(null, bytes)
//return decodeURIComponent(escape(encodedString))
return encodedString
}
/**

View File

@@ -1,4 +1,3 @@
// TODO: rename mutex
/**
@@ -19,7 +18,7 @@
*/
export function createMutualExclude () {
var token = true
return function mutualExclude (f) {
return function mutualExclude (f, g) {
if (token) {
token = false
try {
@@ -28,6 +27,8 @@ export function createMutualExclude () {
console.error(e)
}
token = true
} else if (g !== undefined) {
g()
}
}
}