LCOV - code coverage report
Current view: top level - src/name - name.js (source / functions) Hit Total Coverage
Test: cov_profile.lcov Lines: 53 53 100.0 %
Date: 2021-12-16 00:47:58 Functions: 7 7 100.0 %
Branches: 12 12 100.0 %

           Branch data     Line data    Source code
       1                 :         10 : import namedatain from "./namedata.js";
       2            [ + ]:         10 : export const namedata = namedatain;
       3                 :         10 : 
       4                 :         10 : const getGender = (gender) =>
       5                 :         10 :   gender && (gender[0].toLowerCase() === "f" ? "female" : "male");
       6         [ +  + ]:         10 : 
       7                 :         10 : export const gender = (seeded) => {
       8                 :         82 :   return seeded.random() < 0.5 ? "male" : "female";
       9         [ +  + ]:         10 : };
      10                 :         10 : 
      11                 :         10 : export const title = (seeded, { gender } = {}) => {
      12                 :         74 :   return seeded.oneOf(namedata[getGender(gender || seeded.gender())].title, {
      13            [ + ]:         74 :     weights: [5, 3],
      14                 :         74 :   });
      15                 :         10 : };
      16                 :         10 : 
      17                 :         10 : export const firstname = (seeded, { gender } = {}) => {
      18                 :         24 :   return seeded.oneOf(namedata[getGender(gender || seeded.gender())].firstname);
      19            [ + ]:         10 : };
      20                 :         10 : 
      21                 :         10 : // TODO: remove firstnames method from name extension
      22                 :         10 : export const firstnames = (seeded, { gender } = {}) => {
      23                 :         62 :   return seeded
      24                 :         62 :     .choose(
      25                 :         62 :       seeded
      26                 :         62 :         .clone()
      27                 :         62 :         .distribution((x) => x * x * x)
      28            [ + ]:         62 :         .number({ min: 1, max: 3 }),
      29                 :         62 :       namedata[getGender(gender || seeded.gender())].firstname,
      30            [ + ]:         62 :     )
      31                 :         62 :     .join(" ");
      32                 :         10 : };
      33                 :         10 : 
      34                 :         10 : export const surname = (seeded) => {
      35                 :         64 :   return seeded
      36                 :         64 :     .choose(
      37                 :         64 :       seeded
      38                 :         64 :         .clone()
      39                 :         64 :         .distribution((x) => x * x * x)
      40            [ + ]:         64 :         .number({ min: 1, max: 2 }),
      41                 :         64 :       namedata.surname,
      42                 :         64 :     )
      43                 :         64 :     .join(seeded.bool() ? " " : "-");
      44         [ +  + ]:         10 : };
      45                 :         10 : 
      46                 :         10 : export const fullname = (seeded, { gender } = {}) => {
      47                 :         60 :   const myGender = getGender(gender || seeded.gender());
      48                 :         60 :   return `${seeded.title({ gender: myGender })} ${
      49                 :         60 :     seeded.firstnames({
      50                 :         60 :       gender: myGender,
      51                 :         60 :     })
      52                 :         60 :   } ${seeded.surname()}`;
      53                 :          5 : };

Generated by: LCOV version 1.15