debug.ts 503 B

12345678910111213141516171819202122
  1. /**
  2. * Logs the current value and returns the same value
  3. * @param x The value to log
  4. * @returns The parameter `x` passed to this
  5. */
  6. export const trace = <T>(x: T) => {
  7. console.log(x)
  8. return x
  9. }
  10. /**
  11. * Logs the annotated current value and returns the same value
  12. * @param name The name of the log
  13. * @curried_param `x` The value to log
  14. * @returns The parameter `x` passed to this
  15. */
  16. export const namedTrace =
  17. (name: string) =>
  18. <T>(x: T) => {
  19. console.log(`${name}:`, x)
  20. return x
  21. }