diff --git a/lib/runtime.js b/lib/runtime.js index 102f054..276d9e4 100644 --- a/lib/runtime.js +++ b/lib/runtime.js @@ -68,3 +68,14 @@ function bigstringaf_memcmp_string(ba, ba_off, str, str_off, len) { } return 0; } + +//Provides: bigstringaf_memchr +//Requires: caml_ba_get_1 +function bigstringaf_memchr(ba, ba_off, chr, len) { + for (var i = 0; i < len; i++) { + if (caml_ba_get_1(ba, ba_off + i) == chr) { + return (ba_off + i); + } + } + return -1; +}