source: trip-planner-front/node_modules/core-js/internals/array-buffer-view-core.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 6.4 KB
Line 
1'use strict';
2var NATIVE_ARRAY_BUFFER = require('../internals/array-buffer-native');
3var DESCRIPTORS = require('../internals/descriptors');
4var global = require('../internals/global');
5var isObject = require('../internals/is-object');
6var has = require('../internals/has');
7var classof = require('../internals/classof');
8var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
9var redefine = require('../internals/redefine');
10var defineProperty = require('../internals/object-define-property').f;
11var getPrototypeOf = require('../internals/object-get-prototype-of');
12var setPrototypeOf = require('../internals/object-set-prototype-of');
13var wellKnownSymbol = require('../internals/well-known-symbol');
14var uid = require('../internals/uid');
15
16var Int8Array = global.Int8Array;
17var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
18var Uint8ClampedArray = global.Uint8ClampedArray;
19var Uint8ClampedArrayPrototype = Uint8ClampedArray && Uint8ClampedArray.prototype;
20var TypedArray = Int8Array && getPrototypeOf(Int8Array);
21var TypedArrayPrototype = Int8ArrayPrototype && getPrototypeOf(Int8ArrayPrototype);
22var ObjectPrototype = Object.prototype;
23var isPrototypeOf = ObjectPrototype.isPrototypeOf;
24
25var TO_STRING_TAG = wellKnownSymbol('toStringTag');
26var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');
27var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR');
28// Fixing native typed arrays in Opera Presto crashes the browser, see #595
29var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
30var TYPED_ARRAY_TAG_REQIRED = false;
31var NAME, Constructor, Prototype;
32
33var TypedArrayConstructorsList = {
34 Int8Array: 1,
35 Uint8Array: 1,
36 Uint8ClampedArray: 1,
37 Int16Array: 2,
38 Uint16Array: 2,
39 Int32Array: 4,
40 Uint32Array: 4,
41 Float32Array: 4,
42 Float64Array: 8
43};
44
45var BigIntArrayConstructorsList = {
46 BigInt64Array: 8,
47 BigUint64Array: 8
48};
49
50var isView = function isView(it) {
51 if (!isObject(it)) return false;
52 var klass = classof(it);
53 return klass === 'DataView'
54 || has(TypedArrayConstructorsList, klass)
55 || has(BigIntArrayConstructorsList, klass);
56};
57
58var isTypedArray = function (it) {
59 if (!isObject(it)) return false;
60 var klass = classof(it);
61 return has(TypedArrayConstructorsList, klass)
62 || has(BigIntArrayConstructorsList, klass);
63};
64
65var aTypedArray = function (it) {
66 if (isTypedArray(it)) return it;
67 throw TypeError('Target is not a typed array');
68};
69
70var aTypedArrayConstructor = function (C) {
71 if (setPrototypeOf && !isPrototypeOf.call(TypedArray, C)) {
72 throw TypeError('Target is not a typed array constructor');
73 } return C;
74};
75
76var exportTypedArrayMethod = function (KEY, property, forced) {
77 if (!DESCRIPTORS) return;
78 if (forced) for (var ARRAY in TypedArrayConstructorsList) {
79 var TypedArrayConstructor = global[ARRAY];
80 if (TypedArrayConstructor && has(TypedArrayConstructor.prototype, KEY)) try {
81 delete TypedArrayConstructor.prototype[KEY];
82 } catch (error) { /* empty */ }
83 }
84 if (!TypedArrayPrototype[KEY] || forced) {
85 redefine(TypedArrayPrototype, KEY, forced ? property
86 : NATIVE_ARRAY_BUFFER_VIEWS && Int8ArrayPrototype[KEY] || property);
87 }
88};
89
90var exportTypedArrayStaticMethod = function (KEY, property, forced) {
91 var ARRAY, TypedArrayConstructor;
92 if (!DESCRIPTORS) return;
93 if (setPrototypeOf) {
94 if (forced) for (ARRAY in TypedArrayConstructorsList) {
95 TypedArrayConstructor = global[ARRAY];
96 if (TypedArrayConstructor && has(TypedArrayConstructor, KEY)) try {
97 delete TypedArrayConstructor[KEY];
98 } catch (error) { /* empty */ }
99 }
100 if (!TypedArray[KEY] || forced) {
101 // V8 ~ Chrome 49-50 `%TypedArray%` methods are non-writable non-configurable
102 try {
103 return redefine(TypedArray, KEY, forced ? property : NATIVE_ARRAY_BUFFER_VIEWS && TypedArray[KEY] || property);
104 } catch (error) { /* empty */ }
105 } else return;
106 }
107 for (ARRAY in TypedArrayConstructorsList) {
108 TypedArrayConstructor = global[ARRAY];
109 if (TypedArrayConstructor && (!TypedArrayConstructor[KEY] || forced)) {
110 redefine(TypedArrayConstructor, KEY, property);
111 }
112 }
113};
114
115for (NAME in TypedArrayConstructorsList) {
116 Constructor = global[NAME];
117 Prototype = Constructor && Constructor.prototype;
118 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);
119 else NATIVE_ARRAY_BUFFER_VIEWS = false;
120}
121
122for (NAME in BigIntArrayConstructorsList) {
123 Constructor = global[NAME];
124 Prototype = Constructor && Constructor.prototype;
125 if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);
126}
127
128// WebKit bug - typed arrays constructors prototype is Object.prototype
129if (!NATIVE_ARRAY_BUFFER_VIEWS || typeof TypedArray != 'function' || TypedArray === Function.prototype) {
130 // eslint-disable-next-line no-shadow -- safe
131 TypedArray = function TypedArray() {
132 throw TypeError('Incorrect invocation');
133 };
134 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
135 if (global[NAME]) setPrototypeOf(global[NAME], TypedArray);
136 }
137}
138
139if (!NATIVE_ARRAY_BUFFER_VIEWS || !TypedArrayPrototype || TypedArrayPrototype === ObjectPrototype) {
140 TypedArrayPrototype = TypedArray.prototype;
141 if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) {
142 if (global[NAME]) setPrototypeOf(global[NAME].prototype, TypedArrayPrototype);
143 }
144}
145
146// WebKit bug - one more object in Uint8ClampedArray prototype chain
147if (NATIVE_ARRAY_BUFFER_VIEWS && getPrototypeOf(Uint8ClampedArrayPrototype) !== TypedArrayPrototype) {
148 setPrototypeOf(Uint8ClampedArrayPrototype, TypedArrayPrototype);
149}
150
151if (DESCRIPTORS && !has(TypedArrayPrototype, TO_STRING_TAG)) {
152 TYPED_ARRAY_TAG_REQIRED = true;
153 defineProperty(TypedArrayPrototype, TO_STRING_TAG, { get: function () {
154 return isObject(this) ? this[TYPED_ARRAY_TAG] : undefined;
155 } });
156 for (NAME in TypedArrayConstructorsList) if (global[NAME]) {
157 createNonEnumerableProperty(global[NAME], TYPED_ARRAY_TAG, NAME);
158 }
159}
160
161module.exports = {
162 NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
163 TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR,
164 TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQIRED && TYPED_ARRAY_TAG,
165 aTypedArray: aTypedArray,
166 aTypedArrayConstructor: aTypedArrayConstructor,
167 exportTypedArrayMethod: exportTypedArrayMethod,
168 exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
169 isView: isView,
170 isTypedArray: isTypedArray,
171 TypedArray: TypedArray,
172 TypedArrayPrototype: TypedArrayPrototype
173};
Note: See TracBrowser for help on using the repository browser.