Utility functions for converting between coordinate objects and string keys. This module provides functions to convert a coordinate object with x and y properties into a string key, and to convert a string key back into a coordinate object. The coordinate format is "x,y", where x and y are numbers. The functions are useful for storing and retrieving coordinates in a hash map or similar data structure.
Returns:
- The string representation of the coordinate.
Type: 
string
Example
// Example usage:
const coord = { x: 10, y: 20 };
const key = coord2Key(coord); // "10,20"
const newCoord = key2Coord(key); // { x: 10, y: 20 }
console.log(newCoord); // { x: 10, y: 20 }

Methods

(static) coord2Key(coord) → {string}

Converts a coordinate object to a string key.
Parameters:
NameTypeDescription
coordObjectThe coordinate object with x and y properties.
Returns:
- The string key in the format "x,y".
Type: 
string

(static) key2Coord(key) → {Object}

Converts a string key back to a coordinate object.
Parameters:
NameTypeDescription
keystringThe string key in the format "x,y".
Returns:
- The coordinate object with x and y properties.
Type: 
Object