Skip to content

Commit 30b39c6

Browse files
committed
Export JS
1 parent c29e0b0 commit 30b39c6

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

jscomp/test/bs_array_test.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,23 @@ eq("File \"bs_array_test.ml\", line 335, characters 5-12", Belt_Array.getBy(/* a
15581558
return x > 3;
15591559
})), undefined);
15601560

1561-
Mt.from_pair_suites("File \"bs_array_test.ml\", line 337, characters 23-30", suites[0]);
1561+
eq("File \"bs_array_test.ml\", line 338, characters 5-12", Belt_Array.getIndexBy(/* array */[
1562+
1,
1563+
2,
1564+
3
1565+
], (function (x) {
1566+
return x > 1;
1567+
})), 1);
1568+
1569+
eq("File \"bs_array_test.ml\", line 339, characters 5-12", Belt_Array.getIndexBy(/* array */[
1570+
1,
1571+
2,
1572+
3
1573+
], (function (x) {
1574+
return x > 3;
1575+
})), undefined);
1576+
1577+
Mt.from_pair_suites("File \"bs_array_test.ml\", line 341, characters 23-30", suites[0]);
15621578

15631579
var A = 0;
15641580

lib/js/belt_Array.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,24 @@ function getBy(a, p) {
329329
return getByU(a, Curry.__1(p));
330330
}
331331

332+
function getIndexByU(a, p) {
333+
var l = a.length;
334+
var i = 0;
335+
var r = undefined;
336+
while(r === undefined && i < l) {
337+
var v = a[i];
338+
if (p(v)) {
339+
r = i;
340+
}
341+
i = i + 1 | 0;
342+
};
343+
return r;
344+
}
345+
346+
function getIndexBy(a, p) {
347+
return getIndexByU(a, Curry.__1(p));
348+
}
349+
332350
function keepU(a, f) {
333351
var l = a.length;
334352
var r = new Array(l);
@@ -677,6 +695,8 @@ exports.mapU = mapU;
677695
exports.map = map;
678696
exports.getByU = getByU;
679697
exports.getBy = getBy;
698+
exports.getIndexByU = getIndexByU;
699+
exports.getIndexBy = getIndexBy;
680700
exports.keepU = keepU;
681701
exports.keep = keep;
682702
exports.keepWithIndexU = keepWithIndexU;

0 commit comments

Comments
 (0)