LCOV - code coverage report
Current view: top level - src/core/prng/distribution - index.js (source / functions) Hit Total Coverage
Test: cov_profile.lcov Lines: 15 22 68.2 %
Date: 2021-12-16 00:47:58 Functions: 2 2 100.0 %
Branches: 6 8 75.0 %

           Branch data     Line data    Source code
       1                 :         46 : // define default distribution method as passthrough
       2            [ + ]:         46 : const defaultDistribution = (i) => i;
       3                 :         46 : 
       4                 :         46 : export default (seeded) => {
       5                 :       1492 :   // define initial distribution to be default distribution
       6                 :       1492 :   let distribution = defaultDistribution;
       7                 :       1492 : 
       8                 :       1492 :   // if passed function, set new distribution method
       9                 :       1492 :   // if passed null, reset distribution method to default passthrough
      10                 :       1492 :   // else call distribution function with passed argument
      11                 :       1492 :   return (newVal) => {
      12            [ + ]:          0 :     if (typeof newVal === "function") {
      13       [ + ][ - ]:          0 :       distribution = newVal;
      14                 :          0 :       return seeded;
      15                 :          0 :     } else if (newVal === null) {
      16    [ +  + ][ - ]:          0 :       distribution = defaultDistribution;
      17                 :          0 :       return seeded;
      18                 :          0 :     } else {
      19            [ + ]:       5950 :       return distribution(newVal);
      20                 :       4914 :     }
      21                 :       1492 :   };
      22                 :         23 : };

Generated by: LCOV version 1.15