-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
78254b4
commit 6c57821
Showing
5 changed files
with
61 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,26 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
|
||
|
||
## identity variable | ||
|
||
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment. | ||
> | ||
Return the parameter supplied to it. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
identity: <T>(val: T) => T | ||
``` | ||
|
||
## Example | ||
|
||
|
||
```ts | ||
identity(1) // 1 | ||
identity({}) // {} | ||
|
||
``` | ||
|
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
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,17 @@ | ||
/** | ||
* Return the parameter supplied to it. | ||
* | ||
* @param val - The value to return | ||
* @returns The result of `val` | ||
* | ||
* @example | ||
* ```ts | ||
* identity(1) // 1 | ||
* identity({}) // {} | ||
* ``` | ||
* | ||
* @beta | ||
*/ | ||
const identity = <T>(val: T): T => val | ||
|
||
export { identity } |
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
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,16 @@ | ||
import { identity } from '@/identity' | ||
|
||
describe('identity', () => { | ||
const table: [unknown, unknown][] = [ | ||
['', ''], | ||
[0, 0], | ||
[1n, 1n], | ||
[() => 1, () => 1], | ||
[{}, {}], | ||
[[], []] | ||
] | ||
|
||
it.each(table)('identity(%s) -> %s', (val) => { | ||
expect(identity(val)).toEqual(val) | ||
}) | ||
}) |