Skip to content

consoleLogPromise

Generates a .then() interceptor that logs the resolved value to the console without altering it.

Available since v1.0.1

import { consoleLogPromise } from '@helpers4/promise';
consoleLogPromise<T>(prefix?: string): (data: T) => T
ParameterTypeDescription
prefixstringOptional. Prefixes the logged value in the console.

(data: T) => T — A .then() interceptor: logs prefix, data to the console, then returns data unchanged.

import { consoleLogPromise } from '@helpers4/promise';

Promise.resolve(42).then(consoleLogPromise('The answer:'));
// => 'The answer:', 42

View on npm