UNPKG

@rickosborne/rebound

Version:

Rick Osborne's utilities for working with bounded numbers

26 lines (25 loc) 915 B
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); import { scrubStackTrace } from "@rickosborne/guard"; import { addTypedProperties } from "./typed-function.mjs"; function assertBounded(guard, errorProvider, ifPresent, value, name) { if (value == null && !ifPresent || !guard(value)) { const error = errorProvider(value, name); throw scrubStackTrace(error, "assertBounded"); } } __name(assertBounded, "assertBounded"); function assertForBounds(guard, errorProvider, ifPresent, fnName = `assert${guard.typeName}${ifPresent ? "IfPresent" : ""}`) { return addTypedProperties( assertBounded.bind(void 0, guard, errorProvider, ifPresent), guard, guard.typeName, fnName ); } __name(assertForBounds, "assertForBounds"); export { assertBounded, assertForBounds }; //# sourceMappingURL=assert-bounded.mjs.map