Index: src/js/typedarray.js |
diff --git a/src/js/typedarray.js b/src/js/typedarray.js |
index 6e8f3c76712845ae73812d87811e5a25e4e05e92..3a5cb847556176c9ea9d6672b8dfd3a0e0fde569 100644 |
--- a/src/js/typedarray.js |
+++ b/src/js/typedarray.js |
@@ -20,6 +20,7 @@ var GlobalArray = global.Array; |
var GlobalArrayBuffer = global.ArrayBuffer; |
var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype; |
var GlobalObject = global.Object; |
+var InnerArrayCopyWithin; |
var InnerArrayEvery; |
var InnerArrayFill; |
var InnerArrayFilter; |
@@ -67,6 +68,7 @@ utils.Import(function(from) { |
ArrayValues = from.ArrayValues; |
GetIterator = from.GetIterator; |
GetMethod = from.GetMethod; |
+ InnerArrayCopyWithin = from.InnerArrayCopyWithin; |
InnerArrayEvery = from.InnerArrayEvery; |
InnerArrayFill = from.InnerArrayFill; |
InnerArrayFilter = from.InnerArrayFilter; |
@@ -436,6 +438,17 @@ function TypedArrayGetToStringTag() { |
} |
+function TypedArrayCopyWithin(target, start, end) { |
+ if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
+ |
+ var length = %_TypedArrayGetLength(this); |
+ |
+ // TODO(littledan): Replace with a memcpy for better performance |
+ return InnerArrayCopyWithin(target, start, end, this, length); |
+} |
+%FunctionSetLength(TypedArrayCopyWithin, 2); |
+ |
+ |
// ES6 draft 05-05-15, section 22.2.3.7 |
function TypedArrayEvery(f, receiver) { |
if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); |
@@ -845,6 +858,7 @@ utils.InstallGetter(GlobalTypedArray.prototype, toStringTagSymbol, |
utils.InstallFunctions(GlobalTypedArray.prototype, DONT_ENUM, [ |
"subarray", TypedArraySubArray, |
"set", TypedArraySet, |
+ "copyWithin", TypedArrayCopyWithin, |
"every", TypedArrayEvery, |
"fill", TypedArrayFill, |
"filter", TypedArrayFilter, |