Skip to content

consoleLogPromise

Returns a function that logs data to the console and passes it through.

Available since v1.0.0

import { consoleLogPromise } from '@helpers4/promise';
consoleLogPromise<T>(prefix?: string): function
ParameterTypeDescription
prefixstringOptional prefix for the console log (optional)

function — A function that logs and returns the data

Creates a function that logs data with an optional prefix and returns it unchanged.

Promise.resolve(42).then(consoleLogPromise('value:'))
// logs "value: 42" and resolves with 42

View source on GitHub