Skip to content

Instantly share code, notes, and snippets.

@rubeniskov
Created August 2, 2016 11:24
Show Gist options
  • Save rubeniskov/55114dd0005f86f54a3f0a37f7b0001d to your computer and use it in GitHub Desktop.
Save rubeniskov/55114dd0005f86f54a3f0a37f7b0001d to your computer and use it in GitHub Desktop.
(function indexOf(buffer, pattern) {
for (var i = 0; i < buffer.length - pattern.length; i++) {
if (buffer.slice(i, i + pattern.length).map(function(v, i) {
return pattern[i] === v;
}).filter(Boolean).length === pattern.length)
return i;
}
return -1
})(temp1.data, [222, 2, 0, 76, 97]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment