Skip to content

Commit 21a4a54

Browse files
authored
feat: add represent convenience function to data classes (#1037)
1 parent 3abbe2b commit 21a4a54

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
"dependencies": {
6464
"axios": "^0.30.0",
65-
"cafe-utility": "^27.14.2",
65+
"cafe-utility": "^28.1.0",
6666
"isomorphic-ws": "^4.0.1",
6767
"semver": "^7.3.5",
6868
"ws": "^8.7.0"

src/utils/bytes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,8 @@ export class Bytes {
8383
public equals(other: Bytes | Uint8Array | string): boolean {
8484
return this.toHex() === new Bytes(other).toHex()
8585
}
86+
87+
public represent(): string {
88+
return this.toHex()
89+
}
8690
}

src/utils/duration.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Dates } from 'cafe-utility'
2+
13
export class Duration {
24
private seconds: number
35

@@ -60,4 +62,8 @@ export class Duration {
6062
toEndDate(startDate?: Date): Date {
6163
return new Date((startDate ?? new Date()).getTime() + this.seconds * 1000)
6264
}
65+
66+
represent(): string {
67+
return Dates.secondsToHumanTime(this.seconds)
68+
}
6369
}

src/utils/size.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ export class Size {
4545
toFormattedString(): string {
4646
return Numbers.convertBytes(this.bytes, 1000)
4747
}
48+
49+
represent(): string {
50+
return this.toFormattedString()
51+
}
4852
}

0 commit comments

Comments
 (0)