Uint8ClampedArray.hx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 `Uint8ClampedArray` typed array represents an array of 8-bit unsigned integers clamped
  26. to 0-255; if you specified a value that is out of the range of [0,255], 0 or 255 will be set instead;
  27. if you specify a non-integer, the nearest integer will be set. The contents are initialized to `0`.
  28. Once established, you can reference elements in the array using the object's methods, or using
  29. standard array index syntax (that is, using bracket notation).
  30. Documentation [Uint8ClampedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
  31. **/
  32. @:native("Uint8ClampedArray")
  33. extern class Uint8ClampedArray implements ArrayBufferView implements ArrayAccess<Int> {
  34. /**
  35. Returns a number value of the element size. 1 in the case of an `Uint8ClampedArray`.
  36. */
  37. static final BYTES_PER_ELEMENT:Int;
  38. /**
  39. Creates a new `Uint8ClampedArray` 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).
  40. */
  41. @:overload(function(source:{}, ?mapFn:(value:Int) -> Int, ?thisArg:Any):Uint8ClampedArray {})
  42. @:pure static function from(source:{}, ?mapFn:(value:Int, index:Int) -> Int, ?thisArg:Any):Uint8ClampedArray;
  43. /**
  44. Creates a new `Uint8ClampedArray` with a variable number of arguments. See also [Array.of()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of).
  45. */
  46. @:pure static function of(elements:haxe.extern.Rest<Dynamic>):Uint8ClampedArray;
  47. /**
  48. Returns a number value of the element size.
  49. */
  50. @:native("BYTES_PER_ELEMENT")
  51. final BYTES_PER_ELEMENT_:Int;
  52. /**
  53. Returns the `ArrayBuffer` referenced by the `Uint8ClampedArray` Fixed at construction time and thus read only.
  54. */
  55. final buffer:ArrayBuffer;
  56. /**
  57. Returns the length (in bytes) of the `Uint8ClampedArray` from the start of its `ArrayBuffer`. Fixed at construction time and thus read only.
  58. */
  59. final byteLength:Int;
  60. /**
  61. Returns the offset (in bytes) of the `Uint8ClampedArray` from the start of its `ArrayBuffer`. Fixed at construction time and thus read only.
  62. */
  63. final byteOffset:Int;
  64. /**
  65. Returns the number of elements hold in the `Uint8ClampedArray`. Fixed at construction time and thus read only.
  66. */
  67. final length:Int;
  68. /** @throws DOMError */
  69. @:overload(function(length:Int):Void {})
  70. @:overload(function(object:{}):Void {})
  71. @:pure function new(buffer:ArrayBuffer, ?byteOffset:Int, ?length:Int):Void;
  72. /**
  73. Copies a sequence of array elements within the array.
  74. See also [Array.prototype.copyWithin()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin).
  75. */
  76. function copyWithin(target:Int, start:Int, ?end:Int):Uint8ClampedArray;
  77. /**
  78. Returns a new Array Iterator object that contains the key/value pairs for each index in the array.
  79. See also [Array.prototype.entries()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries).
  80. */
  81. @:pure function entries():js.lib.Iterator<KeyValue<Int, Int>>;
  82. /**
  83. Tests whether all elements in the array pass the test provided by a function.
  84. See also [Array.prototype.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
  85. */
  86. @:overload(function(callback:(currentValue:Int) -> Bool, ?thisArg:Any):Bool {})
  87. @:overload(function(callback:(currentValue:Int, index:Int) -> Bool, ?thisArg:Any):Bool {})
  88. function every(callback:(currentValue:Int, index:Int, array:Uint8ClampedArray) -> Bool, ?thisArg:Any):Bool;
  89. /**
  90. Fills all the elements of an array from a start index to an end index with a static value.
  91. See also [Array.prototype.fill()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill).
  92. */
  93. function fill(value:Int, ?start:Int, ?end:Int):Uint8ClampedArray;
  94. /**
  95. Creates a new array with all of the elements of this array for which the provided filtering function returns true.
  96. See also [Array.prototype.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter).
  97. */
  98. @:overload(function(callback:(element:Int) -> Bool, ?thisArg:Any):Uint8ClampedArray {})
  99. @:overload(function(callback:(element:Int, index:Int) -> Bool, ?thisArg:Any):Uint8ClampedArray {})
  100. function filter(callback:(element:Int, index:Int, array:Uint8ClampedArray) -> Bool, ?thisArg:Any):Uint8ClampedArray;
  101. /**
  102. Returns the found value in the array, if an element in the array satisfies the provided testing function or undefined if not found.
  103. See also [Array.prototype.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
  104. */
  105. @:overload(function(callback:(element:Int) -> Bool, ?thisArg:Any):Null<Int> {})
  106. @:overload(function(callback:(element:Int, index:Int) -> Bool, ?thisArg:Any):Null<Int> {})
  107. function find(callback:(element:Int, index:Int, array:Uint8ClampedArray) -> Bool, ?thisArg:Any):Null<Int>;
  108. /**
  109. Returns the found index in the array, if an element in the array satisfies the provided testing function or -1 if not found.
  110. See also [Array.prototype.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex).
  111. */
  112. @:overload(function(callback:(element:Int) -> Bool, ?thisArg:Any):Int {})
  113. @:overload(function(callback:(element:Int, index:Int) -> Bool, ?thisArg:Any):Int {})
  114. function findIndex(callback:(element:Int, index:Int, array:Uint8ClampedArray) -> Bool, ?thisArg:Any):Int;
  115. /**
  116. Calls a function for each element in the array.
  117. See also [Array.prototype.forEach()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).
  118. */
  119. @:overload(function(callback:(element:Int) -> Void, ?thisArg:Any):Void {})
  120. @:overload(function(callback:(element:Int, index:Int) -> Void, ?thisArg:Any):Void {})
  121. function forEach(callback:(element:Int, index:Int, array:Uint8ClampedArray) -> Void, ?thisArg:Any):Void;
  122. /**
  123. Determines whether a typed array includes a certain element, returning true or false as appropriate.
  124. See also [Array.prototype.includes()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes).
  125. */
  126. @:pure function includes(searchElement:Int, ?fromIndex:Int):Bool;
  127. /**
  128. Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
  129. See also [Array.prototype.indexOf()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf).
  130. */
  131. @:pure function indexOf(searchElement:Int, ?fromIndex:Int):Int;
  132. /**
  133. Joins all elements of an array into a string.
  134. See also [Array.prototype.join()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join).
  135. */
  136. @:pure function join(?separator:String):String;
  137. /**
  138. Returns a new Array Iterator that contains the keys for each index in the array.
  139. See also [Array.prototype.keys()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys).
  140. */
  141. @:pure function keys():js.lib.Iterator<Int>;
  142. /**
  143. Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
  144. See also [Array.prototype.lastIndexOf()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf).
  145. */
  146. @:pure function lastIndexOf(searchElement:Int, ?fromIndex:Int):Int;
  147. /**
  148. Creates a new array with the results of calling a provided function on every element in this array.
  149. See also [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
  150. */
  151. @:overload(function(callback:(element:Int) -> Int, ?thisArg:Any):Uint8ClampedArray {})
  152. @:overload(function(callback:(element:Int, index:Int) -> Int, ?thisArg:Any):Uint8ClampedArray {})
  153. function map(callback:(element:Int, index:Int, array:Uint8ClampedArray) -> Int, ?thisArg:Any):Uint8ClampedArray;
  154. /**
  155. Apply a function against an accumulator and each value of the array (from left-to-right) as to reduce it to a single value.
  156. See also [Array.prototype.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
  157. */
  158. @:overload(function<T>(callback:(previousValue:T, currentValue:Int) -> T, initialValue:T):T {})
  159. @:overload(function<T>(callback:(previousValue:T, currentValue:Int, index:Int) -> T, initialValue:T):T {})
  160. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int) -> Int):Int {})
  161. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int, index:Int) -> Int):Int {})
  162. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int, index:Int, array:Uint8ClampedArray) -> Int):Int {})
  163. function reduce<T>(callback:(previousValue:T, currentValue:Int, index:Int, array:Uint8ClampedArray) -> T, initialValue:T):T;
  164. /**
  165. Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value.
  166. See also [Array.prototype.reduceRight()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight).
  167. */
  168. @:overload(function<T>(callback:(previousValue:T, currentValue:Int) -> T, initialValue:T):T {})
  169. @:overload(function<T>(callback:(previousValue:T, currentValue:Int, index:Int) -> T, initialValue:T):T {})
  170. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int) -> Int):Int {})
  171. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int, index:Int) -> Int):Int {})
  172. @:overload(function(callbackfn:(previousValue:Int, currentValue:Int, index:Int, array:Uint8ClampedArray) -> Int):Int {})
  173. function reduceRight<T>(callback:(previousValue:T, currentValue:Int, index:Int, array:Uint8ClampedArray) -> T, initialValue:T):T;
  174. /**
  175. Reverses the order of the elements of an array — the first becomes the last, and the last becomes the first.
  176. See also [Array.prototype.reverse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse).
  177. */
  178. function reverse():Uint8ClampedArray;
  179. /**
  180. Stores multiple values in the typed array, reading input values from a specified array.
  181. */
  182. @:overload(function(array:Int8Array, ?offset:Int):Void {})
  183. @:overload(function(array:Uint8Array, ?offset:Int):Void {})
  184. @:overload(function(array:Uint8ClampedArray, ?offset:Int):Void {})
  185. @:overload(function(array:Int16Array, ?offset:Int):Void {})
  186. @:overload(function(array:Uint16Array, ?offset:Int):Void {})
  187. @:overload(function(array:Int32Array, ?offset:Int):Void {})
  188. @:overload(function(array:Uint32Array, ?offset:Int):Void {})
  189. @:overload(function(array:Float32Array, ?offset:Int):Void {})
  190. @:overload(function(array:Float64Array, ?offset:Int):Void {})
  191. function set(array:Array<Int>, ?offset:Int):Void;
  192. /**
  193. Extracts a section of an array and returns a new array.
  194. See also [Array.prototype.slice()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice).
  195. */
  196. @:pure function slice(?start:Int, ?end:Int):Uint8ClampedArray;
  197. /**
  198. Returns true if at least one element in this array satisfies the provided testing function.
  199. See also [Array.prototype.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
  200. */
  201. @:overload(function(callback:(element:Int) -> Bool, ?thisArg:Any):Bool {})
  202. @:overload(function(callback:(element:Int, index:Int) -> Bool, ?thisArg:Any):Bool {})
  203. function some(callback:(element:Int, index:Int, array:Uint8ClampedArray) -> Bool, ?thisArg:Any):Bool;
  204. /**
  205. Sorts the elements of an array in place and returns the array.
  206. See also [Array.prototype.sort()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort).
  207. */
  208. function sort(?compareFn:(x:Int, y:Int) -> Int):Uint8ClampedArray;
  209. /**
  210. Returns a new TypedArray from the given start and end element index.
  211. */
  212. @:pure function subarray(?begin:Int, ?end:Int):Uint8ClampedArray;
  213. /**
  214. Returns a new Array Iterator object that contains the values for each index in the array.
  215. See also [Array.prototype.values()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values).
  216. */
  217. @:pure function values():js.lib.Iterator<Int>;
  218. /**
  219. Returns a string representing the array and its elements.
  220. See also [Array.prototype.toString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString).
  221. */
  222. @:pure function toLocaleString(?locales:String, ?options:NumberFormatOptions):String;
  223. /**
  224. Returns a string representing the array and its elements.
  225. See also [Array.prototype.toString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString).
  226. */
  227. @:pure function toString():String;
  228. }