Cookbook: Utilities

1. Logging Consumers

{utilities.js 1}
export function logConsumer(message, consumer) {
  return (s, a) => {
    const ret = consumer(s, a);
    // eslint-disable-next-line no-console
    console.log(message, ret);
    return ret;
  };
}

Added to in section 2

2. Debugging consumers

{utilities.js 1} +=
export function debugConsumer(consumer) {
  return (s, a) => {
    // eslint-disable-next-line no-debugger
    debugger;
    return consumer(s, a);
  };
}

Previous ChapterNext Chapter