UNPKG

992 BJavaScriptView Raw
1'use strict';
2var global = require('../internals/global');
3var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
4var fails = require('../internals/fails');
5
6var Int8Array = global.Int8Array;
7var aTypedArray = ArrayBufferViewCore.aTypedArray;
8var $toLocaleString = [].toLocaleString;
9var $slice = [].slice;
10
11// iOS Safari 6.x fails here
12var TO_LOCALE_STRING_BUG = !!Int8Array && fails(function () {
13 $toLocaleString.call(new Int8Array(1));
14});
15
16var FORCED = fails(function () {
17 return [1, 2].toLocaleString() != new Int8Array([1, 2]).toLocaleString();
18}) || !fails(function () {
19 Int8Array.prototype.toLocaleString.call([1, 2]);
20});
21
22// `%TypedArray%.prototype.toLocaleString` method
23// https://tc39.github.io/ecma262/#sec-%typedarray%.prototype.tolocalestring
24ArrayBufferViewCore.exportProto('toLocaleString', function toLocaleString() {
25 return $toLocaleString.apply(TO_LOCALE_STRING_BUG ? $slice.call(aTypedArray(this)) : aTypedArray(this), arguments);
26}, FORCED);