/static/node_modules/typescript/lib/lib.es2015.iterable.d.ts

https://gitlab.com/garbotron/goshots2 · TypeScript Typings · 461 lines · 164 code · 62 blank · 235 comment · 2 complexity · 00894e7132957ea8885ce84fbad5dbc1 MD5 · raw file

  1. /*! *****************************************************************************
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  4. this file except in compliance with the License. You may obtain a copy of the
  5. License at http://www.apache.org/licenses/LICENSE-2.0
  6. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  8. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  9. MERCHANTABLITY OR NON-INFRINGEMENT.
  10. See the Apache Version 2.0 License for specific language governing permissions
  11. and limitations under the License.
  12. ***************************************************************************** */
  13. /// <reference no-default-lib="true"/>
  14. /// <reference path="lib.es2015.symbol.d.ts" />
  15. interface SymbolConstructor {
  16. /**
  17. * A method that returns the default iterator for an object. Called by the semantics of the
  18. * for-of statement.
  19. */
  20. readonly iterator: symbol;
  21. }
  22. interface IteratorResult<T> {
  23. done: boolean;
  24. value: T;
  25. }
  26. interface Iterator<T> {
  27. next(value?: any): IteratorResult<T>;
  28. return?(value?: any): IteratorResult<T>;
  29. throw?(e?: any): IteratorResult<T>;
  30. }
  31. interface Iterable<T> {
  32. [Symbol.iterator](): Iterator<T>;
  33. }
  34. interface IterableIterator<T> extends Iterator<T> {
  35. [Symbol.iterator](): IterableIterator<T>;
  36. }
  37. interface Array<T> {
  38. /** Iterator */
  39. [Symbol.iterator](): IterableIterator<T>;
  40. /**
  41. * Returns an array of key, value pairs for every entry in the array
  42. */
  43. entries(): IterableIterator<[number, T]>;
  44. /**
  45. * Returns an list of keys in the array
  46. */
  47. keys(): IterableIterator<number>;
  48. /**
  49. * Returns an list of values in the array
  50. */
  51. values(): IterableIterator<T>;
  52. }
  53. interface ArrayConstructor {
  54. /**
  55. * Creates an array from an iterable object.
  56. * @param iterable An iterable object to convert to an array.
  57. * @param mapfn A mapping function to call on every element of the array.
  58. * @param thisArg Value of 'this' used to invoke the mapfn.
  59. */
  60. from<T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): Array<U>;
  61. /**
  62. * Creates an array from an iterable object.
  63. * @param iterable An iterable object to convert to an array.
  64. */
  65. from<T>(iterable: Iterable<T>): Array<T>;
  66. }
  67. interface ReadonlyArray<T> {
  68. /** Iterator */
  69. [Symbol.iterator](): IterableIterator<T>;
  70. /**
  71. * Returns an array of key, value pairs for every entry in the array
  72. */
  73. entries(): IterableIterator<[number, T]>;
  74. /**
  75. * Returns an list of keys in the array
  76. */
  77. keys(): IterableIterator<number>;
  78. /**
  79. * Returns an list of values in the array
  80. */
  81. values(): IterableIterator<T>;
  82. }
  83. interface IArguments {
  84. /** Iterator */
  85. [Symbol.iterator](): IterableIterator<any>;
  86. }
  87. interface Map<K, V> {
  88. [Symbol.iterator](): IterableIterator<[K,V]>;
  89. entries(): IterableIterator<[K, V]>;
  90. keys(): IterableIterator<K>;
  91. values(): IterableIterator<V>;
  92. }
  93. interface MapConstructor {
  94. new <K, V>(iterable: Iterable<[K, V]>): Map<K, V>;
  95. }
  96. interface WeakMap<K, V> { }
  97. interface WeakMapConstructor {
  98. new <K, V>(iterable: Iterable<[K, V]>): WeakMap<K, V>;
  99. }
  100. interface Set<T> {
  101. [Symbol.iterator](): IterableIterator<T>;
  102. entries(): IterableIterator<[T, T]>;
  103. keys(): IterableIterator<T>;
  104. values(): IterableIterator<T>;
  105. }
  106. interface SetConstructor {
  107. new <T>(iterable: Iterable<T>): Set<T>;
  108. }
  109. interface WeakSet<T> { }
  110. interface WeakSetConstructor {
  111. new <T>(iterable: Iterable<T>): WeakSet<T>;
  112. }
  113. interface Promise<T> { }
  114. interface PromiseConstructor {
  115. /**
  116. * Creates a Promise that is resolved with an array of results when all of the provided Promises
  117. * resolve, or rejected when any Promise is rejected.
  118. * @param values An array of Promises.
  119. * @returns A new Promise.
  120. */
  121. all<TAll>(values: Iterable<TAll | PromiseLike<TAll>>): Promise<TAll[]>;
  122. /**
  123. * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
  124. * or rejected.
  125. * @param values An array of Promises.
  126. * @returns A new Promise.
  127. */
  128. race<T>(values: Iterable<T | PromiseLike<T>>): Promise<T>;
  129. }
  130. declare namespace Reflect {
  131. function enumerate(target: any): IterableIterator<any>;
  132. }
  133. interface String {
  134. /** Iterator */
  135. [Symbol.iterator](): IterableIterator<string>;
  136. }
  137. /**
  138. * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested
  139. * number of bytes could not be allocated an exception is raised.
  140. */
  141. interface Int8Array {
  142. [Symbol.iterator](): IterableIterator<number>;
  143. /**
  144. * Returns an array of key, value pairs for every entry in the array
  145. */
  146. entries(): IterableIterator<[number, number]>;
  147. /**
  148. * Returns an list of keys in the array
  149. */
  150. keys(): IterableIterator<number>;
  151. /**
  152. * Returns an list of values in the array
  153. */
  154. values(): IterableIterator<number>;
  155. }
  156. interface Int8ArrayConstructor {
  157. new (elements: Iterable<number>): Int8Array;
  158. /**
  159. * Creates an array from an array-like or iterable object.
  160. * @param arrayLike An array-like or iterable object to convert to an array.
  161. * @param mapfn A mapping function to call on every element of the array.
  162. * @param thisArg Value of 'this' used to invoke the mapfn.
  163. */
  164. from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array;
  165. }
  166. /**
  167. * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
  168. * requested number of bytes could not be allocated an exception is raised.
  169. */
  170. interface Uint8Array {
  171. [Symbol.iterator](): IterableIterator<number>;
  172. /**
  173. * Returns an array of key, value pairs for every entry in the array
  174. */
  175. entries(): IterableIterator<[number, number]>;
  176. /**
  177. * Returns an list of keys in the array
  178. */
  179. keys(): IterableIterator<number>;
  180. /**
  181. * Returns an list of values in the array
  182. */
  183. values(): IterableIterator<number>;
  184. }
  185. interface Uint8ArrayConstructor {
  186. new (elements: Iterable<number>): Uint8Array;
  187. /**
  188. * Creates an array from an array-like or iterable object.
  189. * @param arrayLike An array-like or iterable object to convert to an array.
  190. * @param mapfn A mapping function to call on every element of the array.
  191. * @param thisArg Value of 'this' used to invoke the mapfn.
  192. */
  193. from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array;
  194. }
  195. /**
  196. * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0.
  197. * If the requested number of bytes could not be allocated an exception is raised.
  198. */
  199. interface Uint8ClampedArray {
  200. [Symbol.iterator](): IterableIterator<number>;
  201. /**
  202. * Returns an array of key, value pairs for every entry in the array
  203. */
  204. entries(): IterableIterator<[number, number]>;
  205. /**
  206. * Returns an list of keys in the array
  207. */
  208. keys(): IterableIterator<number>;
  209. /**
  210. * Returns an list of values in the array
  211. */
  212. values(): IterableIterator<number>;
  213. }
  214. interface Uint8ClampedArrayConstructor {
  215. new (elements: Iterable<number>): Uint8ClampedArray;
  216. /**
  217. * Creates an array from an array-like or iterable object.
  218. * @param arrayLike An array-like or iterable object to convert to an array.
  219. * @param mapfn A mapping function to call on every element of the array.
  220. * @param thisArg Value of 'this' used to invoke the mapfn.
  221. */
  222. from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray;
  223. }
  224. /**
  225. * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the
  226. * requested number of bytes could not be allocated an exception is raised.
  227. */
  228. interface Int16Array {
  229. [Symbol.iterator](): IterableIterator<number>;
  230. /**
  231. * Returns an array of key, value pairs for every entry in the array
  232. */
  233. entries(): IterableIterator<[number, number]>;
  234. /**
  235. * Returns an list of keys in the array
  236. */
  237. keys(): IterableIterator<number>;
  238. /**
  239. * Returns an list of values in the array
  240. */
  241. values(): IterableIterator<number>;
  242. }
  243. interface Int16ArrayConstructor {
  244. new (elements: Iterable<number>): Int16Array;
  245. /**
  246. * Creates an array from an array-like or iterable object.
  247. * @param arrayLike An array-like or iterable object to convert to an array.
  248. * @param mapfn A mapping function to call on every element of the array.
  249. * @param thisArg Value of 'this' used to invoke the mapfn.
  250. */
  251. from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array;
  252. }
  253. /**
  254. * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the
  255. * requested number of bytes could not be allocated an exception is raised.
  256. */
  257. interface Uint16Array {
  258. [Symbol.iterator](): IterableIterator<number>;
  259. /**
  260. * Returns an array of key, value pairs for every entry in the array
  261. */
  262. entries(): IterableIterator<[number, number]>;
  263. /**
  264. * Returns an list of keys in the array
  265. */
  266. keys(): IterableIterator<number>;
  267. /**
  268. * Returns an list of values in the array
  269. */
  270. values(): IterableIterator<number>;
  271. }
  272. interface Uint16ArrayConstructor {
  273. new (elements: Iterable<number>): Uint16Array;
  274. /**
  275. * Creates an array from an array-like or iterable object.
  276. * @param arrayLike An array-like or iterable object to convert to an array.
  277. * @param mapfn A mapping function to call on every element of the array.
  278. * @param thisArg Value of 'this' used to invoke the mapfn.
  279. */
  280. from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array;
  281. }
  282. /**
  283. * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the
  284. * requested number of bytes could not be allocated an exception is raised.
  285. */
  286. interface Int32Array {
  287. [Symbol.iterator](): IterableIterator<number>;
  288. /**
  289. * Returns an array of key, value pairs for every entry in the array
  290. */
  291. entries(): IterableIterator<[number, number]>;
  292. /**
  293. * Returns an list of keys in the array
  294. */
  295. keys(): IterableIterator<number>;
  296. /**
  297. * Returns an list of values in the array
  298. */
  299. values(): IterableIterator<number>;
  300. }
  301. interface Int32ArrayConstructor {
  302. new (elements: Iterable<number>): Int32Array;
  303. /**
  304. * Creates an array from an array-like or iterable object.
  305. * @param arrayLike An array-like or iterable object to convert to an array.
  306. * @param mapfn A mapping function to call on every element of the array.
  307. * @param thisArg Value of 'this' used to invoke the mapfn.
  308. */
  309. from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array;
  310. }
  311. /**
  312. * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the
  313. * requested number of bytes could not be allocated an exception is raised.
  314. */
  315. interface Uint32Array {
  316. [Symbol.iterator](): IterableIterator<number>;
  317. /**
  318. * Returns an array of key, value pairs for every entry in the array
  319. */
  320. entries(): IterableIterator<[number, number]>;
  321. /**
  322. * Returns an list of keys in the array
  323. */
  324. keys(): IterableIterator<number>;
  325. /**
  326. * Returns an list of values in the array
  327. */
  328. values(): IterableIterator<number>;
  329. }
  330. interface Uint32ArrayConstructor {
  331. new (elements: Iterable<number>): Uint32Array;
  332. /**
  333. * Creates an array from an array-like or iterable object.
  334. * @param arrayLike An array-like or iterable object to convert to an array.
  335. * @param mapfn A mapping function to call on every element of the array.
  336. * @param thisArg Value of 'this' used to invoke the mapfn.
  337. */
  338. from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array;
  339. }
  340. /**
  341. * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number
  342. * of bytes could not be allocated an exception is raised.
  343. */
  344. interface Float32Array {
  345. [Symbol.iterator](): IterableIterator<number>;
  346. /**
  347. * Returns an array of key, value pairs for every entry in the array
  348. */
  349. entries(): IterableIterator<[number, number]>;
  350. /**
  351. * Returns an list of keys in the array
  352. */
  353. keys(): IterableIterator<number>;
  354. /**
  355. * Returns an list of values in the array
  356. */
  357. values(): IterableIterator<number>;
  358. }
  359. interface Float32ArrayConstructor {
  360. new (elements: Iterable<number>): Float32Array;
  361. /**
  362. * Creates an array from an array-like or iterable object.
  363. * @param arrayLike An array-like or iterable object to convert to an array.
  364. * @param mapfn A mapping function to call on every element of the array.
  365. * @param thisArg Value of 'this' used to invoke the mapfn.
  366. */
  367. from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array;
  368. }
  369. /**
  370. * A typed array of 64-bit float values. The contents are initialized to 0. If the requested
  371. * number of bytes could not be allocated an exception is raised.
  372. */
  373. interface Float64Array {
  374. [Symbol.iterator](): IterableIterator<number>;
  375. /**
  376. * Returns an array of key, value pairs for every entry in the array
  377. */
  378. entries(): IterableIterator<[number, number]>;
  379. /**
  380. * Returns an list of keys in the array
  381. */
  382. keys(): IterableIterator<number>;
  383. /**
  384. * Returns an list of values in the array
  385. */
  386. values(): IterableIterator<number>;
  387. }
  388. interface Float64ArrayConstructor {
  389. new (elements: Iterable<number>): Float64Array;
  390. /**
  391. * Creates an array from an array-like or iterable object.
  392. * @param arrayLike An array-like or iterable object to convert to an array.
  393. * @param mapfn A mapping function to call on every element of the array.
  394. * @param thisArg Value of 'this' used to invoke the mapfn.
  395. */
  396. from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
  397. }