1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
| const Chainable = require('./Chainable');
|
| module.exports = class extends Chainable {
| constructor(parent) {
| super(parent);
| this.store = new Set();
| }
|
| add(value) {
| this.store.add(value);
| return this;
| }
|
| prepend(value) {
| this.store = new Set([value, ...this.store]);
| return this;
| }
|
| clear() {
| this.store.clear();
| return this;
| }
|
| delete(value) {
| this.store.delete(value);
| return this;
| }
|
| values() {
| return [...this.store];
| }
|
| has(value) {
| return this.store.has(value);
| }
|
| merge(arr) {
| this.store = new Set([...this.store, ...arr]);
| return this;
| }
|
| when(
| condition,
| whenTruthy = Function.prototype,
| whenFalsy = Function.prototype,
| ) {
| if (condition) {
| whenTruthy(this);
| } else {
| whenFalsy(this);
| }
|
| return this;
| }
| };
|
|