Co-authored-by: Liyas Thomas <hi@liyasthomas.com> Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com> Co-authored-by: liyasthomas <liyascthomas@gmail.com> Co-authored-by: Rishabh Agarwal <45998880+RishabhAgarwal-2001@users.noreply.github.com>
23 lines
504 B
TypeScript
23 lines
504 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
|
|
}
|