Skip to content

[2.0.0] Refactor TinyMoon to act as namespace

Compare
Choose a tag to compare
@mannylopez mannylopez released this 30 May 01:43
· 92 commits to main since this release
9ee3712

Breaking change This is a major release, will update version to 2.0.0

TinyMoon namespace

Main change is that instead of having to instantiate TinyMoon, like this

let moon = TinyMoon().calculateMoonPhase()

Now the API is simpler and TinyMoon acts as a namespace, like this

let moon = TinyMoon.calculateMoonPhase()

Simplify Moon

I've also moved the logic of instantiating the Moon object into the Moon initializer, so instead of this

public struct Moon: Hashable {
  init(moonPhase: MoonPhase, lunarDay: Double, maxLunarDay: Double, date: Date) {...}
...
}

The Moon initializer now looks like this

public struct Moon: Hashable {
  init(date: Date) {...}
...
}

This will make it easier to test the functions inside of Moon

To update

// Replace the following
TinyMoon().calculateMoonPhase()
// with
TinyMoon.calculateMoonPhase()