medikoo/cli-color

"not a function" error when binding

beether opened this issue · 1 comments

I tried to create a function that returns a function which will log things in color:

const logRed = createLogger(clc.red);
function createLogger(colorizeFn) {
	return function() {
		var args = getArgs(arguments);
		args[0] = colorizeFn(args[0].toString());
		console.log.apply(console.log, args);
	}
}
logRed("sometimes this doesnt work...");

Seemingly randomly, it thinks "colorizeFn" is not a function. What is going on here?

I have tried following:

const clc = require("cli-color");

const logRed = createLogger(clc.red);
function createLogger(colorizeFn) {
	return function() {
		var args = arguments;
		args[0] = colorizeFn(args[0].toString());
		console.log.apply(console, args);
	};
}
logRed("sometimes this doesnt work...");

And it works in all cases for me.

Can you create some reproducible test case, that exposes the problem, you have?

I'm going to close it as there's no proof there's any problem with this module, but let's keep discussion open.