Created
August 2, 2016 11:24
-
-
Save rubeniskov/55114dd0005f86f54a3f0a37f7b0001d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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