lib.es2015.collection.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. interface Map<K, V> {
  15. clear(): void;
  16. /**
  17. * @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
  18. */
  19. delete(key: K): boolean;
  20. /**
  21. * Executes a provided function once per each key/value pair in the Map, in insertion order.
  22. */
  23. forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
  24. /**
  25. * Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
  26. * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
  27. */
  28. get(key: K): V | undefined;
  29. /**
  30. * @returns boolean indicating whether an element with the specified key exists or not.
  31. */
  32. has(key: K): boolean;
  33. /**
  34. * Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
  35. */
  36. set(key: K, value: V): this;
  37. /**
  38. * @returns the number of elements in the Map.
  39. */
  40. readonly size: number;
  41. }
  42. interface MapConstructor {
  43. new (): Map<any, any>;
  44. new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
  45. readonly prototype: Map<any, any>;
  46. }
  47. declare var Map: MapConstructor;
  48. interface ReadonlyMap<K, V> {
  49. forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
  50. get(key: K): V | undefined;
  51. has(key: K): boolean;
  52. readonly size: number;
  53. }
  54. interface WeakMap<K extends WeakKey, V> {
  55. /**
  56. * Removes the specified element from the WeakMap.
  57. * @returns true if the element was successfully removed, or false if it was not present.
  58. */
  59. delete(key: K): boolean;
  60. /**
  61. * @returns a specified element.
  62. */
  63. get(key: K): V | undefined;
  64. /**
  65. * @returns a boolean indicating whether an element with the specified key exists or not.
  66. */
  67. has(key: K): boolean;
  68. /**
  69. * Adds a new element with a specified key and value.
  70. * @param key Must be an object or symbol.
  71. */
  72. set(key: K, value: V): this;
  73. }
  74. interface WeakMapConstructor {
  75. new <K extends WeakKey = WeakKey, V = any>(entries?: readonly (readonly [K, V])[] | null): WeakMap<K, V>;
  76. readonly prototype: WeakMap<WeakKey, any>;
  77. }
  78. declare var WeakMap: WeakMapConstructor;
  79. interface Set<T> {
  80. /**
  81. * Appends a new element with a specified value to the end of the Set.
  82. */
  83. add(value: T): this;
  84. clear(): void;
  85. /**
  86. * Removes a specified value from the Set.
  87. * @returns Returns true if an element in the Set existed and has been removed, or false if the element does not exist.
  88. */
  89. delete(value: T): boolean;
  90. /**
  91. * Executes a provided function once per each value in the Set object, in insertion order.
  92. */
  93. forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
  94. /**
  95. * @returns a boolean indicating whether an element with the specified value exists in the Set or not.
  96. */
  97. has(value: T): boolean;
  98. /**
  99. * @returns the number of (unique) elements in Set.
  100. */
  101. readonly size: number;
  102. }
  103. interface SetConstructor {
  104. new <T = any>(values?: readonly T[] | null): Set<T>;
  105. readonly prototype: Set<any>;
  106. }
  107. declare var Set: SetConstructor;
  108. interface ReadonlySet<T> {
  109. forEach(callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void, thisArg?: any): void;
  110. has(value: T): boolean;
  111. readonly size: number;
  112. }
  113. interface WeakSet<T extends WeakKey> {
  114. /**
  115. * Appends a new value to the end of the WeakSet.
  116. */
  117. add(value: T): this;
  118. /**
  119. * Removes the specified element from the WeakSet.
  120. * @returns Returns true if the element existed and has been removed, or false if the element does not exist.
  121. */
  122. delete(value: T): boolean;
  123. /**
  124. * @returns a boolean indicating whether a value exists in the WeakSet or not.
  125. */
  126. has(value: T): boolean;
  127. }
  128. interface WeakSetConstructor {
  129. new <T extends WeakKey = WeakKey>(values?: readonly T[] | null): WeakSet<T>;
  130. readonly prototype: WeakSet<WeakKey>;
  131. }
  132. declare var WeakSet: WeakSetConstructor;