UNPKG

everyutil

Version:

A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.

19 lines (18 loc) 598 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hashNumber = void 0; /** * Generates a stable hash from a number, optionally using a seed. * @author @dailker * @param {number} n - The number to hash. * @param {number} [seed=0] - Optional seed for hashing. * @returns {number} The hash value. */ function hashNumber(n, seed = 0) { let hash = n ^ seed; hash = ((hash >> 16) ^ hash) * 0x45d9f3b; hash = ((hash >> 16) ^ hash) * 0x45d9f3b; hash = (hash >> 16) ^ hash; return hash >>> 0; } exports.hashNumber = hashNumber;