factor out tuple logic into from-tuple.ts
This commit is contained in:
parent
4e592fb1c9
commit
86a693b182
6 changed files with 33 additions and 12 deletions
7
packages/backend/src/misc/from-tuple.ts
Normal file
7
packages/backend/src/misc/from-tuple.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export function fromTuple<T>(value: T | [T]): T {
|
||||
if (Array.isArray(value)) {
|
||||
return value[0];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue