LCOV - code coverage report
Current view: top level - randomjs/distribution - real.ts (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 4 21 19.0 %
Date: 2021-03-12 10:43:40 Functions: 0 1 0.0 %

          Line data    Source code
       1             : import { Distribution } from "../types.ts";
       2           1 : import { add } from "../utils/add.ts";
       3           1 : import { multiply } from "../utils/multiply.ts";
       4           1 : import { realZeroToOneExclusive } from "./realZeroToOneExclusive.ts";
       5           1 : import { realZeroToOneInclusive } from "./realZeroToOneInclusive.ts";
       6             : 
       7             : /**
       8             :  * Returns a floating-point value within [min, max) or [min, max]
       9             :  * @param min The minimum floating-point value, inclusive.
      10             :  * @param max The maximum floating-point value.
      11             :  * @param inclusive If true, `max` will be inclusive.
      12             :  */
      13           0 : export function real(
      14           0 :   min: number,
      15           0 :   max: number,
      16           0 :   inclusive: boolean = false
      17             : ): Distribution {
      18           0 :   if (!isFinite(min)) {
      19           0 :     throw new RangeError("Expected min to be a finite number");
      20           0 :   } else if (!isFinite(max)) {
      21           0 :     throw new RangeError("Expected max to be a finite number");
      22           0 :   }
      23           0 :   return add(
      24           0 :     multiply(
      25           0 :       inclusive ? realZeroToOneInclusive : realZeroToOneExclusive,
      26           0 :       max - min
      27           0 :     ),
      28           0 :     min
      29           0 :   );
      30           0 : }

Generated by: LCOV version 1.15