var buffer_1 = new ArrayBuffer(50000);
var buffer_2 = new ArrayBuffer(1000000);
var needle = new Uint8Array(buffer_1);
var haystack = new Uint8Array(buffer_2);
needle.fill(111)
haystack.fill(222)[111, 111, 111 ... 111, 111]vs [222, 222, 222 ... 222, 222]needle are NOT present in the haystack, then the result below will be Absent.
Result ...
var buffer_1 = new ArrayBuffer(500);
var buffer_2 = new ArrayBuffer(1000000);
var needle = new Uint8Array(buffer_1);
var haystack = new Uint8Array(buffer_2);
needle.fill(111)
haystack.fill(111)[111, 111, 111 ... 111, 111] vs [111, 111, 111 ... 111, 111]needle are present in the haystack, then the result below will be Present.
Result!
This work is explained in more detail in an online article called An easy way to boost your client-side Javascript using WebAssembly(Wasm). An additional follow-up article called How to detect a sequence of bytes, in a byte array, using client-side Javascript also provides additional details about this work.