-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# isSet | ||
|
||
주어진 값이 `Set`의 인스턴스인지 확인해요. | ||
|
||
값이 `Set`이면 `true`, 아니면 `false`를 반환해요. | ||
|
||
TypeScript의 타입 가드로 주로 사용되는데요, 파라미터로 주어진 값을 `Set`인 타입으로 좁힐 수 있어요. | ||
|
||
## 인터페이스 | ||
|
||
```typescript | ||
function isSet(value: unknown): value is Set<any>; | ||
``` | ||
|
||
### 파라미터 | ||
|
||
- `value` (`unknown`): `Set`인지 확인할 값. | ||
|
||
### 반환 값 | ||
|
||
(`value is Set<any>`): 값이 `Set`이면 `true`, 아니면 `false`. | ||
|
||
## 예시 | ||
|
||
```typescript | ||
const value1 = new Set(); | ||
const value2 = new Map(); | ||
const value3 = new WeakSet(); | ||
|
||
console.log(isSet(value1)); // true | ||
console.log(isSet(value2)); // false | ||
console.log(isSet(value3)); // false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# isSet | ||
|
||
Checks if the given value is a `Set`. | ||
|
||
This function tests whether the provided value is an instance of `Set`. | ||
It returns `true` if the value is a `Set`, and `false` otherwise. | ||
|
||
This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Set`. | ||
|
||
## Signature | ||
|
||
```typescript | ||
function isSet(value: unknown): value is Set<any>; | ||
``` | ||
|
||
### Parameters | ||
|
||
- `value` (`unknown`): The value to check if it is a `Set`. | ||
|
||
### Returns | ||
|
||
(`value is Set<any>`): true if the value is a `Set`, false otherwise. | ||
|
||
## Examples | ||
|
||
```typescript | ||
const value1 = new Set(); | ||
const value2 = new Map(); | ||
const value3 = new WeakSet(); | ||
|
||
console.log(isSet(value1)); // true | ||
console.log(isSet(value2)); // false | ||
console.log(isSet(value3)); // false | ||
``` |