node
node copied to clipboard
[Implement] Buffer.concat
~Current problems:~
- ~No good logging for that extend
ArrayBufferView
(opened issue with as-pect https://github.com/jtenner/as-pect/issues/132 )~ - ~No good way of comparing things that extend
ArrayBufferView
(opened issue with as-pect https://github.com/jtenner/as-pect/issues/133 )~
expect<Buffer>(actual).toStrictEqual(expected); // should compare lengths and values
- ~No good way to create a buffer from scratch without a naive
Buffer.from<T>()
function~- ~Could create a helper function, but that's a todo~
This pull request is not blocked by anything. Current questions:
- Should we set the length parameter to
i32.MAX_VALUE
? - Any suggestions for optimizations?
- Should we do a
null
check on the array? (in case of uninitialized field problems?)
I think I'm going to implement a test function for utility purposes.
function bufferFrom(values: i32[]): Buffer {
let length = values.lengrh;
let buffer = Buffer.allocUnsafe(length);
for (let i = 0; i < length; i++) buffer[i] = u8(unchecked(values[i]));
return buffer;
}
This should be relatively safe for testing.
Do you think this can be merged? It looks good to me.
Six months in the making! Time to revive this pull request.