Files
hoppscotch/packages/hoppscotch-app/helpers/functional/debug.ts
2022-05-27 14:48:33 +05:30

23 lines
503 B
TypeScript

/**
* Logs the current value and returns the same value
* @param x The value to log
* @returns The parameter `x` passed to this
*/
export const trace = <T>(x: T) => {
console.log(x)
return x
}
/**
* Logs the annotated current value and returns the same value
* @param name The name of the log
* @curried_param `x` The value to log
* @returns The parameter `x` passed to this
*/
export const namedTrace =
(name: string) =>
<T>(x: T) => {
console.log(`${name}:`, x)
return x
}