Skip to content

Function: isSet()

isSet(val): val is Set<unknown>

Type guard to check if a value is a Set instance.

Parameters

val

unknown

The value to check

Returns

val is Set<unknown>

True if the value is a Set

Example

typescript
const value: unknown = new Set([1, 2, 3])

if (isSet(value)) {
  // TypeScript knows value is a Set
  console.log(value.size) // 3
}

Released under the MIT License.