You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.7 KiB
38 lines
1.7 KiB
'use strict';
|
|
var global = require('../internals/global');
|
|
var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
|
|
var ArrayIterators = require('../modules/es.array.iterator');
|
|
var wellKnownSymbol = require('../internals/well-known-symbol');
|
|
|
|
var ITERATOR = wellKnownSymbol('iterator');
|
|
var Uint8Array = global.Uint8Array;
|
|
var arrayValues = ArrayIterators.values;
|
|
var arrayKeys = ArrayIterators.keys;
|
|
var arrayEntries = ArrayIterators.entries;
|
|
var aTypedArray = ArrayBufferViewCore.aTypedArray;
|
|
var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
|
|
var nativeTypedArrayIterator = Uint8Array && Uint8Array.prototype[ITERATOR];
|
|
|
|
var CORRECT_ITER_NAME = !!nativeTypedArrayIterator
|
|
&& (nativeTypedArrayIterator.name == 'values' || nativeTypedArrayIterator.name == undefined);
|
|
|
|
var typedArrayValues = function values() {
|
|
return arrayValues.call(aTypedArray(this));
|
|
};
|
|
|
|
// `%TypedArray%.prototype.entries` method
|
|
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.entries
|
|
exportTypedArrayMethod('entries', function entries() {
|
|
return arrayEntries.call(aTypedArray(this));
|
|
});
|
|
// `%TypedArray%.prototype.keys` method
|
|
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.keys
|
|
exportTypedArrayMethod('keys', function keys() {
|
|
return arrayKeys.call(aTypedArray(this));
|
|
});
|
|
// `%TypedArray%.prototype.values` method
|
|
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.values
|
|
exportTypedArrayMethod('values', typedArrayValues, !CORRECT_ITER_NAME);
|
|
// `%TypedArray%.prototype[@@iterator]` method
|
|
// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype-@@iterator
|
|
exportTypedArrayMethod(ITERATOR, typedArrayValues, !CORRECT_ITER_NAME);
|
|
|