Skip to content

Commit 7d333fd

Browse files
authored
Merge pull request #10 from vapor/sizes
size helpers
2 parents 1aa7bc3 + 3bc0a4b commit 7d333fd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Sources/Bits/Aliases.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,18 @@ public typealias Bytes = [Byte]
1212
A sliced collection of raw data
1313
*/
1414
public typealias BytesSlice = ArraySlice<Byte>
15+
16+
// MARK: Sizes
17+
18+
private let _bytes = 1
19+
private let _kilobytes = _bytes * 1000
20+
private let _megabytes = _kilobytes * 1000
21+
private let _gigabytes = _megabytes * 1000
22+
23+
extension Int {
24+
public var bytes: Int { return self }
25+
public var kilobytes: Int { return self * _kilobytes }
26+
public var megabytes: Int { return self * _megabytes }
27+
public var gigabytes: Int { return self * _gigabytes }
28+
}
29+

0 commit comments

Comments
 (0)