-
Notifications
You must be signed in to change notification settings - Fork 3
/
byteSize.ts
36 lines (29 loc) · 895 Bytes
/
byteSize.ts
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
import { ByteSize } from './src/Humanizer/Bytes/ByteSize'
declare global {
interface Number {
bits(): ByteSize
bytes(): ByteSize
kilobytes(): ByteSize
megabytes(): ByteSize
gigabytes(): ByteSize
terabytes(): ByteSize
}
}
Number.prototype.bits = function (): ByteSize {
return ByteSize.fromBits(this as number)
}
Number.prototype.bytes = function (): ByteSize {
return ByteSize.fromBytes(this as number)
}
Number.prototype.kilobytes = function (): ByteSize {
return ByteSize.fromKilobytes(this as number)
}
Number.prototype.megabytes = function (): ByteSize {
return ByteSize.fromMegabytes(this as number)
}
Number.prototype.gigabytes = function (): ByteSize {
return ByteSize.fromGigabytes(this as number)
}
Number.prototype.terabytes = function (): ByteSize {
return ByteSize.fromTerabytes(this as number)
}