v4.0.0-beta.1
Pre-release
Pre-release
4.0.0-beta.1 (2022-08-17)
Bug Fixes
- grid: fix bug where internal hexes were cleared after Grid run() was called (cb6c65d), closes #67
- grid: fix incorrect width or height calculation in Grid.rectangleFromOpposingCorners() (3b4bb7c)
- grid: fix neighborOf() (and functions that use it like move()) (3b8cdf6)
- grid: grid's update() now always returns a grid that iterates over hexes in its store (b2a0298), closes #68
- grid: grids are now iterable again (e.g.:
[...grid]
orfor (const hex of grid) {})
) (c142a68) - hex: createHex() now also accepts tuple coordinates (8f5196e)
- hex: fix typing issue for createHexPrototype() (d6e24b4)
- hex: when overriding a hex prototype method,
this
is now correctly typed (8df5488), closes 1#comment116992054_66162731 - move (internal) util to fix circular dependency (be57fee)
Code Refactoring
- grid: rename at() to add() and make it accept multiple coordinates (e63f650)
Features
- add benny for running benchmarks (in node) (63a932f)
- add parcel-bundler and playground (2845088)
- coordinates: expand the HexCoordinates type to include a tuple of axial or cube coordinates (ca41673)
- createHexPrototype() adds several readonly properties (WIP) (6af96e1)
- first functionality of v4.0 (WIP) (fcd005a)
- fix reference to type declaration and improve typing of
createHexPrototype()
(2c53678) - grid/neighborof: returns a hex instead of just coordinates (fa9f2f0)
- grid/transduce: add transduce function (efd9c2e)
- grid/transducers: add inGrid() transducer (97660e4)
- grid/transducers: add tap() (28797cf)
- grid/traversers: add repeatWith traverser (8e400af)
- grid/traversers: re-implement rays, ring and spiral (9c84121)
- grid/traversers: revert back to outputting arrays (282f1f1)
- grid: a grid can now be created with an optional traverser (e56ced8)
- grid: add distance function and method that returns the amount of hexes between 2 hexes (7a2de46)
- grid: add from() static method that accepts an iterable of hexes and returns a new grid (83b25ad)
- grid: add GridStore type and make sure the toString() Hex method is called to create an id (99192b2)
- grid: add HexCache class and use it as a start to cache hexes in grid (2b4afeb)
- grid: add hexes() and cursor() methods to Grid (5738045)
- grid: add map() method to Grid (3716e6c)
- grid: add NoOpCache and use it as the default cache in Grid (30d7a87)
- grid: add optional argument to move() traverser to move in the same direction multiple times (f8b96ad)
- grid: add rays() traverser (50e707d)
- grid: add ring() traverser (256879f)
- grid: add setStore helper function and add set method to GridStore interface (10125c1)
- grid: add size getter and hasHex() method (eb41e71)
- grid: add spiral() traverser (d433af0)
- grid: add update() method to Grid (ec0dfce)
- grid: call copy() on the initial cursor hex in Grid.traverse() (98c7054)
- grid: change how a grid's store is set (2376845)
- grid: grids can now be created/traversed with a single traverser or an array of traversers (890ce96)
- grid: improve types and name some anonymous functions for better debugging (383dfbd)
- grid: improve typing of Grid methods and traverse commands (193531d)
- grid: line() now accepts either "line as vector" options or "line between" options (2fe7f1d)
- grid: make CompassDirection a union type (6a65b87)
- grid: more or less settled on Grid API (2cd5c1e)
- grid: move traversers to traversers folder and add utils folder with forEach and map (751be5a)
- grid: pass cursor along with hexes in getPrevHexState() for a ~20% performance increase (a90f083)
- grid: pass getHex() function to all traversers, this way they can use the cache (64ec33b)
- grid: prevent iterators to be run again when run() is called more than once (2e39a3b)
- grid: rectangle() traverser and grid method now accept opposing corners as arguments (b8bab92)
- grid: reimplement traverse to not be a generator (3a7a09e)
- grid: remove map method, add filter and takeWhile methods and add inStore helper function (956a2a0)
- grid: remove move() alias of line() and update signature of line() (5205e93)
- grid: rename HexCache to CoordinatesCache and expand API, add toString() to hex (6a0ca15)
- grid: rename the move() traverser to line() and make move() an alias (7663738)
- grid: restrict Grid.traverse() to the hexes in the grid (from the previous iteration, if any) (c25249b)
- grid: rewrite the rectangle traverser and update Grid.rectangle() to use it, add Compass class (3e0ca95)
- grid: subsequent traverse() calls now stop when attempting to traverse outside the grid (1aa8f73)
- grid: traverse functions don't create hexes anymore (bdfb22b)
- grid: traverse() now also accept transducers (8efa19d)
- grid: traversers no longer accept both a
start
andat
option, only either or none (XOR) (231acf6) - grid: update grid rectangle method to only within previous grid (b242c94)
- grid: update rectangle() to behave as most traversers should (5415029)
- grid: update ring() to behave as most traversers should (e1cdc81)
- grid: use single Compass enum, make move() accept ambiguous directions, improve grid.rectangle (2bf8d1e)
- grid: various changes, mainly traverse() and update() methods (a79be39)
- grid: WIP: rewrite grid things to use iterables and transducers (3c97979)
- hex,grid: add round() and pointToCube() functions and pointToHex() method to Grid (b302c08)
- hex,grid: traversers return hexes (as before), fix move() traverser, add neighborOf() function (b2da583)
- hex: add center() function and method (c0730b5)
- hex: add corners(), width() and height() functions (e9e98da)
- hex: add equals() method to hex prototype (f519448)
- hex: add functions to convert hexes to points (7e1e3da)
- hex: add isHex() function and overload corners() to either accept a hex or hex settings (893c829)
- hex: createHex() now also accepts a hex (instance) and if it does copies it (43d0109)
- hex: hexCoordinates now also include offset coordinates (dd39813)
- hex: normalize and assert all required hex prototype properties in createHexPrototype() (9cf0511)
- hex: rename createToPoint() to hexToPoint() and make it accept a hex (4227737)
- hex: rename offsetToAxial() to offsetToCube() and make it return cube coordinates (52d89f8)
- hex: rename size to dimensions and normalize dimensions in createHexPrototype() (4c08684)
- hex: set hex origin relative to center of hex (0db666d)
- hex: store s cube coordinate when passed to createHex, otherwise use getter (9a9b4a9)
- hex: the equals() function and hex method can now compare different kinds of hex coordinates (5dc14d0)
- hex: toString() now also accepts cube coordinates (1c552c4)
- hex: use axial coordinates by default (775e711)
- remove cartesian coordinates for now (dc959e7)
- remove transducers (072ead5)
- set [Symbol.toStringTag] on Grid and hex prototype (a189f77)
- traversers/line: add support for "stop" coordinates and update tests (2cf143b)
- traversers/ring: it now also accepts a radius (fafdcee)
Performance Improvements
- grid: improve grid creation (0748558)
- grid: replace generators with iterable-returning functions (20655d1)
- tiny improvements (a58c7eb)
BREAKING CHANGES
- grid: When rectangle() isn't passed
start
coordinates it now excludes its first hex
(the cursor, usually{ q: 0, r: 0 }
). In other words: you probably want to passstart
coordinates when using rectangle() - grid: Remove move() alias of line(). line() now accepts an object with options:
direction
,length
,at
andstart
. - grid: The at() traverser is renamed to add()
- hex: offsetToAxial() is now offsetToCube()
- hex: toString() now only accepts axial coordinates
- grid: Remove the of() static grid method, because it's a rather redundant as it does the
same as the constructor. Also update the inStore function to be used directly as a grid iterator
method callback (before change:grid.each(inStore())
, after change:grid.each(inStore)
). Remove
setStore() because it's ambiguous how the store should be set: hexes could be removed/added/updated
from the store.