lib.esnext.collection.d.ts (3878B)
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 7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 10 MERCHANTABLITY OR NON-INFRINGEMENT. 11 12 See the Apache Version 2.0 License for specific language governing permissions 13 and limitations under the License. 14 ***************************************************************************** */ 15 16 17 /// <reference no-default-lib="true"/> 18 19 /// <reference lib="es2024.collection" /> 20 21 interface ReadonlySetLike<T> { 22 /** 23 * Despite its name, returns an iterator of the values in the set-like. 24 */ 25 keys(): Iterator<T>; 26 /** 27 * @returns a boolean indicating whether an element with the specified value exists in the set-like or not. 28 */ 29 has(value: T): boolean; 30 /** 31 * @returns the number of (unique) elements in the set-like. 32 */ 33 readonly size: number; 34 } 35 36 interface Set<T> { 37 /** 38 * @returns a new Set containing all the elements in this Set and also all the elements in the argument. 39 */ 40 union<U>(other: ReadonlySetLike<U>): Set<T | U>; 41 /** 42 * @returns a new Set containing all the elements which are both in this Set and in the argument. 43 */ 44 intersection<U>(other: ReadonlySetLike<U>): Set<T & U>; 45 /** 46 * @returns a new Set containing all the elements in this Set which are not also in the argument. 47 */ 48 difference<U>(other: ReadonlySetLike<U>): Set<T>; 49 /** 50 * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. 51 */ 52 symmetricDifference<U>(other: ReadonlySetLike<U>): Set<T | U>; 53 /** 54 * @returns a boolean indicating whether all the elements in this Set are also in the argument. 55 */ 56 isSubsetOf(other: ReadonlySetLike<unknown>): boolean; 57 /** 58 * @returns a boolean indicating whether all the elements in the argument are also in this Set. 59 */ 60 isSupersetOf(other: ReadonlySetLike<unknown>): boolean; 61 /** 62 * @returns a boolean indicating whether this Set has no elements in common with the argument. 63 */ 64 isDisjointFrom(other: ReadonlySetLike<unknown>): boolean; 65 } 66 67 interface ReadonlySet<T> { 68 /** 69 * @returns a new Set containing all the elements in this Set and also all the elements in the argument. 70 */ 71 union<U>(other: ReadonlySetLike<U>): Set<T | U>; 72 /** 73 * @returns a new Set containing all the elements which are both in this Set and in the argument. 74 */ 75 intersection<U>(other: ReadonlySetLike<U>): Set<T & U>; 76 /** 77 * @returns a new Set containing all the elements in this Set which are not also in the argument. 78 */ 79 difference<U>(other: ReadonlySetLike<U>): Set<T>; 80 /** 81 * @returns a new Set containing all the elements which are in either this Set or in the argument, but not in both. 82 */ 83 symmetricDifference<U>(other: ReadonlySetLike<U>): Set<T | U>; 84 /** 85 * @returns a boolean indicating whether all the elements in this Set are also in the argument. 86 */ 87 isSubsetOf(other: ReadonlySetLike<unknown>): boolean; 88 /** 89 * @returns a boolean indicating whether all the elements in the argument are also in this Set. 90 */ 91 isSupersetOf(other: ReadonlySetLike<unknown>): boolean; 92 /** 93 * @returns a boolean indicating whether this Set has no elements in common with the argument. 94 */ 95 isDisjointFrom(other: ReadonlySetLike<unknown>): boolean; 96 }