MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / clamp

Function clamp

src/compute-engine/interval/comparison.ts:210–231  ·  view source on GitHub ↗
(
  x: Interval | IntervalResult,
  lo: Interval | IntervalResult,
  hi: Interval | IntervalResult
)

Source from the content-addressed store, hash-verified

208 return 'maybe';
209}
210
211/**
212 * Greater than comparison for intervals. An `empty` operand gives `'false'`
213 * (`hasEmptyOperand`).
214 */
215export function greater(
216 a: Interval | IntervalResult,
217 b: Interval | IntervalResult
218): BoolInterval {
219 if (hasEmptyOperand(a, b)) return 'false';
220 const unwrapped = unwrapOrPropagate(a, b);
221 if (!Array.isArray(unwrapped)) return 'maybe';
222 const [aVal, bVal] = unwrapped;
223 if (aVal.lo > bVal.hi) return holds(a, b);
224 if (aVal.hi <= bVal.lo) return 'false';
225 return 'maybe';
226}
227
228/**
229 * Greater than or equal comparison for intervals. An `empty` operand gives
230 * `'false'` (`hasEmptyOperand`).
231 */
232export function greaterEqual(
233 a: Interval | IntervalResult,
234 b: Interval | IntervalResult

Callers 1

Calls 1

unwrapOrPropagateFunction · 0.90

Tested by

no test coverage detected