Skip to content

Instantly share code, notes, and snippets.

@petamoriken
Last active November 28, 2015 02:26
Show Gist options
  • Save petamoriken/11678900319cb0fb4f59 to your computer and use it in GitHub Desktop.
Save petamoriken/11678900319cb0fb4f59 to your computer and use it in GitHub Desktop.
TypedArray の対応する ArrayBuffer の切り出し機能が欲しい。
for(let TypedArray of [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array]) {
Object.defineProperty(TypedArray.prototype, "slicedBuffer", {
get: function() {
let byteOffset = this.byteOffset, byteLength = this.byteLength;
return this.buffer.slice(byteOffset, byteOffset + byteLength);
}
});
}
@petamoriken
Copy link
Author

(/ω\)

@petamoriken
Copy link
Author

spliced というよりかは sliced といった方が良い気がしたので変更した。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment