# All files / src Relude_Map.bs.js

39.36% Statements 37/94
100% Branches 0/0
2.38% Functions 1/42
39.36% Lines 37/94

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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186

    26x
    26x
    26x
    26x
    26x
    26x
    26x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    42x

    26x

     'use strict';

    var Curry = require("bs-platform/lib/js/curry.js");
    var Belt_Id = require("bs-platform/lib/js/belt_Id.js");
    var Belt_Map = require("bs-platform/lib/js/belt_Map.js");
    var Belt_List = require("bs-platform/lib/js/belt_List.js");
    var Belt_Array = require("bs-platform/lib/js/belt_Array.js");
    var Relude_Function = require("./Relude_Function.bs.js");
    var Relude_Ordering = require("./Relude_Ordering.bs.js");

    function WithOrd(M) {
      var cmp = function (a, b) {
        return Relude_Ordering.toInt(Curry._2(M.compare, a, b));
      };
      var Comparable = Belt_Id.MakeComparable({
            cmp: cmp
          });
      var make = function (param) {
        return Belt_Map.make(Comparable);
      };
      var contains = function (key, __x) {
        return Belt_Map.has(__x, key);
      };
      var compareInt = function (comparator, a, b) {
        return Belt_Map.cmp(a, b, comparator);
      };
      var compare = function (comparator, a, b) {
        return Relude_Ordering.fromInt(Belt_Map.cmp(a, b, comparator));
      };
      var eqBy = function (comparator, a, b) {
        return Belt_Map.eq(a, b, comparator);
      };
      var find = function (by, __x) {
        return Belt_Map.findFirstBy(__x, by);
      };
      var forEach = function (fn, __x) {
        return Belt_Map.forEach(__x, fn);
      };
      var foldLeft = function (fn, acc, __x) {
        return Belt_Map.reduce(__x, acc, fn);
      };
      var all = function (cond, __x) {
        return Belt_Map.every(__x, cond);
      };
      var any = function (cond, __x) {
        return Belt_Map.some(__x, cond);
      };
      var fromArray = function (__x) {
        return Belt_Map.fromArray(__x, Comparable);
      };
      var fromList = function (lst) {
        return Belt_Map.fromArray(Belt_List.toArray(lst), Comparable);
      };
      var get = function (key, __x) {
        return Belt_Map.get(__x, key);
      };
      var getOrElse = function (key, $$default, __x) {
        return Belt_Map.getWithDefault(__x, key, $$default);
      };
      var remove = function (key, __x) {
        return Belt_Map.remove(__x, key);
      };
      var removeMany = function (keys, __x) {
        return Belt_Map.removeMany(__x, keys);
      };
      var set = function (key, value, __x) {
        return Belt_Map.set(__x, key, value);
      };
      var update = function (key, updateFn, __x) {
        return Belt_Map.update(__x, key, updateFn);
      };
      var merge = function (mergeFn, a, b) {
        return Belt_Map.merge(a, b, mergeFn);
      };
      var mergeMany = function (arr, __x) {
        return Belt_Map.mergeMany(__x, arr);
      };
      var filter = function (fn, __x) {
        return Belt_Map.keep(__x, fn);
      };
      var partition = function (fn, __x) {
        return Belt_Map.partition(__x, fn);
      };
      var map = function (fn, __x) {
        return Belt_Map.map(__x, fn);
      };
      var mapWithKey = function (fn, __x) {
        return Belt_Map.mapWithKey(__x, fn);
      };
      var groupListBy = function (groupBy) {
        var addItemToGroup = function (x) {
          var partial_arg = Curry._1(groupBy, x);
          var partial_arg$1 = function (param) {
            return Belt_Map.getWithDefault(param, partial_arg, /* [] */0);
          };
          var partial_arg$2 = Relude_Function.Infix.$great$great;
          return (function (param) {
              return partial_arg$2(partial_arg$1, (function (xs) {
                            return /* :: */[
                                    x,
                                    xs
                                  ];
                          }), param);
            });
        };
        var addItemToMap = function (dict, x) {
          var value = addItemToGroup(x)(dict);
          var key = Curry._1(groupBy, x);
          return Belt_Map.set(dict, key, value);
        };
        var partial_arg = Relude_Function.Infix.$great$great;
        return (function (param) {
            return partial_arg((function (__x) {
                          return Belt_List.reduce(__x, Belt_Map.make(Comparable), addItemToMap);
                        }), (function (param) {
                          return Belt_Map.map(param, Belt_List.reverse);
                        }), param);
          });
      };
      var groupArrayBy = function (groupBy) {
        var addItemToGroup = function (x) {
          var partial_arg = /* array */[];
          var partial_arg$1 = Curry._1(groupBy, x);
          var partial_arg$2 = function (param) {
            return Belt_Map.getWithDefault(param, partial_arg$1, partial_arg);
          };
          var partial_arg$3 = Relude_Function.Infix.$great$great;
          return (function (param) {
              return partial_arg$3(partial_arg$2, (function (__x) {
                            return Belt_Array.concat(__x, /* array */[x]);
                          }), param);
            });
        };
        var addItemToMap = function (dict, x) {
          var value = addItemToGroup(x)(dict);
          var key = Curry._1(groupBy, x);
          return Belt_Map.set(dict, key, value);
        };
        return (function (__x) {
            return Belt_Array.reduce(__x, Belt_Map.make(Comparable), addItemToMap);
          });
      };
      return {
              Comparable: { },
              make: make,
              isEmpty: Belt_Map.isEmpty,
              contains: contains,
              compareInt: compareInt,
              compare: compare,
              eqBy: eqBy,
              find: find,
              forEach: forEach,
              foldLeft: foldLeft,
              all: all,
              any: any,
              length: Belt_Map.size,
              toArray: Belt_Map.toArray,
              fromArray: fromArray,
              toList: Belt_Map.toList,
              fromList: fromList,
              keys: Belt_Map.keysToArray,
              values: Belt_Map.valuesToArray,
              minKey: Belt_Map.minKey,
              maxKey: Belt_Map.maxKey,
              min: Belt_Map.minimum,
              max: Belt_Map.maximum,
              get: get,
              getOrElse: getOrElse,
              remove: remove,
              removeMany: removeMany,
              set: set,
              update: update,
              merge: merge,
              mergeMany: mergeMany,
              filter: filter,
              partition: partition,
              map: map,
              mapWithKey: mapWithKey,
              groupListBy: groupListBy,
              groupArrayBy: groupArrayBy
            };
    }

    exports.WithOrd = WithOrd;
    /* Relude_Function Not a pure module */