Uint32Array.hx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package js.lib;
  23. import js.lib.intl.NumberFormat.NumberFormatOptions;
  24. /**
  25. The `Uint32Array` typed array represents an array of 32-bit unsigned integers in the platform
  26. byte order. If control over byte order is needed, use `DataView` instead. The contents are
  27. initialized to `0`. Once established, you can reference elements in the array using the object's
  28. methods, or using standard array index syntax (that is, using bracket notation).
  29. Documentation [Uint32Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
  30. **/
  31. @:native("Uint32Array")
  32. extern class Uint32Array implements ArrayBufferView implements ArrayAccess<Int> {
  33. /**
  34. Returns a number value of the element size. 4 in the case of an `Uint32Array`.
  35. */
  36. static final BYTES_PER_ELEMENT:Int;
  37. /**
  38. Creates a new `Uint32Array` from an array-like or iterable object. See also [Array.from()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from).
  39. */
  40. @:overload(function(source:{}, ?mapFn:(value:Int) -> Int, ?thisArg:Any):Uint32Array {})
  41. @:pure static function from(source:{}, ?mapFn:(value:Int, index:Int) -> Int, ?thisArg:Any):Uint32Array;
  42. /**
  43. Creates a new `Uint32Array` with a variable number of arguments. See also [Array.of()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of).
  44. */
  45. @:pure static function of(elements:haxe.extern.Rest<Dynamic>):Uint32Array;
  46. /**
  47. Returns a number value of the element size.
  48. */
  49. @:native("BYTES_PER_ELEMENT")
  50. final BYTES_PER_ELEMENT_:Int;
  51. /**
  52. Returns the `ArrayBuffer` referenced by the `Uint32Array` Fixed at construction time and thus read only.
  53. */
  54. final buffer:ArrayBuffer;
  55. /**
  56. Returns the length (in bytes) of the `Uint32Array` from the start of its `ArrayBuffer`. Fixed at construction time and thus read only.
  57. */
  58. final byteLength:Int;
  59. /**
  60. Returns the offset (in bytes) of the `Uint32Array` from the start of its `ArrayBuffer`. Fixed at construction time and thus read only.
  61. */
  62. final byteOffset:Int;
  63. /**
  64. Returns the number of elements hold in the `Uint32Array`. Fixed at construction time and thus read only.
  65. */
  66. final length:Int;
  67. /** @throws DOMError */
  68. @:overload(function(length:Int):Void {})
  69. @:overload(function(object:{}):Void {})
  70. @:pure function new(buffer:ArrayBuffer, ?byteOffset:Int, ?length:Int):Void;
  71. /**
  72. Copies a sequence of array elements within the array.
  73. See also [Array.prototype.copyWithin()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin).
  74. */
  75. function copyWithin(target:Int, start:Int, ?end:Int):Uint32Array;
  76. /**
  77. Returns a new Array Iterator object that contains the key/value pairs for each index in the array.
  78. See also [Array.prototype.entries()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries).
  79. */
  80. @:pure function entries():js.lib.Iterator<KeyValue<Int, Int>>;
  81. /**
  82. Tests whether all elements in the array pass the test provided by a function.
  83. See also [Array.prototype.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
  84. */
  85. @:overload(function(callback:(currentValue:Int) -> Bool, ?thisArg:Any):Bool {})
  86. @:overload(function(callback:(currentValue:Int, index:Int) -> Bool, ?thisArg:Any):Bool {})
  87. function every(callback:(currentValue:Int, index:Int, array:Uint32Array) -> Bool, ?thisArg:Any):Bool;
  88. /**
  89. Fills all the elements of an array from a start index to an end index with a static value.
  90. See also [Array.prototype.fill()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill).
  91. */
  92. function fill(value:Int, ?start:Int, ?end:Int):Uint32Array;
  93. /**
  94. Creates a new array with all of the elements of this array for which the provided filtering function returns true.
  95. See also [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter).
  96. */
  97. @:overload(function(callback:(element:Int) -> Bool, ?thisArg:Any):Uint32Array {})
  98. @:overload(function(callback:(element:Int, index:Int) -> Bool, ?thisArg:Any):Uint32Array {})
  99. function filter(callback:(element:Int, index:Int, array:Uint32Array) -> Bool, ?thisArg:Any):Uint32Array;
  100. /**
  101. Returns the found value in the array, if an element in the array satisfies the provided testing function or undefined if not found.
  102. See also [Array.prototype.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
  103. */
  104. @:overload(function(callback:(element:Int) -> Bool, ?thisArg:Any):Null<Int> {})
  105. @:overload(function(callback:(element:Int, index:Int) -> Bool, ?thisArg:Any):Null<Int> {})
  106. function find(callback:(element:Int, index:Int, array:Uint32Array) -> Bool, ?thisArg:Any):Null<Int>;
  107. /**
  108. Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found.
  109. See also [Array.prototype.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex).
  110. */
  111. @:overload(function(callback:(element:Int) -> Bool, ?thisArg:Any):Int {})
  112. @:overload(function(callback:(element:Int, index:Int) -> Bool, ?thisArg:Any):Int {})
  113. function findIndex(callback:(element:Int, index:Int, array:Uint32Array) -> Bool, ?thisArg:Any):Int;
  114. /**
  115. Calls a function for each element in the array.
  116. See also [Array.prototype.forEach()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).
  117. */
  118. @:overload(function(callback:(element:Int) -> Void, ?thisArg:Any):Void {})
  119. @:overload(function(callback:(element:Int, index:Int) -> Void, ?thisArg:Any):Void {})
  120. function forEach(callback:(element:Int, index:Int, array:Uint32Array) -> Void, ?thisArg:Any):Void;
  121. /**
  122. Determines whether a typed array includes a certain element, returning true or false as appropriate.
  123. See also [Array.prototype.includes()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes).
  124. */
  125. @:pure function includes(searchElement:Int, ?fromIndex:Int):Bool;
  126. /**
  127. Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
  128. See also [Array.prototype.indexOf()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf).
  129. */
  130. @:pure function indexOf(searchElement:Int, ?fromIndex:Int):Int;
  131. /**
  132. Joins all elements of an array into a string.
  133. See also [Array.prototype.join()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join).
  134. */
  135. @:pure function join(?separator:String):String;
  136. /**
  137. Returns a new Array Iterator that contains the keys for each index in the array.
  138. See also [Array.prototype.keys()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys).
  139. */
  140. @:pure function keys():js.lib.Iterator<Int>;
  141. /**
  142. Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
  143. See also [Array.prototype.lastIndexOf()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf).
  144. */
  145. @:pure function lastIndexOf(searchElement:Int, ?fromIndex:Int):Int;
  146. /**
  147. Creates a new array with the results of calling a provided function on every element in this array.
  148. See also [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
  149. */
  150. @:overload(function(callback:(element:Int) -> Int, ?thisArg:Any):Uint32Array {})
  151. @:overload(function(callback:(element:Int, index:Int) -> Int, ?thisArg:Any):Uint32Array {})
  152. function map(callback:(element:Int, index:Int, array:Uint32Array) -> Int, ?thisArg:Any):Uint32Array;
  153. /**
  154. Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value.
  155. See also [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
  156. */
  157. @:overload(function<T>(callback:(previousValue:T, currentValue:Int) -> T, initialValue:T):T {})
  158. @:overload(function<T>(callback:(previousValue:T, currentValue:Int, index:Int) -> T, initialValue:T):T {})
  159. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int) -> Int):Int {})
  160. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int, index:Int) -> Int):Int {})
  161. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int, index:Int, array:Uint32Array) -> Int):Int {})
  162. function reduce<T>(callback:(previousValue:T, currentValue:Int, index:Int, array:Uint32Array) -> T, initialValue:T):T;
  163. /**
  164. Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value.
  165. See also [Array.prototype.reduceRight()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight).
  166. */
  167. @:overload(function<T>(callback:(previousValue:T, currentValue:Int) -> T, initialValue:T):T {})
  168. @:overload(function<T>(callback:(previousValue:T, currentValue:Int, index:Int) -> T, initialValue:T):T {})
  169. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int) -> Int):Int {})
  170. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int, index:Int) -> Int):Int {})
  171. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int, index:Int, array:Uint32Array) -> Int):Int {})
  172. function reduceRight<T>(callback:(previousValue:T, currentValue:Int, index:Int, array:Uint32Array) -> T, initialValue:T):T;
  173. /**
  174. Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first.
  175. See also [Array.prototype.reverse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse).
  176. */
  177. function reverse():Uint32Array;
  178. /**
  179. Stores multiple values in the typed array, reading input values from a specified array.
  180. */
  181. @:overload(function(array:Int8Array, ?offset:Int):Void {})
  182. @:overload(function(array:Uint8Array, ?offset:Int):Void {})
  183. @:overload(function(array:Uint8ClampedArray, ?offset:Int):Void {})
  184. @:overload(function(array:Int16Array, ?offset:Int):Void {})
  185. @:overload(function(array:Uint16Array, ?offset:Int):Void {})
  186. @:overload(function(array:Int32Array, ?offset:Int):Void {})
  187. @:overload(function(array:Uint32Array, ?offset:Int):Void {})
  188. @:overload(function(array:Float32Array, ?offset:Int):Void {})
  189. @:overload(function(array:Float64Array, ?offset:Int):Void {})
  190. function set(array:Array<Int>, ?offset:Int):Void;
  191. /**
  192. Extracts a section of an array and returns a new array.
  193. See also [Array.prototype.slice()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice).
  194. */
  195. @:pure function slice(?start:Int, ?end:Int):Uint32Array;
  196. /**
  197. Returns true if at least one element in this array satisfies the provided testing function.
  198. See also [Array.prototype.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
  199. */
  200. @:overload(function(callback:(element:Int) -> Bool, ?thisArg:Any):Bool {})
  201. @:overload(function(callback:(element:Int, index:Int) -> Bool, ?thisArg:Any):Bool {})
  202. function some(callback:(element:Int, index:Int, array:Uint32Array) -> Bool, ?thisArg:Any):Bool;
  203. /**
  204. Sorts the elements of an array in place and returns the array.
  205. See also [Array.prototype.sort()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort).
  206. */
  207. function sort(?compareFn:(x:Int, y:Int) -> Int):Uint32Array;
  208. /**
  209. Returns a new TypedArray from the given start and end element index.
  210. */
  211. @:pure function subarray(?begin:Int, ?end:Int):Uint32Array;
  212. /**
  213. Returns a new Array Iterator object that contains the values for each index in the array.
  214. See also [Array.prototype.values()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values).
  215. */
  216. @:pure function values():js.lib.Iterator<Int>;
  217. /**
  218. Returns a string representing the array and its elements.
  219. See also [Array.prototype.toString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString).
  220. */
  221. @:pure function toLocaleString(?locales:String, ?options:NumberFormatOptions):String;
  222. /**
  223. Returns a string representing the array and its elements.
  224. See also [Array.prototype.toString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString).
  225. */
  226. @:pure function toString():String;
  227. }