# All files / src/extensions Relude_Extensions_MonoidAny.bs.js

84.21% Statements 16/19
75% Branches 6/8
100% Functions 4/4
84.21% Lines 16/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37

    23x

    46x
    2x
    1x

    1x

    46x
    1x
    2x

    2x
    1x
    1x

    1x
    1x

    1x

    46x

    23x

     'use strict';

    var Curry = require("bs-platform/lib/js/curry.js");

    function MonoidAnyExtensions(M) {
      var guard = function (condition, ma) {
        if (condition) {
          return ma;
        } else {
          return M.empty;
        }
      };
      var power = function (ma, times) {
        var go = function (count) {
          Iif (count <= 0) {
            return M.empty;
          } else if (count === 1) {
            return ma;
          } else Iif (count % 2 === 0) {
            var ma$prime = go(count / 2 | 0);
            return Curry._2(M.append, ma$prime, ma$prime);
          } else {
            var ma$prime$1 = go(count / 2 | 0);
            return Curry._2(M.append, Curry._2(M.append, ma$prime$1, ma$prime$1), ma);
          }
        };
        return go(times);
      };
      return {
              guard: guard,
              power: power
            };
    }

    exports.MonoidAnyExtensions = MonoidAnyExtensions;
    /* No side effect */