Open ronag opened 3 months ago
@nodejs/performance @joyeecheung
Buffer.copyWithin
might be a clearer name than Buffer.copy
.
@ronag I'm going to work on this feature :)
@ronag i am going to fix this issue
@ayan-de I'm already working on it
@ayan-de I'm already working on it
No problem i will also try it
What is the problem this feature will solve?
Avoid creating a temporary typed buffer:
Buffer.from(arrayBuffer).copy(dst, 0)
What is the feature you are proposing to solve the problem?
Buffer.copy(arrayBuffer, dst, 0)
What alternatives have you considered?
No response
@ronag will this Buffer.copy
a new method or it is just buf.copy(target[, targetStart[, sourceStart[, sourceEnd]]])
function that will also start taking ArrayBuffer in the target parameter?
@ronag will this Buffer.copy a new method or it is just buf.copy(target[, targetStart[, sourceStart[, sourceEnd]]]) function that will also start taking ArrayBuffer in the target parameter?
The idea is to be able to copy both to and from an ArrayBuffer so I would prefer a static method.
Might be a good idea to centralize all copying in that static method so the instance copy method delegates to the static method and it just handles copying of all buffer varieties. 🤔
@Qard @ronag something like : Buffer.copyWithin(arrayBuffer[, dest[, sourceStart]]])
and throw a error if something else than a arrayBuffer
is given ?
Why only ArrayBuffer
? Seems to me like it's better to support all varieties of buffer. 🤔
@Qard so arrayBuffer
buffer
array
?
array
is also be part varieties of buffer ?
something like :
Buffer.copyWithin(array[, dest[, sourceStart]]])
Buffer.copyWithin(buffer[, dest[, sourceStart]]])
Buffer.copyWithin(arrayBuffer[, dest[, sourceStart]]])
I was thinking more the buffer-intended things. So Buffer, ArrayBuffer, and DataView. Maybe typed arrays could be included too.
@Qard @ronag Can I create a PR draft to show you my code during implementation, to give me some advice if I do something wrong?
What is the problem this feature will solve?
Avoid creating a temporary typed buffer:
What is the feature you are proposing to solve the problem?
What alternatives have you considered?
No response