MCPcopy Create free account
hub / github.com/Effect-TS/effect / number

Function number

packages/effect/src/Hash.ts:320–338  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

318 * @since 2.0.0
319 */
320export const number = (n: number) => {
321 if (n !== n) {
322 return string("NaN")
323 }
324 if (n === Infinity) {
325 return string("Infinity")
326 }
327 if (n === -Infinity) {
328 return string("-Infinity")
329 }
330 let h = n | 0
331 if (h !== n) {
332 h ^= n * 0xffffffff
333 }
334 while (n > 0xffffffff) {
335 h ^= n /= 0xffffffff
336 }
337 return optimize(h)
338}
339
340/**
341 * Computes a hash value for a string using the djb2 algorithm.

Callers 3

hashFunction · 0.70
randomFunction · 0.70
dateTime.tsFile · 0.50

Calls 2

optimizeFunction · 0.85
stringFunction · 0.70

Tested by

no test coverage detected