# All files / src Relude_String.bs.js

100% Statements 210/210
100% Branches 14/14
100% Functions 49/49
100% Lines 210/210

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
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416

    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x

    15x

    5x

    2x

    2x

    2x
    2x
    1x

    1x

    4x

    9x
    9x

    2x
    2x

    3x
    3x
    3x
    1x

    2x

    27x

    15x

    15x

    15x

    15x

    1x
    2x

    1x
    3x

    1x

    1x
    1x
    1x
    6x
    6x
    6x
    6x
    1x

    5x
    5x
    5x

    2x
    2x
    2x
    9x
    9x
    9x
    9x
    2x

    7x
    7x
    7x

    1x

    1x

    1x

    23x

    2x

    21x
    21x
    20x

    1x

    4x
    14x

    1x
    5x

    1x

    1x

    27x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    1x

    1x

    6x

    2x
    2x
    1x

    1x

    2x
    2x
    1x

    1x

    1x

    1x

    1x

    1x

    9x

    1x

    1x

    3x

    1x

    1x

    1x

    1x

    10x
    10x

    6x

    2x

    5x
    5x

    3x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x

    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x
    15x

     'use strict';

    var Curry = require("bs-platform/lib/js/curry.js");
    var Js_exn = require("bs-platform/lib/js/js_exn.js");
    var $$String = require("bs-platform/lib/js/string.js");
    var Relude_Map = require("./Relude_Map.bs.js");
    var Relude_Set = require("./Relude_Set.bs.js");
    var Caml_format = require("bs-platform/lib/js/caml_format.js");
    var Caml_option = require("bs-platform/lib/js/caml_option.js");
    var Relude_List_Base = require("./list/Relude_List_Base.bs.js");
    var Relude_Array_Base = require("./array/Relude_Array_Base.bs.js");
    var String$BsAbstract = require("bs-abstract/lib/js/src/implementations/String.bs.js");
    var Relude_Extensions_Eq = require("./extensions/Relude_Extensions_Eq.bs.js");
    var Relude_Extensions_Ord = require("./extensions/Relude_Extensions_Ord.bs.js");
    var Relude_List_Instances = require("./list/Relude_List_Instances.bs.js");
    var Relude_Array_Instances = require("./array/Relude_Array_Instances.bs.js");
    var Relude_Extensions_Monoid = require("./extensions/Relude_Extensions_Monoid.bs.js");
    var Relude_Extensions_Semigroup = require("./extensions/Relude_Extensions_Semigroup.bs.js");

    var empty = "";

    function length(prim) {
      return prim.length;
    }

    function isEmpty(s) {
      return s.length === 0;
    }

    function isNonEmpty(s) {
      return s.length !== 0;
    }

    function toNonEmpty(s) {
      var match = s.length === 0;
      if (match) {
        return undefined;
      } else {
        return s;
      }
    }

    function trim(prim) {
      return prim.trim();
    }

    function isWhitespace(s) {
      var s$1 = s.trim();
      return s$1.length === 0;
    }

    function isNonWhitespace(s) {
      var s$1 = s.trim();
      return s$1.length !== 0;
    }

    function toNonWhitespace(s) {
      var s$1 = s.trim();
      var match = s$1.length === 0;
      if (match) {
        return undefined;
      } else {
        return s;
      }
    }

    function concat(a, b) {
      return a + b;
    }

    var Semigroup = /* module */[/* append */concat];

    Relude_Extensions_Semigroup.SemigroupExtensions(Semigroup);

    var Monoid = /* module */[
      /* append */concat,
      /* empty */empty
    ];

    var include = Relude_Extensions_Monoid.MonoidExtensions(Monoid);

    function concatArray(array) {
      return Relude_Array_Instances.foldLeft((function (acc, str) {
                      return acc + str;
                    }), "")(array);
    }

    function concatList(list) {
      return Relude_List_Instances.foldLeft((function (acc, str) {
                      return acc + str;
                    }), "")(list);
    }

    function make(prim) {
      return String(prim);
    }

    function makeWithIndex(i, f) {
      var _acc = "";
      var _idx = 0;
      while(true) {
        var idx = _idx;
        var acc = _acc;
        var match = idx >= i;
        if (match) {
          return acc;
        } else {
          _idx = idx + 1 | 0;
          _acc = acc + Curry._1(f, idx);
          continue ;
        }
      };
    }

    function repeat(i, str) {
      var _acc = "";
      var _i = i;
      while(true) {
        var i$1 = _i;
        var acc = _acc;
        var match = i$1 <= 0;
        if (match) {
          return acc;
        } else {
          _i = i$1 - 1 | 0;
          _acc = acc + str;
          continue ;
        }
      };
    }

    function toUpperCase(prim) {
      return prim.toUpperCase();
    }

    function toLowerCase(prim) {
      return prim.toLowerCase();
    }

    function fromCharCode(prim) {
      return String.fromCharCode(prim);
    }

    function charAt(i, str) {
      return Caml_option.nullable_to_opt(str[i]);
    }

    function charAtNullable(i, str) {
      return str[i];
    }

    function charAtOrThrow(i, str) {
      var match = charAt(i, str);
      if (match !== undefined) {
        return match;
      } else {
        return Js_exn.raiseRangeError("Failed to get string at index " + (String(i) + (" for string: " + str)));
      }
    }

    function toList(str) {
      return Relude_List_Base.makeWithIndex(str.length, (function (i) {
                    return charAtOrThrow(i, str);
                  }));
    }

    function toArray(str) {
      return Relude_Array_Base.makeWithIndex(str.length, (function (i) {
                    return charAtOrThrow(i, str);
                  }));
    }

    function foldLeft(f, init, str) {
      return Relude_List_Instances.foldLeft(f, init)(toList(str));
    }

    function foldRight(f, init, str) {
      return Relude_List_Instances.foldRight(f, init)(toList(str));
    }

    function eq(a, b) {
      return a === b;
    }

    var Eq = /* module */[/* eq */eq];

    var include$1 = Relude_Extensions_Eq.EqExtensions(Eq);

    var compare = String$BsAbstract.Ord[/* compare */1];

    var Ord = /* module */[
      /* eq */eq,
      /* compare */compare
    ];

    var include$2 = Relude_Extensions_Ord.OrdExtensions(Ord);

    var $$Map = Relude_Map.WithOrd(Ord);

    var $$Set = Relude_Set.WithOrd(Ord);

    function endsWith(search, input) {
      return input.endsWith(search);
    }

    function startsWith(search, input) {
      return input.startsWith(search);
    }

    function contains(search, input) {
      return input.includes(search);
    }

    function indexOf(search, input) {
      var index = input.indexOf(search);
      if (index < 0) {
        return undefined;
      } else {
        return index;
      }
    }

    function lastIndexOf(search, input) {
      var index = input.lastIndexOf(search);
      if (index < 0) {
        return undefined;
      } else {
        return index;
      }
    }

    function slice(fromIndex, toIndex, input) {
      return input.slice(fromIndex, toIndex);
    }

    function sliceToEnd(fromIndex, str) {
      return str.slice(fromIndex);
    }

    function splitArray(delimiter, input) {
      return input.split(delimiter);
    }

    function splitList(delimiter, input) {
      return Relude_List_Instances.fromArray(input.split(delimiter));
    }

    function splitAt(index, input) {
      return /* tuple */[
              input.slice(0, index),
              input.slice(index)
            ];
    }

    function mapChars(f, str) {
      return Curry._3(Relude_List_Instances.foldMap, Monoid, f, toList(str));
    }

    function replaceFirst(search, replaceWith, input) {
      return input.replace(search, replaceWith);
    }

    function replaceEach(search, replaceWith, input) {
      return $$String.concat(replaceWith, Relude_List_Instances.fromArray(input.split(search)));
    }

    function replaceRegex(search, replaceWith, input) {
      return input.replace(search, replaceWith);
    }

    function removeFirst(search, input) {
      return input.replace(search, "");
    }

    function removeEach(search, input) {
      return replaceEach(search, "", input);
    }

    function fromInt(prim) {
      return String(prim);
    }

    function toInt(v) {
      try {
        return Caml_format.caml_int_of_string(v);
      }
      catch (exn){
        return undefined;
      }
    }

    function fromFloat(prim) {
      return prim.toString();
    }

    function toFloat(v) {
      try {
        return Caml_format.caml_float_of_string(v);
      }
      catch (exn){
        return undefined;
      }
    }

    var isNotEmpty = isNonEmpty;

    var BsMonoidExtensions = include[0];

    var guard = include[1];

    var power = include[2];

    var notEq = include$1[0];

    var compareAsInt = include$2[0];

    var min = include$2[1];

    var max = include$2[2];

    var lessThan = include$2[3];

    var lessThanOrEq = include$2[4];

    var greaterThan = include$2[5];

    var greaterThanOrEq = include$2[6];

    var lt = include$2[7];

    var lte = include$2[8];

    var gt = include$2[9];

    var gte = include$2[10];

    var clamp = include$2[11];

    var between = include$2[12];

    var OrdRingExtensions = include$2[13];

    exports.empty = empty;
    exports.length = length;
    exports.isEmpty = isEmpty;
    exports.isNonEmpty = isNonEmpty;
    exports.isNotEmpty = isNotEmpty;
    exports.toNonEmpty = toNonEmpty;
    exports.trim = trim;
    exports.isWhitespace = isWhitespace;
    exports.isNonWhitespace = isNonWhitespace;
    exports.toNonWhitespace = toNonWhitespace;
    exports.concat = concat;
    exports.Semigroup = Semigroup;
    exports.Monoid = Monoid;
    exports.BsMonoidExtensions = BsMonoidExtensions;
    exports.guard = guard;
    exports.power = power;
    exports.concatArray = concatArray;
    exports.concatList = concatList;
    exports.make = make;
    exports.makeWithIndex = makeWithIndex;
    exports.repeat = repeat;
    exports.toUpperCase = toUpperCase;
    exports.toLowerCase = toLowerCase;
    exports.fromCharCode = fromCharCode;
    exports.charAt = charAt;
    exports.charAtNullable = charAtNullable;
    exports.charAtOrThrow = charAtOrThrow;
    exports.toList = toList;
    exports.toArray = toArray;
    exports.foldLeft = foldLeft;
    exports.foldRight = foldRight;
    exports.eq = eq;
    exports.Eq = Eq;
    exports.notEq = notEq;
    exports.compare = compare;
    exports.Ord = Ord;
    exports.compareAsInt = compareAsInt;
    exports.min = min;
    exports.max = max;
    exports.lessThan = lessThan;
    exports.lessThanOrEq = lessThanOrEq;
    exports.greaterThan = greaterThan;
    exports.greaterThanOrEq = greaterThanOrEq;
    exports.lt = lt;
    exports.lte = lte;
    exports.gt = gt;
    exports.gte = gte;
    exports.clamp = clamp;
    exports.between = between;
    exports.OrdRingExtensions = OrdRingExtensions;
    exports.$$Map = $$Map;
    exports.$$Set = $$Set;
    exports.endsWith = endsWith;
    exports.startsWith = startsWith;
    exports.contains = contains;
    exports.indexOf = indexOf;
    exports.lastIndexOf = lastIndexOf;
    exports.slice = slice;
    exports.sliceToEnd = sliceToEnd;
    exports.splitArray = splitArray;
    exports.splitList = splitList;
    exports.splitAt = splitAt;
    exports.mapChars = mapChars;
    exports.replaceFirst = replaceFirst;
    exports.replaceEach = replaceEach;
    exports.replaceRegex = replaceRegex;
    exports.removeFirst = removeFirst;
    exports.removeEach = removeEach;
    exports.fromInt = fromInt;
    exports.toInt = toInt;
    exports.fromFloat = fromFloat;
    exports.toFloat = toFloat;
    /*  Not a pure module */