es6-collections.d.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Type definitions for es6-collections v0.5.1
  2. // Project: https://github.com/WebReflection/es6-collections/
  3. // Definitions by: Ron Buckton <http://github.com/rbuckton>
  4. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  5. /* *****************************************************************************
  6. Copyright (c) Microsoft Corporation. All rights reserved.
  7. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  8. this file except in compliance with the License. You may obtain a copy of the
  9. License at http://www.apache.org/licenses/LICENSE-2.0
  10. THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  11. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  12. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  13. MERCHANTABLITY OR NON-INFRINGEMENT.
  14. See the Apache Version 2.0 License for specific language governing permissions
  15. and limitations under the License.
  16. ***************************************************************************** */
  17. interface IteratorResult<T> {
  18. done: boolean;
  19. value?: T;
  20. }
  21. interface Iterator<T> {
  22. next(value?: any): IteratorResult<T>;
  23. return?(value?: any): IteratorResult<T>;
  24. throw?(e?: any): IteratorResult<T>;
  25. }
  26. interface ForEachable<T> {
  27. forEach(callbackfn: (value: T) => void): void;
  28. }
  29. interface Map<K, V> {
  30. clear(): void;
  31. delete(key: K): boolean;
  32. forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
  33. get(key: K): V;
  34. has(key: K): boolean;
  35. set(key: K, value?: V): Map<K, V>;
  36. entries(): Iterator<[K, V]>;
  37. keys(): Iterator<K>;
  38. values(): Iterator<V>;
  39. size: number;
  40. }
  41. interface MapConstructor {
  42. new <K, V>(): Map<K, V>;
  43. new <K, V>(iterable: ForEachable<[K, V]>): Map<K, V>;
  44. prototype: Map<any, any>;
  45. }
  46. declare var Map: MapConstructor;
  47. interface Set<T> {
  48. add(value: T): Set<T>;
  49. clear(): void;
  50. delete(value: T): boolean;
  51. forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
  52. has(value: T): boolean;
  53. entries(): Iterator<[T, T]>;
  54. keys(): Iterator<T>;
  55. values(): Iterator<T>;
  56. size: number;
  57. }
  58. interface SetConstructor {
  59. new <T>(): Set<T>;
  60. new <T>(iterable: ForEachable<T>): Set<T>;
  61. prototype: Set<any>;
  62. }
  63. declare var Set: SetConstructor;
  64. interface WeakMap<K, V> {
  65. delete(key: K): boolean;
  66. clear(): void;
  67. get(key: K): V;
  68. has(key: K): boolean;
  69. set(key: K, value?: V): WeakMap<K, V>;
  70. }
  71. interface WeakMapConstructor {
  72. new <K, V>(): WeakMap<K, V>;
  73. new <K, V>(iterable: ForEachable<[K, V]>): WeakMap<K, V>;
  74. prototype: WeakMap<any, any>;
  75. }
  76. declare var WeakMap: WeakMapConstructor;
  77. interface WeakSet<T> {
  78. delete(value: T): boolean;
  79. clear(): void;
  80. add(value: T): WeakSet<T>;
  81. has(value: T): boolean;
  82. }
  83. interface WeakSetConstructor {
  84. new <T>(): WeakSet<T>;
  85. new <T>(iterable: ForEachable<T>): WeakSet<T>;
  86. prototype: WeakSet<any>;
  87. }
  88. declare var WeakSet: WeakSetConstructor;
  89. declare module "es6-collections" {
  90. var Map: MapConstructor;
  91. var Set: SetConstructor;
  92. var WeakMap: WeakMapConstructor;
  93. var WeakSet: WeakSetConstructor;
  94. }