node icon indicating copy to clipboard operation
node copied to clipboard

[Implement] Buffer.concat

Open jtenner opened this issue 4 years ago • 3 comments

~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?)

jtenner avatar Jul 18 '19 20:07 jtenner

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.

jtenner avatar Jul 19 '19 12:07 jtenner

Do you think this can be merged? It looks good to me.

jtenner avatar Jul 31 '19 20:07 jtenner

Six months in the making! Time to revive this pull request.

jtenner avatar Mar 12 '20 18:03 jtenner