Skip to content

Commit 177704a

Browse files
committed
cleanup: Constant
1 parent d2d9a75 commit 177704a

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,18 @@
11
export default class Constant {
22
#value;
33
constructor(value, ...rest) {
4-
if (rest.length) {
5-
this.#value = [value, ...rest];
6-
} else {
7-
this.#value = value;
8-
}
4+
this.#value = [value, ...rest];
95
}
106

117
equals(other) {
12-
return this === other || valueEquals(this.#value, other);
8+
return this === other || this.#value.includes(other?.valueOf());
139
}
1410

1511
toString() {
1612
return this.valueOf();
1713
}
1814

1915
valueOf() {
20-
const value = this.#value;
21-
if (Array.isArray(value)) {
22-
return value[0];
23-
}
24-
return value;
16+
return this.#value[0];
2517
}
2618
}
27-
28-
function valueEquals(value, other) {
29-
const otherValue = other?.valueOf();
30-
if (Array.isArray(value)) {
31-
return value.includes(otherValue);
32-
}
33-
return value === otherValue;
34-
}

0 commit comments

Comments
 (0)