(bases: string, isMin: boolean)
| 1088 | |
| 1089 | const boundMethod = |
| 1090 | (bases: string, isMin: boolean) => |
| 1091 | (d: Deferred, [n, message]: any[]): Facts | undefined => { |
| 1092 | const { bounds, of, min, max, pure, cyclic } = d.facts |
| 1093 | const over = of ? d.facts.base : bounds |
| 1094 | if ( |
| 1095 | // a bound with its own message isn't the one its facts write |
| 1096 | message !== undefined || |
| 1097 | cyclic === true || |
| 1098 | !over || |
| 1099 | (!pure && (!of || over !== "array")) || |
| 1100 | !bases.includes(over) || |
| 1101 | typeof n !== "number" || |
| 1102 | // a node holds -0 apart from 0, which a key writes as one |
| 1103 | Object.is(n, -0) || |
| 1104 | !(over === "number" ? |
| 1105 | Number.isFinite(n) |
| 1106 | : Number.isSafeInteger(n) && n >= 0) |
| 1107 | ) |
| 1108 | return |
| 1109 | // what's narrower holds |
| 1110 | const lo = isMin && !(min! > n) ? n : min |
| 1111 | const hi = !isMin && !(max! < n) ? n : max |
| 1112 | if ((lo ?? -Infinity) > (hi ?? Infinity)) return |
| 1113 | // a narrowed number bounded to one value is a unit its predicate checks |
| 1114 | if (!of && lo === hi && (over === "number" || over === "integer")) return |
| 1115 | return of ? |
| 1116 | rangeFacts(d.facts, lo, hi) |
| 1117 | : { |
| 1118 | ...d.facts, |
| 1119 | key: `${wrap(d.facts)}${isMin ? ">=" : "<="}${n}`, |
| 1120 | terms: undefined, |
| 1121 | min: lo, |
| 1122 | max: hi, |
| 1123 | // a narrow's facts don't say which of its bounds it excludes |
| 1124 | ends: |
| 1125 | over === "number" || over === "integer" ? |
| 1126 | endsOf(lo, hi) |
| 1127 | : d.facts.ends |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | const metaFacts = (d: Deferred, meta: object): Facts => ({ |
| 1132 | ...d.facts, |
no test coverage detected