scats 1.4.0-dev → 1.4.1-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/abstract-map.d.ts +4 -4
  2. package/dist/abstract-map.js +12 -15
  3. package/dist/abstract-set.d.ts +2 -2
  4. package/dist/abstract-set.js +6 -9
  5. package/dist/array-iterable.d.ts +1 -1
  6. package/dist/array-iterable.js +22 -26
  7. package/dist/collection.d.ts +4 -4
  8. package/dist/collection.js +50 -71
  9. package/dist/either.d.ts +4 -4
  10. package/dist/either.js +31 -39
  11. package/dist/hashmap.d.ts +2 -2
  12. package/dist/hashmap.js +9 -12
  13. package/dist/hashset.d.ts +3 -3
  14. package/dist/hashset.js +6 -11
  15. package/dist/index.d.ts +8 -8
  16. package/dist/index.js +9 -13
  17. package/dist/mappable.js +1 -2
  18. package/dist/mutable/hashmap.d.ts +3 -3
  19. package/dist/mutable/hashmap.js +3 -8
  20. package/dist/mutable/hashset.d.ts +2 -2
  21. package/dist/mutable/hashset.js +3 -8
  22. package/dist/mutable.d.ts +3 -3
  23. package/dist/mutable.js +3 -9
  24. package/dist/option.d.ts +6 -6
  25. package/dist/option.js +34 -44
  26. package/dist/try.d.ts +3 -3
  27. package/dist/try.js +27 -37
  28. package/dist/util.d.ts +2 -2
  29. package/dist/util.js +41 -50
  30. package/package.json +1 -1
  31. package/.eslintrc.cjs +0 -44
  32. package/coverage/clover.xml +0 -937
  33. package/coverage/coverage-final.json +0 -15
  34. package/coverage/lcov-report/array-iterable.ts.html +0 -1709
  35. package/coverage/lcov-report/base.css +0 -224
  36. package/coverage/lcov-report/block-navigation.js +0 -79
  37. package/coverage/lcov-report/collection.ts.html +0 -1475
  38. package/coverage/lcov-report/either.ts.html +0 -1934
  39. package/coverage/lcov-report/favicon.png +0 -0
  40. package/coverage/lcov-report/hashmap.ts.html +0 -527
  41. package/coverage/lcov-report/hashset.ts.html +0 -392
  42. package/coverage/lcov-report/index.html +0 -126
  43. package/coverage/lcov-report/index.ts.html +0 -101
  44. package/coverage/lcov-report/option.ts.html +0 -758
  45. package/coverage/lcov-report/prettify.css +0 -1
  46. package/coverage/lcov-report/prettify.js +0 -2
  47. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  48. package/coverage/lcov-report/sorter.js +0 -170
  49. package/coverage/lcov-report/src/abstract-map.ts.html +0 -317
  50. package/coverage/lcov-report/src/abstract-set.ts.html +0 -200
  51. package/coverage/lcov-report/src/array-iterable.ts.html +0 -1751
  52. package/coverage/lcov-report/src/collection.ts.html +0 -1778
  53. package/coverage/lcov-report/src/either.ts.html +0 -1934
  54. package/coverage/lcov-report/src/hashmap.ts.html +0 -428
  55. package/coverage/lcov-report/src/hashset.ts.html +0 -482
  56. package/coverage/lcov-report/src/index.html +0 -276
  57. package/coverage/lcov-report/src/index.ts.html +0 -110
  58. package/coverage/lcov-report/src/mutable/hashmap.ts.html +0 -821
  59. package/coverage/lcov-report/src/mutable/hashset.ts.html +0 -611
  60. package/coverage/lcov-report/src/mutable/index.html +0 -126
  61. package/coverage/lcov-report/src/mutable.ts.html +0 -89
  62. package/coverage/lcov-report/src/option.ts.html +0 -758
  63. package/coverage/lcov-report/src/try.ts.html +0 -923
  64. package/coverage/lcov-report/src/util.ts.html +0 -518
  65. package/coverage/lcov-report/try.ts.html +0 -923
  66. package/coverage/lcov-report/util.ts.html +0 -518
  67. package/coverage/lcov.info +0 -2223
  68. package/jest.config.js +0 -32
  69. package/src/abstract-map.ts +0 -79
  70. package/src/abstract-set.ts +0 -40
  71. package/src/array-iterable.ts +0 -557
  72. package/src/collection.ts +0 -619
  73. package/src/either.ts +0 -618
  74. package/src/hashmap.ts +0 -116
  75. package/src/hashset.ts +0 -134
  76. package/src/index.ts +0 -10
  77. package/src/mappable.ts +0 -8
  78. package/src/mutable/hashmap.ts +0 -247
  79. package/src/mutable/hashset.ts +0 -177
  80. package/src/mutable.ts +0 -3
  81. package/src/option.ts +0 -226
  82. package/src/try.ts +0 -281
  83. package/src/util.ts +0 -146
package/src/hashmap.ts DELETED
@@ -1,116 +0,0 @@
1
- import {mutable, Option} from './index';
2
- import {AbstractMap, Tuple2} from './abstract-map';
3
-
4
-
5
-
6
- export class HashMap<K, V> extends AbstractMap<K, V, HashMap<K, V>> {
7
-
8
- protected fromArray(array: Tuple2<K, V>[]): HashMap<K, V> {
9
- return HashMap.of(...array);
10
- }
11
-
12
- protected constructor(protected readonly map: Map<K, V>) {
13
- super(map);
14
- }
15
-
16
- static of<K, V>(...values: Tuple2<K, V>[]): HashMap<K, V> {
17
- return new HashMap<K, V>(new Map(values));
18
- }
19
-
20
- static from<K, V>(values: Iterable<Tuple2<K, V>>): HashMap<K, V> {
21
- return HashMap.of(...Array.from(values));
22
- }
23
-
24
- static empty = new HashMap(new Map());
25
-
26
- appendedAll(map: HashMap<K, V>): HashMap<K, V> {
27
- return this.concat(map);
28
- }
29
-
30
- appended(key: K, value: V): HashMap<K, V> {
31
- return this.set(key, value);
32
- }
33
-
34
- /**
35
- * Creates a new map obtained by updating this map with a given key/value pair.
36
- * @param key the key
37
- * @param value the value
38
- * @tparam V1 the type of the added value
39
- * @return A new map with the new key/value mapping added to this map.
40
- */
41
- updated(key: K, value: V): HashMap<K, V> {
42
- return this.set(key, value);
43
- }
44
-
45
- /**
46
- * Removes a key from this map, returning a new map.
47
- *
48
- * @param key the key to be removed
49
- * @return a new map without a binding for ''key''
50
- */
51
- removed(key: K): HashMap<K, V> {
52
- const next = new Map(this.map);
53
- next.delete(key);
54
- return new HashMap<K, V>(next);
55
- }
56
-
57
- /**
58
- * Creates a new map from this map by removing all elements of another
59
- * collection.
60
- *
61
- * @param keys the collection containing the removed elements.
62
- * @return a new map that contains all elements of the current map
63
- * except one less occurrence of each of the elements of `elems`.
64
- */
65
- removedAll(keys: Iterable<K>): HashMap<K, V> {
66
- const next = new Map(this.map);
67
- for (const key of keys) {
68
- next.delete(key);
69
- }
70
- return new HashMap<K, V>(next);
71
- }
72
-
73
- concat(map: HashMap<K, V>): HashMap<K, V> {
74
- const mergedMap = new Map<K, V>([
75
- ...this.entries.toArray,
76
- ...map.entries.toArray
77
- ]);
78
- return new HashMap<K, V>(mergedMap);
79
- }
80
-
81
- set(key: K, value: V): HashMap<K, V> {
82
- const next = new Map(this.map);
83
- next.set(key, value);
84
- return new HashMap<K, V>(new Map(next));
85
- }
86
-
87
- /**
88
- * Update a mapping for the specified key and its current optionally-mapped value
89
- * (`Some` if there is current mapping, `None` if not).
90
- *
91
- * If the remapping function returns `Some(v)`, the mapping is updated with the new value `v`.
92
- * If the remapping function returns `None`, the mapping is removed (or remains absent if initially absent).
93
- * If the function itself throws an exception, the exception is rethrown, and the current mapping is left unchanged.
94
- *
95
- * @param key the key value
96
- * @param remappingFunction a partial function that receives current optionally-mapped value and return a new mapping
97
- * @return A new map with the updated mapping with the key
98
- */
99
- updatedWith(key: K): (remappingFunction: (maybeValue: Option<V>) => Option<V>) => HashMap<K, V> {
100
- const previousValue = this.get(key);
101
- return (remappingFunction: (maybeValue: Option<V>) => Option<V>) => {
102
- const nextValue = remappingFunction(previousValue);
103
- if (previousValue.isEmpty && nextValue.isEmpty) {
104
- return this;
105
- } else if (previousValue.isDefined && nextValue.isEmpty) {
106
- return this.removed(key);
107
- } else {
108
- return this.updated(key, nextValue.get);
109
- }
110
- };
111
- }
112
-
113
- get toMutable(): mutable.HashMap<K, V> {
114
- return mutable.HashMap.of(...Array.from(this.map.entries()));
115
- }
116
- }
package/src/hashset.ts DELETED
@@ -1,134 +0,0 @@
1
- import {HashMap} from './hashmap';
2
- import {AbstractSet} from './abstract-set';
3
- import * as mutable from './mutable/hashset';
4
-
5
- export class HashSet<T> extends AbstractSet<T, HashSet<T>> {
6
-
7
- protected constructor(items: Set<T>) {
8
- super(items);
9
- }
10
-
11
- static empty = new HashSet<any>(new Set());
12
-
13
- static of<T>(...items: T[]): HashSet<T> {
14
- return new HashSet<T>(new Set(items));
15
- }
16
-
17
- static from<T>(elements: Iterable<T>): HashSet<T> {
18
- return new HashSet<T>(new Set(elements));
19
- }
20
-
21
- protected fromArray(array: T[]): HashSet<T> {
22
- return HashSet.of(...array);
23
- }
24
-
25
-
26
- toMap<K, V>(mapper: (item: T) => [K, V]): HashMap<K, V> {
27
- return HashMap.of(...this.map(mapper).toArray);
28
- }
29
-
30
-
31
- /**
32
- * Builds a new HashSet by applying a function to all elements of this $coll.
33
- *
34
- * @param f the function to apply to each element.
35
- * @tparam B the element type of the returned $coll.
36
- * @return a new HashSet resulting from applying the given function
37
- * `f` to each element of this HashSet and collecting the results.
38
- */
39
- map<B>(f: (item: T) => B): HashSet<B> {
40
- return HashSet.of(...Array.from(this.items).map(i => f(i)));
41
- }
42
-
43
-
44
- /** Builds a new HashSet by applying a function to all elements of this HashSet
45
- * and using the elements of the resulting collections.
46
- *
47
- * For example:
48
- *
49
- * ```
50
- * getWords(lines: HashSet<string>): HashSet<string> {
51
- * return lines.flatMap(line => HashSet.from(line.split("\\W+")))
52
- * }
53
- * ```
54
- *
55
- *
56
- * @param f the function to apply to each element.
57
- * @tparam B the element type of the returned collection.
58
- * @return a new HashSet resulting from applying the given collection-valued function
59
- * `f` to each element of this HashSet and concatenating the results.
60
- */
61
- flatMap<B>(f: (item: T) => HashSet<B>): HashSet<B> {
62
- const res = new Set<B>();
63
- this.items.forEach(i =>
64
- f(i).foreach(e => res.add(e))
65
- );
66
- return new HashSet(res);
67
- }
68
-
69
-
70
- /** Creates a new $coll by adding all elements contained in another collection to this $coll, omitting duplicates.
71
- *
72
- * This method takes a collection of elements and adds all elements, omitting duplicates, into $coll.
73
- *
74
- * Example:
75
- * {{{
76
- * scala> val a = Set(1, 2) concat Set(2, 3)
77
- * a: scala.collection.immutable.Set[Int] = Set(1, 2, 3)
78
- * }}}
79
- *
80
- * @param that the collection containing the elements to add.
81
- * @return a new $coll with the given elements added, omitting duplicates.
82
- */
83
- concat(that: Iterable<T>): HashSet<T> {
84
- return this.appendedAll(that);
85
- }
86
-
87
- union(other: Iterable<T>): HashSet<T> {
88
- return this.concat(other);
89
- }
90
-
91
- appended(item: T): HashSet<T> {
92
- return this.fromArray(this.toArray.concat([item]));
93
- }
94
-
95
- appendedAll(other: Iterable<T>): HashSet<T> {
96
- const res = Array.from(this.items);
97
- res.push(...Array.from(other));
98
- return this.fromArray(res);
99
- }
100
-
101
- removed(item: T): HashSet<T> {
102
- const res = new Set(Array.from(this.items));
103
- res.delete(item);
104
- return new HashSet(res);
105
- }
106
-
107
- removedAll(other: Iterable<T>): HashSet<T> {
108
- const res = new Set(Array.from(this.items));
109
- for (const element of other) {
110
- res.delete(element);
111
- }
112
- return new HashSet(res);
113
- }
114
-
115
- /**
116
- * Computes the intersection between this set and another set.
117
- *
118
- * @param other the set to intersect with.
119
- * @return a new set consisting of all elements that are both in this
120
- * set and in the given set `that`.
121
- */
122
- intersect(other: HashSet<T>): HashSet<T> {
123
- return this.filter(x => other.contains(x));
124
- }
125
-
126
- /**
127
- * Creates the immutable HashMap with the contents from this HashMap.
128
- * @return immutable HashMap
129
- */
130
- get toMutable(): mutable.HashSet<T> {
131
- return mutable.HashSet.of(...this.items);
132
- }
133
-
134
- }
package/src/index.ts DELETED
@@ -1,10 +0,0 @@
1
- export * from './collection';
2
- export * from './either';
3
- export * from './hashmap';
4
- export * from './hashset';
5
- export * from './option';
6
- export * from './try';
7
- export * from './util';
8
-
9
- import * as mutable from './mutable';
10
- export {mutable};
package/src/mappable.ts DELETED
@@ -1,8 +0,0 @@
1
- export interface Mappable<C> {
2
-
3
- map<B>(f: (item: C) => B): Mappable<B>;
4
- flatMap<B>(f: (item: C) => Mappable<B>): Mappable<B>;
5
-
6
- mapPromise<B>(f: (v: C) => Promise<B>): Promise<Mappable<B>>;
7
- flatMapPromise<B>(f: (item: C) => Promise<Mappable<B>>): Promise<Mappable<B>>;
8
- }
@@ -1,247 +0,0 @@
1
- import {Option} from '../option';
2
- import {AbstractMap, Tuple2} from '../abstract-map';
3
- import * as immutable from '../hashmap';
4
-
5
- export class HashMap<K, V> extends AbstractMap<K, V, HashMap<K, V>> {
6
-
7
- constructor(map: Map<K, V> = new Map()) {
8
- super(map);
9
- }
10
-
11
- protected fromArray(array: Tuple2<K, V>[]): HashMap<K, V> {
12
- return HashMap.of(...array);
13
- }
14
-
15
- static of<K, V>(...values: Tuple2<K, V>[]): HashMap<K, V> {
16
- return new HashMap<K, V>(new Map(values));
17
- }
18
-
19
- static from<K, V>(values: Iterable<Tuple2<K, V>>): HashMap<K, V> {
20
- return HashMap.of(...Array.from(values));
21
- }
22
-
23
- /** Adds all elements produced by an Iterable to this HashMap.
24
- *
25
- * @param values the Iterable producing the elements to HashMap.
26
- * @return the HashMap itself.
27
- */
28
- addAll(values: Iterable<Tuple2<K, V>>): this {
29
- for (const [key, value] of values) {
30
- this.map.set(key, value);
31
- }
32
- return this;
33
- }
34
-
35
-
36
- /**
37
- * Update a mapping for the specified key and its current optionally-mapped value
38
- * (`Some` if there is current mapping, `None` if not).
39
- *
40
- * If the remapping function returns `Some(v)`, the mapping is updated with the new value `v`.
41
- * If the remapping function returns `None`, the mapping is removed (or remains absent if initially absent).
42
- * If the function itself throws an exception, the exception is rethrown, and the current mapping is left unchanged.
43
- *
44
- * @param key the key value
45
- * @param remappingFunction a partial function that receives current optionally-mapped value and return a new mapping
46
- * @return the new value associated with the specified key
47
- */
48
- updateWith(key: K): (remappingFunction: (maybeValue: Option<V>) => Option<V>) => Option<V> {
49
- const previousValue = this.get(key);
50
-
51
- return (remappingFunction: (maybeValue: Option<V>) => Option<V>) => {
52
- const nextValue = remappingFunction(previousValue);
53
- if (previousValue.isEmpty && nextValue.isEmpty) {
54
- return nextValue;
55
- } else if (previousValue.isDefined && nextValue.isEmpty) {
56
- this.remove(key);
57
- return nextValue;
58
- } else {
59
- this.update(key, nextValue.get);
60
- return nextValue;
61
- }
62
-
63
- };
64
- }
65
-
66
- /**
67
- * Removes all elements produced by an iterator from this $coll.
68
- *
69
- * @param values the iterator producing the elements to remove.
70
- * @return the hashmap itself
71
- */
72
- subtractAll(values: Iterable<K>): this {
73
- if (this.isEmpty) {
74
- return this;
75
- }
76
-
77
- for (const key of values) {
78
- this.map.delete(key);
79
- if (this.isEmpty) {
80
- return this;
81
- }
82
- }
83
-
84
- return this;
85
- }
86
-
87
-
88
- /** Clears the map's contents. After this operation, the
89
- * map is empty.
90
- */
91
- clear(): void {
92
- this.map.clear();
93
- }
94
-
95
- /**
96
- * Creates new Hashmap with the values from this HashMap
97
- * @return new Hashmap
98
- */
99
- clone(): HashMap<K, V> {
100
- const contentClone = new Map(this.map);
101
- return new HashMap<K, V>(contentClone);
102
- }
103
-
104
- /**
105
- * Retains only those mappings for which the predicate
106
- * `p` returns `true`.
107
- *
108
- * @param p The test predicate
109
- */
110
- filterInPlace(p: (entry: Tuple2<K, V>) => boolean): this {
111
- if (this.nonEmpty) {
112
- const entries = this.entries;
113
- entries.foreach(e => {
114
- if (!p(e)) {
115
- this.remove(e[0]);
116
- }
117
- });
118
- }
119
- return this;
120
- }
121
-
122
- /**
123
- * Applies a transformation function to all values contained in this map.
124
- * The transformation function produces new values from existing keys
125
- * associated values.
126
- *
127
- * @param f the transformation to apply
128
- * @return the map itself.
129
- */
130
- mapValuesInPlace(f: (entry: Tuple2<K, V>) => V): this {
131
- if (this.nonEmpty) {
132
- const entries = this.entries;
133
- entries.foreach(e => {
134
- this.update(e[0], f(e));
135
- });
136
- }
137
- return this;
138
- }
139
-
140
- /**
141
- * If given key is already in this map, returns associated value.
142
- *
143
- * Otherwise, computes value from given expression `op`, stores with key
144
- * in map and returns that value.
145
- *
146
- * Concurrent map implementations may evaluate the expression `op`
147
- * multiple times, or may evaluate `op` without inserting the result.
148
- *
149
- * @param key the key to test
150
- * @param defaultValue the computation yielding the value to associate with `key`, if
151
- * `key` is previously unbound.
152
- * @return the value associated with key (either previously or as a result
153
- * of executing the method).
154
- */
155
- getOrElseUpdate(key: K, defaultValue: () => V): V {
156
- return this.get(key).getOrElse(() => {
157
- const newValue = defaultValue();
158
- this.map.set(key, newValue);
159
- return newValue;
160
- });
161
- }
162
-
163
- /**
164
- * Adds a single element to this map.
165
- *
166
- * @param key the element to add.
167
- * @param value the element's value.
168
- * @return the map itself
169
- */
170
- set(key: K, value: V): this {
171
- this.map.set(key, value);
172
- return this;
173
- }
174
-
175
- /**
176
- * Adds a new key/value pair to this map and optionally returns previously bound value.
177
- * If the map already contains a
178
- * mapping for the key, it will be overridden by the new value.
179
- *
180
- * @param key the key to update
181
- * @param value the new value
182
- * @return an option value containing the value associated with the key
183
- * before the `put` operation was executed, or `None` if `key`
184
- * was not defined in the map before.
185
- */
186
- put(key: K, value: V): Option<V> {
187
- const res = this.get(key);
188
- this.map.set(key, value);
189
- return res;
190
- }
191
-
192
- /**
193
- * Removes a key from this map, returning the value associated previously
194
- * with that key as an option.
195
- * @param key the key to be removed
196
- * @return an option value containing the value associated previously with `key`,
197
- * or `None` if `key` was not defined in the map before.
198
- */
199
- remove(key: K): Option<V> {
200
- const res = this.get(key);
201
- this.subtractOne(key);
202
- return res;
203
- }
204
-
205
- /**
206
- * Adds a new key/value pair to this map.
207
- * If the map already contains a
208
- * mapping for the key, it will be overridden by the new value.
209
- *
210
- * @param key The key to update
211
- * @param value The new value
212
- */
213
- update(key: K, value: V): void {
214
- this.map.set(key, value);
215
- }
216
-
217
- /**
218
- * Adds a single element to this map.
219
- *
220
- * @param elem the element to $=add.
221
- * @return the map itself
222
- */
223
- addOne(elem: Tuple2<K, V>): this {
224
- this.map.set(elem[0], elem[1]);
225
- return this;
226
- }
227
-
228
- /**
229
- * Removes a single element from this $coll.
230
- *
231
- * @param key the element to remove.
232
- * @return the map itself
233
- */
234
- subtractOne(key: K): this {
235
- this.map.delete(key);
236
- return this;
237
- }
238
-
239
- /**
240
- * Creates the immutable HashMap with the contents from this HashMap.
241
- * @return immutable HashMap
242
- */
243
- get toImmutable(): immutable.HashMap<K, V> {
244
- return immutable.HashMap.of(...this.map.entries());
245
- }
246
-
247
- }
@@ -1,177 +0,0 @@
1
- import {AbstractSet} from '../abstract-set';
2
- import * as immutable from '../hashset';
3
-
4
- export class HashSet<T> extends AbstractSet<T, HashSet<T>> {
5
-
6
- constructor(items: Set<T> = new Set()) {
7
- super(items);
8
- }
9
-
10
- static of<T>(...items: T[]): HashSet<T> {
11
- return new HashSet<T>(new Set(items));
12
- }
13
-
14
- static from<T>(values: Iterable<T>): HashSet<T> {
15
- return HashSet.of(...Array.from(values));
16
- }
17
-
18
- protected fromArray(array: T[]): HashSet<T> {
19
- return HashSet.of(...array);
20
- }
21
-
22
- /**
23
- * Adds an element to this set
24
- * @param elem element to add
25
- * @return true if the element wasn't already contained in the set
26
- */
27
- add(elem: T): boolean {
28
- const res = this.items.has(elem);
29
- if (!res) {
30
- this.items.add(elem);
31
- return true;
32
- } else {
33
- return !res;
34
- }
35
- }
36
-
37
- /**
38
- * Adds all elements produced by an Iterable to this set.
39
- *
40
- * @param xs the Iterable producing the elements to add.
41
- * @return the set itself.
42
- */
43
- addAll(xs: Iterable<T>): this {
44
- for (const x of xs) {
45
- this.items.add(x);
46
- }
47
- return this;
48
- }
49
-
50
- /**
51
- * Removes all elements produced by an iterator from this set.
52
- *
53
- * @param xs the iterator producing the elements to remove.
54
- * @return the set itself
55
- */
56
- subtractAll(xs: Iterable<T>): this {
57
- for (const x of xs) {
58
- this.items.delete(x);
59
- }
60
- return this;
61
- }
62
-
63
- /**
64
- * Removes an element from this set.
65
- *
66
- * @param elem the element to be removed
67
- * @return true if this set contained the element before it was removed
68
- */
69
- remove(elem: T) : boolean {
70
- const res = this.items.has(elem);
71
- if (res) {
72
- this.items.delete(elem);
73
- return true;
74
- } else {
75
- return res;
76
- }
77
-
78
- }
79
-
80
-
81
- /**
82
- * Removes all elements from the set for which do not satisfy a predicate.
83
- * @param p the predicate used to test elements. Only elements for
84
- * which `p` returns `true` are retained in the set; all others
85
- * are removed.
86
- */
87
- filterInPlace(p: (item: T) => boolean): this {
88
- if (this.nonEmpty) {
89
- const arr = this.toArray;
90
- for (const t of arr) {
91
- if (!p(t)) {
92
- this.remove(t);
93
- }
94
- }
95
- }
96
- return this;
97
- }
98
-
99
-
100
- /** Clears the set's contents. After this operation, the
101
- * set is empty.
102
- */
103
- clear(): void {
104
- this.items.clear();
105
- }
106
-
107
- /**
108
- * Adds a single element to this set.
109
- *
110
- * @param elem the element to add.
111
- * @return the $coll itself
112
- */
113
- addOne(elem: T): this {
114
- this.add(elem);
115
- return this;
116
- }
117
-
118
-
119
- /** Removes a single element from this set.
120
- *
121
- * @param elem the element to remove.
122
- * @return the set itself
123
- */
124
- subtractOne(elem: T): this {
125
- this.remove(elem);
126
- return this;
127
- }
128
-
129
- /**
130
- * Creates a new $coll by adding all elements contained in another collection to this $coll, omitting duplicates.
131
- *
132
- * This method takes a collection of elements and adds all elements, omitting duplicates, into $coll.
133
- *
134
- * Example:
135
- * {{{
136
- * scala> val a = Set(1, 2) concat Set(2, 3)
137
- * a: scala.collection.immutable.Set[Int] = Set(1, 2, 3)
138
- * }}}
139
- *
140
- * @param that the collection containing the elements to add.
141
- * @return a new $coll with the given elements added, omitting duplicates.
142
- */
143
- concat(that: Iterable<T>): HashSet<T> {
144
- const newSet = new Set<T>([...this.items, ...that]);
145
- return new HashSet<T>(newSet);
146
- }
147
-
148
- /**
149
- * Computes the intersection between this set and another set.
150
- *
151
- * @param that the set to intersect with.
152
- * @return a new set consisting of all elements that are both in this
153
- * set and in the given set `that`.
154
- */
155
- intersect(that: AbstractSet<T, any>): HashSet<T> {
156
- return this.filter(x => that.contains(x));
157
- }
158
-
159
- /** Computes the union between of set and another set.
160
- *
161
- * @param that the set to form the union with.
162
- * @return a new set consisting of all elements that are in this
163
- * set or in the given set `that`.
164
- */
165
- union(that: AbstractSet<T, any>): HashSet<T> {
166
- return this.concat(that);
167
- }
168
-
169
- /**
170
- * Creates the immutable HashMap with the contents from this HashMap.
171
- * @return immutable HashMap
172
- */
173
- get toImmutable(): immutable.HashSet<T> {
174
- return immutable.HashSet.of(...this.items);
175
- }
176
-
177
- }
package/src/mutable.ts DELETED
@@ -1,3 +0,0 @@
1
- export {ArrayBuffer} from './collection';
2
- export {HashMap} from './mutable/hashmap';
3
- export {HashSet} from './mutable/hashset';