MCPcopy Index your code
hub / github.com/nodejs/node / findLooseMatchingPrimitives

Function findLooseMatchingPrimitives

lib/internal/util/comparisons.js:584–605  ·  view source on GitHub ↗
(prim)

Source from the content-addressed store, hash-verified

582// type is a string, number, bigint or boolean. The reason is that those values
583// can match lots of different string values (e.g., 1n == '+00001').
584function findLooseMatchingPrimitives(prim) {
585 switch (typeof prim) {
586 case 'undefined':
587 return null;
588 case 'object': // Only pass in null as object!
589 return undefined;
590 case 'symbol':
591 return false;
592 case 'string':
593 prim = +prim;
594 // Loose equal entries exist only if the string is possible to convert to
595 // a regular number and not NaN.
596 // Fall through
597 case 'number':
598 // Check for NaN
599 // eslint-disable-next-line no-self-compare
600 if (prim !== prim) {
601 return false;
602 }
603 }
604 return true;
605}
606
607function setMightHaveLoosePrim(a, b, prim) {
608 const altValue = findLooseMatchingPrimitives(prim);

Callers 2

setMightHaveLoosePrimFunction · 0.85
mapMightHaveLoosePrimFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected