-
-
Save TooTallNate/00241b86d7f6a874b933 to your computer and use it in GitHub Desktop.
This file contains 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
// sometimes you get a variable length array that is terminated by a NULL byte. | |
var buf = new Buffer(int.size * 3) | |
int.set(buf, int.size * 0, 5) | |
int.set(buf, int.size * 1, 8) | |
int.set(buf, int.size * 2, 0) // <- terminate with 0s | |
// you can create an array instance with the length automatically determined | |
var array = IntArray.untilZero(buf) | |
console.log(array.length) | |
// 2 | |
console.log(array) | |
// [ 5, 8 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment