Skip to content

Commit

Permalink
feat(hex): toString() now also accepts cube coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
flauwekeul committed Apr 22, 2021
1 parent 5738045 commit 1c552c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/hex/functions/toString.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import { toString } from './toString'

test('returns a string representation of the hex coordinates', () => {
expect(toString({ q: 1, r: 2 })).toBe('1,2')
expect(toString({ q: 1, r: 2, s: -3 })).toBe('1,2')
})
4 changes: 2 additions & 2 deletions src/hex/functions/toString.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { AxialCoordinates } from '../types'
import { PartialCubeCoordinates } from '../types'

export const toString = ({ q, r }: AxialCoordinates) => `${q},${r}`
export const toString = ({ q, r }: PartialCubeCoordinates) => `${q},${r}`

0 comments on commit 1c552c4

Please sign in to comment.