Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

array-buffer-view-core.js 6.2KB

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