utilium 0.6.3 → 0.7.0

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.
package/dist/list.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
- export declare class List<T> extends EventEmitter<'update'> implements Set<T>, RelativeIndexable<T> {
2
+ export declare class List<T> extends EventEmitter<'update'> implements RelativeIndexable<T> {
3
3
  readonly [Symbol.toStringTag] = "List";
4
4
  constructor(values?: readonly T[] | Iterable<T> | null);
5
5
  protected data: Set<T>;
6
- array(): T[];
7
- json(): string;
6
+ toSet(): Set<T>;
7
+ toArray(): T[];
8
+ toJSON(): string;
8
9
  toString(): string;
9
10
  set(index: number, value: T): void;
10
11
  deleteAt(index: number): void;
@@ -16,14 +17,6 @@ export declare class List<T> extends EventEmitter<'update'> implements Set<T>, R
16
17
  add(value: T): this;
17
18
  clear(): void;
18
19
  delete(value: T): boolean;
19
- union<U>(other: ReadonlySetLike<U>): List<T | U>;
20
- intersection<U>(other: ReadonlySetLike<U>): List<T & U>;
21
- difference<U>(other: ReadonlySetLike<U>): List<T>;
22
- symmetricDifference<U>(other: ReadonlySetLike<U>): List<T | U>;
23
- isSubsetOf(other: ReadonlySetLike<unknown>): boolean;
24
- isSupersetOf(other: ReadonlySetLike<unknown>): boolean;
25
- isDisjointFrom(other: ReadonlySetLike<unknown>): boolean;
26
- forEach(callbackfn: (value: T, value2: T, list: List<T>) => void, thisArg?: any): void;
27
20
  has(value: T): boolean;
28
21
  get size(): number;
29
22
  entries(): IterableIterator<[T, T]>;
package/dist/list.js CHANGED
@@ -8,10 +8,13 @@ export class List extends EventEmitter {
8
8
  }
9
9
  }
10
10
  data = new Set();
11
- array() {
11
+ toSet() {
12
+ return new Set(this.data);
13
+ }
14
+ toArray() {
12
15
  return [...this.data];
13
16
  }
14
- json() {
17
+ toJSON() {
15
18
  return JSON.stringify([...this.data]);
16
19
  }
17
20
  toString() {
@@ -80,31 +83,6 @@ export class List extends EventEmitter {
80
83
  this.emit('update');
81
84
  return success;
82
85
  }
83
- union(other) {
84
- return new List(this.data.union(other));
85
- }
86
- intersection(other) {
87
- return new List(this.data.intersection(other));
88
- }
89
- difference(other) {
90
- return new List(this.data.difference(other));
91
- }
92
- symmetricDifference(other) {
93
- return new List(this.data.symmetricDifference(other));
94
- }
95
- isSubsetOf(other) {
96
- return this.data.isSubsetOf(other);
97
- }
98
- isSupersetOf(other) {
99
- return this.data.isSupersetOf(other);
100
- }
101
- isDisjointFrom(other) {
102
- return this.data.isDisjointFrom(other);
103
- }
104
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
- forEach(callbackfn, thisArg) {
106
- this.data.forEach((v1, v2) => callbackfn.call(thisArg, v1, v2, this));
107
- }
108
86
  has(value) {
109
87
  return this.data.has(value);
110
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "0.6.3",
3
+ "version": "0.7.0",
4
4
  "description": "Typescript utilies",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/list.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
 
3
- export class List<T> extends EventEmitter<'update'> implements Set<T>, RelativeIndexable<T> {
3
+ export class List<T> extends EventEmitter<'update'> implements RelativeIndexable<T> {
4
4
  public readonly [Symbol.toStringTag] = 'List';
5
5
 
6
6
  public constructor(values?: readonly T[] | Iterable<T> | null) {
@@ -12,11 +12,15 @@ export class List<T> extends EventEmitter<'update'> implements Set<T>, RelativeI
12
12
 
13
13
  protected data = new Set<T>();
14
14
 
15
- public array(): T[] {
15
+ public toSet(): Set<T> {
16
+ return new Set(this.data);
17
+ }
18
+
19
+ public toArray(): T[] {
16
20
  return [...this.data];
17
21
  }
18
22
 
19
- public json() {
23
+ public toJSON() {
20
24
  return JSON.stringify([...this.data]);
21
25
  }
22
26
 
@@ -103,39 +107,6 @@ export class List<T> extends EventEmitter<'update'> implements Set<T>, RelativeI
103
107
  return success;
104
108
  }
105
109
 
106
- public union<U>(other: ReadonlySetLike<U>): List<T | U> {
107
- return new List(this.data.union(other));
108
- }
109
-
110
- public intersection<U>(other: ReadonlySetLike<U>): List<T & U> {
111
- return new List(this.data.intersection(other));
112
- }
113
-
114
- public difference<U>(other: ReadonlySetLike<U>): List<T> {
115
- return new List(this.data.difference(other));
116
- }
117
-
118
- public symmetricDifference<U>(other: ReadonlySetLike<U>): List<T | U> {
119
- return new List(this.data.symmetricDifference(other));
120
- }
121
-
122
- public isSubsetOf(other: ReadonlySetLike<unknown>): boolean {
123
- return this.data.isSubsetOf(other);
124
- }
125
-
126
- public isSupersetOf(other: ReadonlySetLike<unknown>): boolean {
127
- return this.data.isSupersetOf(other);
128
- }
129
-
130
- public isDisjointFrom(other: ReadonlySetLike<unknown>): boolean {
131
- return this.data.isDisjointFrom(other);
132
- }
133
-
134
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
135
- public forEach(callbackfn: (value: T, value2: T, list: List<T>) => void, thisArg?: any): void {
136
- this.data.forEach((v1, v2) => callbackfn.call(thisArg, v1, v2, this));
137
- }
138
-
139
110
  public has(value: T): boolean {
140
111
  return this.data.has(value);
141
112
  }