UNPKG

@rickosborne/rebound

Version:

Rick Osborne's utilities for working with bounded numbers

45 lines (44 loc) 1.88 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var assert_bounded_exports = {}; __export(assert_bounded_exports, { assertBounded: () => assertBounded, assertForBounds: () => assertForBounds }); module.exports = __toCommonJS(assert_bounded_exports); var import_guard = require("@rickosborne/guard"); var import_typed_function = require("./typed-function.cjs"); function assertBounded(guard, errorProvider, ifPresent, value, name) { if (value == null && !ifPresent || !guard(value)) { const error = errorProvider(value, name); throw (0, import_guard.scrubStackTrace)(error, "assertBounded"); } } __name(assertBounded, "assertBounded"); function assertForBounds(guard, errorProvider, ifPresent, fnName = `assert${guard.typeName}${ifPresent ? "IfPresent" : ""}`) { return (0, import_typed_function.addTypedProperties)( assertBounded.bind(void 0, guard, errorProvider, ifPresent), guard, guard.typeName, fnName ); } __name(assertForBounds, "assertForBounds"); //# sourceMappingURL=assert-bounded.cjs.map