iterable.es6.d.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. interface Symbol {
  2. /** Returns a string representation of an object. */
  3. toString(): string;
  4. /** Returns the primitive value of the specified object. */
  5. valueOf(): Object;
  6. [Symbol.toStringTag]: string;
  7. }
  8. interface SymbolConstructor {
  9. /**
  10. * A reference to the prototype.
  11. */
  12. prototype: Symbol;
  13. /**
  14. * Returns a new unique Symbol value.
  15. * @param description Description of the new Symbol object.
  16. */
  17. (description?: string|number): symbol;
  18. /**
  19. * Returns a Symbol object from the global symbol registry matching the given key if found.
  20. * Otherwise, returns a new symbol with this key.
  21. * @param key key to search for.
  22. */
  23. for(key: string): symbol;
  24. /**
  25. * Returns a key from the global symbol registry matching the given Symbol if found.
  26. * Otherwise, returns a undefined.
  27. * @param sym Symbol to find the key for.
  28. */
  29. keyFor(sym: symbol): string;
  30. // Well-known Symbols
  31. /**
  32. * A method that determines if a constructor object recognizes an object as one of the
  33. * constructor’s instances. Called by the semantics of the instanceof operator.
  34. */
  35. hasInstance: symbol;
  36. /**
  37. * A Boolean value that if true indicates that an object should flatten to its array elements
  38. * by Array.prototype.concat.
  39. */
  40. isConcatSpreadable: symbol;
  41. /**
  42. * A method that returns the default iterator for an object. Called by the semantics of the
  43. * for-of statement.
  44. */
  45. iterator: symbol;
  46. /**
  47. * A regular expression method that matches the regular expression against a string. Called
  48. * by the String.prototype.match method.
  49. */
  50. match: symbol;
  51. /**
  52. * A regular expression method that replaces matched substrings of a string. Called by the
  53. * String.prototype.replace method.
  54. */
  55. replace: symbol;
  56. /**
  57. * A regular expression method that returns the index within a string that matches the
  58. * regular expression. Called by the String.prototype.search method.
  59. */
  60. search: symbol;
  61. /**
  62. * A function valued property that is the constructor function that is used to create
  63. * derived objects.
  64. */
  65. species: symbol;
  66. /**
  67. * A regular expression method that splits a string at the indices that match the regular
  68. * expression. Called by the String.prototype.split method.
  69. */
  70. split: symbol;
  71. /**
  72. * A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
  73. * abstract operation.
  74. */
  75. toPrimitive: symbol;
  76. /**
  77. * A String value that is used in the creation of the default string description of an object.
  78. * Called by the built-in method Object.prototype.toString.
  79. */
  80. toStringTag: symbol;
  81. /**
  82. * An Object whose own property names are property names that are excluded from the with
  83. * environment bindings of the associated objects.
  84. */
  85. unscopables: symbol;
  86. }
  87. declare var Symbol: SymbolConstructor;
  88. interface IteratorResult<T> {
  89. done: boolean;
  90. value?: T;
  91. }
  92. interface Iterator<T> {
  93. next(value?: any): IteratorResult<T>;
  94. return?(value?: any): IteratorResult<T>;
  95. throw?(e?: any): IteratorResult<T>;
  96. }
  97. interface Iterable<T> {
  98. [Symbol.iterator](): Iterator<T>;
  99. }
  100. interface IterableIterator<T> extends Iterator<T> {
  101. [Symbol.iterator](): IterableIterator<T>;
  102. }
  103. interface WeakMap<K, V> {
  104. clear(): void;
  105. delete(key: K): boolean;
  106. get(key: K): V;
  107. has(key: K): boolean;
  108. set(key: K, value?: V): WeakMap<K, V>;
  109. }
  110. interface WeakMapConstructor {
  111. new <K, V>(): WeakMap<K, V>;
  112. prototype: WeakMap<any, any>;
  113. }
  114. declare var WeakMap: WeakMapConstructor;
  115. interface Map<K, V> {
  116. clear(): void;
  117. delete(key: K): boolean;
  118. entries(): IterableIterator<[K, V]>;
  119. forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
  120. get(key: K): V;
  121. has(key: K): boolean;
  122. keys(): IterableIterator<K>;
  123. set(key: K, value?: V): Map<K, V>;
  124. size: number;
  125. values(): IterableIterator<V>;
  126. [Symbol.iterator]():IterableIterator<[K,V]>;
  127. [Symbol.toStringTag]: string;
  128. }
  129. interface MapConstructor {
  130. new <K, V>(): Map<K, V>;
  131. new <K, V>(iterable: Iterable<[K, V]>): Map<K, V>;
  132. prototype: Map<any, any>;
  133. }
  134. declare var Map: MapConstructor;
  135. interface Set<T> {
  136. add(value: T): Set<T>;
  137. clear(): void;
  138. delete(value: T): boolean;
  139. entries(): IterableIterator<[T, T]>;
  140. forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
  141. has(value: T): boolean;
  142. keys(): IterableIterator<T>;
  143. size: number;
  144. values(): IterableIterator<T>;
  145. [Symbol.iterator]():IterableIterator<T>;
  146. [Symbol.toStringTag]: string;
  147. }
  148. interface SetConstructor {
  149. new <T>(): Set<T>;
  150. new <T>(iterable: Iterable<T>): Set<T>;
  151. prototype: Set<any>;
  152. }
  153. declare var Set: SetConstructor;
  154. interface WeakSet<T> {
  155. add(value: T): WeakSet<T>;
  156. clear(): void;
  157. delete(value: T): boolean;
  158. has(value: T): boolean;
  159. [Symbol.toStringTag]: string;
  160. }
  161. interface WeakSetConstructor {
  162. new <T>(): WeakSet<T>;
  163. new <T>(iterable: Iterable<T>): WeakSet<T>;
  164. prototype: WeakSet<any>;
  165. }
  166. declare var WeakSet: WeakSetConstructor;