From 5c6aa86bbde6f5ba101de877b34aedc7390bf257 Mon Sep 17 00:00:00 2001 From: griest024 Date: Mon, 13 May 2024 14:50:00 -0400 Subject: [PATCH] feat(core): add `identity` function (#2785) --- libs/core/src/utils/identity.ts | 7 +++++++ libs/core/src/utils/public_api.ts | 1 + 2 files changed, 8 insertions(+) create mode 100644 libs/core/src/utils/identity.ts diff --git a/libs/core/src/utils/identity.ts b/libs/core/src/utils/identity.ts new file mode 100644 index 0000000000..c38836ebf5 --- /dev/null +++ b/libs/core/src/utils/identity.ts @@ -0,0 +1,7 @@ +/** + * The unary identity function. + * Returns whatever is passed to it. + */ +export function identity(v: T): T { + return v; +} diff --git a/libs/core/src/utils/public_api.ts b/libs/core/src/utils/public_api.ts index 3346d7c3fe..20d8f96dcd 100644 --- a/libs/core/src/utils/public_api.ts +++ b/libs/core/src/utils/public_api.ts @@ -12,3 +12,4 @@ export { shallowCompare } from './shallow-compare'; export { shuffle } from './shuffle'; export { unique } from './unique'; export * from './long-arithmetic'; +export * from './identity';