From f5194484f4edefe9e24295646980596cfd3e3a8e Mon Sep 17 00:00:00 2001 From: Abbe Keultjes Date: Sat, 13 Feb 2021 22:12:54 +0100 Subject: [PATCH] feat(hex): add equals() method to hex prototype --- src/hex/functions/createHexPrototype.ts | 4 ++++ src/hex/types.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/src/hex/functions/createHexPrototype.ts b/src/hex/functions/createHexPrototype.ts index a636e87f..1814a845 100644 --- a/src/hex/functions/createHexPrototype.ts +++ b/src/hex/functions/createHexPrototype.ts @@ -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' @@ -87,6 +88,9 @@ export const createHexPrototype = (customPrototype?: T | Partial< const prototype = { ...defaultHexSettings, + equals(coordinates) { + return equals(this, coordinates) + }, copy(newProps) { return copyHex(this, newProps) }, diff --git a/src/hex/types.ts b/src/hex/types.ts index 07a4372e..671ae78f 100644 --- a/src/hex/types.ts +++ b/src/hex/types.ts @@ -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 | HexCoordinates): this toPoint(this: this): Point