Contents

brantonb/RunningPace

Swift Package adding .minutesPerMile and .minutesPerKilometer to UnitSpeed, along with operators useful for working with speeds, durations, and distances.

Usage

// Basic usage
let pace = Measurement<UnitSpeed>(value: 10, unit: .minutesPerMile)
print(pace) // "10.0 min/mile"

// Usage with type aliases
let kmPace = Speed(value: 6, unit: .minutesPerKilometer)
let duration = Duration(value: 30, unit: .minutes)
let distance = Distance(value: 1600, unit: .meters)

// Usage with Double extensions
let milePace = 10.minutesPerMile
let duration = 30.5.minutes
let distance = 5.miles

// Operators
let duration = 10.miles * 6.25.minutesPerMile
let distance = 51.minutes * 5.minutesPerKilometer
let speed = (17.minutes / 5.kilometers).converted(to: .minutesPerMile)

Installation

Swift Package Manager

This component is designed to be used with Swift Package Manager. Add the following to your Package.swift file's dependencies:

.package(url: "https://github.com/brantonb/RunningPace.git", from: "0.1.0")

And then add import RunningPace wherever needed.

Contributing

Pull requests are welcome. Before submitting, please ensure that all tests pass and SwiftLint is clean.

SwiftLint

This project uses SwiftLint via the Mint package manager. After installing Mint, run SwiftLint by executing:

$ mint run swiftlint

Testing on Linux with Docker

Install Docker and then run ./testLinuxOnDocker.sh. It will pull the latest swift image from Docker Hub, mount the current directory at /src, and then run the tests from inside the container.

Package Metadata

Repository: brantonb/RunningPace

Stars: 5

Forks: 1

Open issues: 0

Default branch: main

Primary language: swift

License: MIT

README: README.md