Swiftpack.co - Package - Alja7dali/swift-bits

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

Alja7dali/swift-bits

A bite sized library for dealing with bytes.
This is a modified forked repo of Vapor-Bits
Why it been modified, because it serve a specific purpose working with bytes only. No need for the extra stuff that the original repo has, they can be in separate repo.

Example:

import Bits

let meaningOfLife: Double = -42.0

let bytes = meaningOfLife.makeBytes()

print(bytes) // [0, 0, 0, 0, 0, 0, 69, 192]

do {
  let float = try Float(bytes)
} catch {
  print(error) // BytesConversionError.invalidConversion(to: Swift.Float)
}

print(Bytes(-42.0 as Float)) // [0, 0, 40, 194]

if let double = try? Double(bytes) {
  print(double) // -42.0
}

Importing Bits:

To include Bits in your project, you need to add the following to the dependencies attribute defined in your Package.swift file.

dependencies: [
  .package(url: "https://github.com/alja7dali/swift-bits.git", from: "1.0.0")
]

Github

link
Stars: 0
Last commit: 1 week ago

Releases

1.0.0 - 2021-02-19T14:13:15

👋 hello, bits!