forked from orbit-oss/chalk
Keep function prototype methods (#434)
This commit is contained in:
parent
d798222a5a
commit
0fba91b037
2 changed files with 8 additions and 0 deletions
|
|
@ -54,6 +54,8 @@ function createChalk(options) {
|
|||
return chalkFactory(options);
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
||||
|
||||
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
||||
styles[styleName] = {
|
||||
get() {
|
||||
|
|
|
|||
|
|
@ -117,3 +117,9 @@ test('sets correct level for chalkStderr and respects it', t => {
|
|||
t.is(chalkStderr.level, 3);
|
||||
t.is(chalkStderr.red.bold('foo'), '\u001B[31m\u001B[1mfoo\u001B[22m\u001B[39m');
|
||||
});
|
||||
|
||||
test('keeps function prototype methods', t => {
|
||||
t.is(chalk.apply(chalk, ['foo']), 'foo');
|
||||
t.is(chalk.bind(chalk, 'foo')(), 'foo');
|
||||
t.is(chalk.call(chalk, 'foo'), 'foo');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue