修改代码

This commit is contained in:
ival 2021-03-31 18:16:58 +08:00
parent 91fd06b695
commit 143d6a67cc

View File

@ -0,0 +1,63 @@
export default class Storage {
constructor() {
this.map = new Map();
this.lst = new Set();
this.clipboard = [];
}
has(code) {
return code ? this.map.has(code) : false;
}
set(code, target) {
if (!this.has(code)) {
this.lst.add(code);
this.map.set(code, target);
}
}
get(code) {
return this.map.get(code);
}
delete(code) {
if (this.has(code)) {
this.map.delete(code);
this.lst.delete(code);
}
}
values() {
return Array.from(this.lst).map(code => { return this.get(code); });
}
clear() {
this.lst.clear();
this.map.clear();
}
isSelectExist(code) {
return this.has(code);
}
setClipboard(lst) {
this.clipboard = Array.from(lst);
}
clearClipboard() {
this.clipboard = [];
}
getClipboard() {
return this.clipboard;
}
getClipboardSize() {
return this.clipboard.length;
}
forEach() {
return this.map.forEach;
}
}