*Change pullRemote to throw if the item is not empty
This commit is contained in:
parent
bef4631c30
commit
74b0f1d596
10
index.js
10
index.js
|
@ -777,12 +777,15 @@ module.exports = class Protomux {
|
||||||
async popFree(id) {
|
async popFree(id) {
|
||||||
await this.userData.syncProtomux("popFree", id);
|
await this.userData.syncProtomux("popFree", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async pushFree(id) {
|
async pushFree(id) {
|
||||||
await this.userData.syncProtomux("pushFree", id);
|
await this.userData.syncProtomux("pushFree", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async pushLocal(id) {
|
async pushLocal(id) {
|
||||||
await this.userData.syncProtomux("pushLocal", id);
|
await this.userData.syncProtomux("pushLocal", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async pushRemote(id) {
|
async pushRemote(id) {
|
||||||
await this.userData.syncProtomux("pushRemote", id);
|
await this.userData.syncProtomux("pushRemote", id);
|
||||||
}
|
}
|
||||||
|
@ -797,20 +800,23 @@ module.exports = class Protomux {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async pullFree() {
|
async pullFree() {
|
||||||
const ids = await this.userData.syncProtomux("pullFree");
|
const ids = await this.userData.syncProtomux("pullFree");
|
||||||
|
|
||||||
this._free = Array.from(new Set([...this._free, ...ids]));
|
this._free = Array.from(new Set([...this._free, ...ids]));
|
||||||
this._free = this._free.filter((item) => item !== null);
|
this._free = this._free.filter((item) => item !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
async pullRemote() {
|
async pullRemote() {
|
||||||
const ids = await this.userData.syncProtomux("pullRemote");
|
const ids = await this.userData.syncProtomux("pullRemote");
|
||||||
|
|
||||||
ids.forEach((item) => {
|
ids.forEach((item) => {
|
||||||
item = parseInt(item);
|
item = parseInt(item);
|
||||||
if (typeof this._remote[item] === "undefined") {
|
if (typeof this._remote[item] !== "undefined") {
|
||||||
this._remote[item] = null;
|
throw new Error("empty remote element expected");
|
||||||
}
|
}
|
||||||
|
this._remote[item] = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in New Issue