Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8390952
es.typed-array.set.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
es.typed-array.set.js
View Options
'use strict'
;
var
global
=
require
(
'../internals/global'
);
var
call
=
require
(
'../internals/function-call'
);
var
ArrayBufferViewCore
=
require
(
'../internals/array-buffer-view-core'
);
var
lengthOfArrayLike
=
require
(
'../internals/length-of-array-like'
);
var
toOffset
=
require
(
'../internals/to-offset'
);
var
toIndexedObject
=
require
(
'../internals/to-object'
);
var
fails
=
require
(
'../internals/fails'
);
var
RangeError
=
global
.
RangeError
;
var
Int8Array
=
global
.
Int8Array
;
var
Int8ArrayPrototype
=
Int8Array
&&
Int8Array
.
prototype
;
var
$set
=
Int8ArrayPrototype
&&
Int8ArrayPrototype
.
set
;
var
aTypedArray
=
ArrayBufferViewCore
.
aTypedArray
;
var
exportTypedArrayMethod
=
ArrayBufferViewCore
.
exportTypedArrayMethod
;
var
WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS
=
!
fails
(
function
()
{
// eslint-disable-next-line es/no-typed-arrays -- required for testing
var
array
=
new
Uint8ClampedArray
(
2
);
call
(
$set
,
array
,
{
length
:
1
,
0
:
3
},
1
);
return
array
[
1
]
!==
3
;
});
// https://bugs.chromium.org/p/v8/issues/detail?id=11294 and other
var
TO_OBJECT_BUG
=
WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS
&&
ArrayBufferViewCore
.
NATIVE_ARRAY_BUFFER_VIEWS
&&
fails
(
function
()
{
var
array
=
new
Int8Array
(
2
);
array
.
set
(
1
);
array
.
set
(
'2'
,
1
);
return
array
[
0
]
!==
0
||
array
[
1
]
!==
2
;
});
// `%TypedArray%.prototype.set` method
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.set
exportTypedArrayMethod
(
'set'
,
function
set
(
arrayLike
/* , offset */
)
{
aTypedArray
(
this
);
var
offset
=
toOffset
(
arguments
.
length
>
1
?
arguments
[
1
]
:
undefined
,
1
);
var
src
=
toIndexedObject
(
arrayLike
);
if
(
WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS
)
return
call
(
$set
,
this
,
src
,
offset
);
var
length
=
this
.
length
;
var
len
=
lengthOfArrayLike
(
src
);
var
index
=
0
;
if
(
len
+
offset
>
length
)
throw
RangeError
(
'Wrong length'
);
while
(
index
<
len
)
this
[
offset
+
index
]
=
src
[
index
++
];
},
!
WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS
||
TO_OBJECT_BUG
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jun 4 2025, 6:37 PM (14 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3340578
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment