Skip to content

Commit

Permalink
feat(hex): add equals() method to hex prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
flauwekeul committed Apr 22, 2021
1 parent 2b4afeb commit f519448
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hex/functions/createHexPrototype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { isFunction, isObject, isPoint } from '../../utils'
import { DefaultHexPrototype, Ellipse, Hex, HexSettings, Orientation, Point, Rectangle } from '../types'
import { copyHex } from './copyHex'
import { corners } from './corners'
import { equals } from './equals'
import { height } from './height'
import { hexToOffset } from './hexToOffset'
import { hexToPoint } from './hexToPoint'
Expand Down Expand Up @@ -87,6 +88,9 @@ export const createHexPrototype = <T extends Hex>(customPrototype?: T | Partial<

const prototype = {
...defaultHexSettings,
equals(coordinates) {
return equals(this, coordinates)
},
copy(newProps) {
return copyHex(this, newProps)
},
Expand Down
1 change: 1 addition & 0 deletions src/hex/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface DefaultHexPrototype extends HexSettings {

s: number

equals(this: this, coordinates: HexCoordinates): boolean
// todo: about 80% sure the newProps type works (it's used in more places, if it works: maybe make it a separate type?)
copy(this: this, newProps?: Partial<this> | HexCoordinates): this
toPoint(this: this): Point
Expand Down

0 comments on commit f519448

Please sign in to comment.