Skip to content

Instantly share code, notes, and snippets.

@jussi-kalliokoski
Created July 18, 2012 21:16
Show Gist options
  • Save jussi-kalliokoski/3138956 to your computer and use it in GitHub Desktop.
Save jussi-kalliokoski/3138956 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