feat: allow quoted key/values for escaping characters and trail/lead whitespaces in raw key value pairs (#2578)
This commit is contained in:
17
packages/hoppscotch-data/src/utils/record.ts
Normal file
17
packages/hoppscotch-data/src/utils/record.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/**
|
||||
* Modify a record value with a mapping function
|
||||
* @param name The key to update
|
||||
* @param func The value to update
|
||||
* @returns The updated record
|
||||
*/
|
||||
export const recordUpdate =
|
||||
<
|
||||
X extends {},
|
||||
K extends keyof X,
|
||||
R
|
||||
>(name: K, func: (input: X[K]) => R) =>
|
||||
(x: X): Omit<X, K> & { [x in K]: R } => ({
|
||||
...x,
|
||||
[name]: func(x[name])
|
||||
})
|
||||
Reference in New Issue
Block a user