Yomguithereal / mnemonist

Curated collection of data structures for the JavaScript/TypeScript language.
https://yomguithereal.github.io/mnemonist
MIT License
2.24k stars 92 forks source link

Have MultiSet.clear() return this #200

Closed kberg closed 1 year ago

kberg commented 1 year ago

// Methods clear(): void; add(key: K, count?: number): this; set(key: K, count: number): this; has(key: K): boolean;

It's currently not possible to write x.clear().add(...), which would be particularly handy.

Yomguithereal commented 1 year ago

Hello @kberg, I see your point but I am split on this problem as currently I am adhering to the ES6 data structure for consistency reasons and an ES6 Map clear method does not return this, and so currently no clear method from this lib does either.

kberg commented 1 year ago

Well, I see your point.

And, add returns this in the ES6 standard?

Yomguithereal commented 1 year ago

And, add returns this in the ES6 standard?

It does indeed: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/add#return_value

kberg commented 1 year ago

OK. Well, I hear you. Let's close these, then. Thanks.