Skip to content

Instantly share code, notes, and snippets.

@renesugar
Forked from jussi-kalliokoski/memcpy.js
Created May 11, 2021 02:54
Show Gist options
  • Save renesugar/a3dd23e8200c090e9f68938a3f75de41 to your computer and use it in GitHub Desktop.
Save renesugar/a3dd23e8200c090e9f68938a3f75de41 to your computer and use it in GitHub Desktop.
function memcpy (src, srcOffset, dst, dstOffset, length) {
var i
src = src.subarray || src.slice ? src : src.buffer
dst = dst.subarray || dst.slice ? dst : dst.buffer
src = srcOffset ? src.subarray ?
src.subarray(srcOffset, length && srcOffset + length) :
src.slice(srcOffset, length && srcOffset + length) : src
if (dst.set) {
dst.set(src, dstOffset)
} else {
for (i=0; i<src.length; i++) {
dst[i + dstOffset] = src[i]
}
}
return dst
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment