Skip to content

Instantly share code, notes, and snippets.

View flying-sausages's full-sized avatar
🕴️
🌭

flying-sausages

🕴️
🌭
View GitHub Profile
@flying-sausages
flying-sausages / stringFileSize.swift
Last active November 5, 2020 22:30 — forked from mminer/formatBytes.swift
Formats bytes into a more human-readable form (e.g. MiB) using Extensions instead of functions
// Forked from https://gist.github.com/mminer/d0a043b0b6054f428a8ed1f505bfe1b0 to
import Foundation
public extension Double {
var stringFileSize: String {
guard self > 0 else {
return "0 bytes"
}
guard self != 1 else {
return "1 byte"