mirror of https://github.com/zulip/zulip.git
lazy_set: Return set from the _make_set method.
This is done to avoid adding typescript type error checks when this is converted to typescript.
This commit is contained in:
parent
84958bf7eb
commit
d0c339e772
|
@ -49,13 +49,15 @@ export class LazySet {
|
||||||
|
|
||||||
_make_set() {
|
_make_set() {
|
||||||
if (this.data.set !== undefined) {
|
if (this.data.set !== undefined) {
|
||||||
return;
|
return this.data.set;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.data = {
|
this.data = {
|
||||||
arr: undefined,
|
arr: undefined,
|
||||||
set: new Set(this.data.arr),
|
set: new Set(this.data.arr),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return this.data.set;
|
||||||
}
|
}
|
||||||
|
|
||||||
map(f) {
|
map(f) {
|
||||||
|
@ -69,15 +71,15 @@ export class LazySet {
|
||||||
}
|
}
|
||||||
|
|
||||||
add(v) {
|
add(v) {
|
||||||
this._make_set();
|
const set = this._make_set();
|
||||||
const val = this._clean(v);
|
const val = this._clean(v);
|
||||||
this.data.set.add(val);
|
set.add(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(v) {
|
delete(v) {
|
||||||
this._make_set();
|
const set = this._make_set();
|
||||||
const val = this._clean(v);
|
const val = this._clean(v);
|
||||||
return this.data.set.delete(val);
|
return set.delete(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
_clean(v) {
|
_clean(v) {
|
||||||
|
|
Loading…
Reference in New Issue