lib.esnext.collection.d.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 MapConstructor {
  15. /**
  16. * Groups members of an iterable according to the return value of the passed callback.
  17. * @param items An iterable.
  18. * @param keySelector A callback which will be invoked for each item in items.
  19. */
  20. groupBy<K, T>(
  21. items: Iterable<T>,
  22. keySelector: (item: T, index: number) => K,
  23. ): Map<K, T[]>;
  24. }
  25. interface ReadonlySetLike<T> {
  26. /**
  27. * Despite its name, returns an iterator of the values in the set-like.
  28. */
  29. keys(): Iterator<T>;
  30. /**
  31. * @returns a boolean indicating whether an element with the specified value exists in the set-like or not.
  32. */
  33. has(value: T): boolean;
  34. /**
  35. * @returns the number of (unique) elements in the set-like.
  36. */
  37. readonly size: number;
  38. }
  39. interface Set<T> {
  40. /**
  41. * @returns a new Set containing all the elements in this Set and also all the elements in the argument.
  42. */
  43. union<U>(other: ReadonlySetLike<U>): Set<T | U>;
  44. /**
  45. * @returns a new Set containing all the elements which are both in this Set and in the argument.
  46. */
  47. intersection<U>(other: ReadonlySetLike<U>): Set<T & U>;
  48. /**
  49. * @returns a new Set containing all the elements in this Set which are not also in the argument.
  50. */
  51. difference<U>(other: ReadonlySetLike<U>): Set<T>;
  52. /**
  53. * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both.
  54. */
  55. symmetricDifference<U>(other: ReadonlySetLike<U>): Set<T | U>;
  56. /**
  57. * @returns a boolean indicating whether all the elements in this Set are also in the argument.
  58. */
  59. isSubsetOf(other: ReadonlySetLike<unknown>): boolean;
  60. /**
  61. * @returns a boolean indicating whether all the elements in the argument are also in this Set.
  62. */
  63. isSupersetOf(other: ReadonlySetLike<unknown>): boolean;
  64. /**
  65. * @returns a boolean indicating whether this Set has no elements in common with the argument.
  66. */
  67. isDisjointFrom(other: ReadonlySetLike<unknown>): boolean;
  68. }
  69. interface ReadonlySet<T> {
  70. /**
  71. * @returns a new Set containing all the elements in this Set and also all the elements in the argument.
  72. */
  73. union<U>(other: ReadonlySetLike<U>): Set<T | U>;
  74. /**
  75. * @returns a new Set containing all the elements which are both in this Set and in the argument.
  76. */
  77. intersection<U>(other: ReadonlySetLike<U>): Set<T & U>;
  78. /**
  79. * @returns a new Set containing all the elements in this Set which are not also in the argument.
  80. */
  81. difference<U>(other: ReadonlySetLike<U>): Set<T>;
  82. /**
  83. * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both.
  84. */
  85. symmetricDifference<U>(other: ReadonlySetLike<U>): Set<T | U>;
  86. /**
  87. * @returns a boolean indicating whether all the elements in this Set are also in the argument.
  88. */
  89. isSubsetOf(other: ReadonlySetLike<unknown>): boolean;
  90. /**
  91. * @returns a boolean indicating whether all the elements in the argument are also in this Set.
  92. */
  93. isSupersetOf(other: ReadonlySetLike<unknown>): boolean;
  94. /**
  95. * @returns a boolean indicating whether this Set has no elements in common with the argument.
  96. */
  97. isDisjointFrom(other: ReadonlySetLike<unknown>): boolean;
  98. }