Files
hoppscotch/packages/hoppscotch-app/helpers/functional/record.ts
liyasthomas b57b948107 fix: urlencoded formdata key value params ui
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
2022-01-23 04:45:05 +05:30

10 lines
263 B
TypeScript

export const tupleToRecord = <
KeyType extends string | number | symbol,
ValueType
>(
tuples: [KeyType, ValueType][]
): Record<KeyType, ValueType> =>
tuples.length > 0
? (Object.assign as any)(...tuples.map(([key, val]) => ({ [key]: val })))
: {}