Why use `_ExtractAsInt` in `getHashCode`

I found this function in getHashCode

    const _ExtractAsInt = (value: number) => {
      return parseInt(value.toString().replace(/\W/g, ""));
    };    
   /**
     * Gets current vector hash code
     * @returns the Vector2 hash code as a number
     */
    public getHashCode(): number {
        const x = _ExtractAsInt(this.x);
        const y = _ExtractAsInt(this.y);
        let hash = x;
        hash = (hash * 397) ^ y;
        return hash;
    }

It transforms a number into a positive int, meaning that new Vector(-1,0,1) and new Vector(1,0,1) have the same hash code.

Why not use a hash library or an UUID or just simply use Symbol.for() as an unique identifier?

Welcome aboard!

As I don’t know what this function is for, I can’t really say much, except that the function may generate collisions, so the user should be prepared for this, and the fact that it generates collisions for numbers that differ only in sign shouldn’t matter too much(?).