Commit graph

50 commits

Author SHA1 Message Date
Sindre Sorhus
0307f263cb Require Node.js 6 2018-09-18 14:32:14 +07:00
Kayla Washburn
678152cf19 Update chalk to use the latest updates to supports-color (#247) 2018-02-11 16:59:24 +07:00
Josh Junon
e2a4aa4275 fix .visible when called after .enable is set to false 2017-10-23 20:12:34 -07:00
Danny Kirchmeier
dc092b4a5f Add .visible for emitting text only when enabled (fixes #192) 2017-10-23 19:44:46 -07:00
calebboyd
f653b061d6 Add TypeScript definitions (#207) 2017-10-18 10:10:43 +07:00
Josh Junon
69ac663f29 Fix undefined and null interpolated expressions (fixes #194) 2017-08-06 18:58:17 -07:00
Josh Junon
f0c0178d12 Allow multiple arguments in base chalk object (fixes #187) 2017-08-06 18:58:17 -07:00
Josh Junon
0827d3b632 Fix level when supportsColor returns falsey (fixes #176, #175) 2017-08-06 18:58:17 -07:00
Josh Junon
fbd17e7a69 Escape backslashes in template arguments (fixes #177) 2017-08-06 18:58:17 -07:00
Kevin Mårtensson
e8d28f3041 Return empty string when there are no arguments (#183) 2017-07-23 22:13:55 +02:00
Sindre Sorhus
3d10f8fad7 Code style tweaks 2017-06-30 12:42:24 +02:00
Josh Junon
caeb7d8dca fix missing TERM cases 2017-06-29 20:11:09 -07:00
Josh Junon
f66271e01a Add tagged template literal (#163) 2017-06-30 01:46:19 +02:00
Josh Junon
09fb2d8606 Re-implement chalk.enabled (#160) 2017-06-29 22:34:00 +02:00
Sindre Sorhus
870249689a Remove chalk.styles
Very few consumers use this. Those who need it can just use the `ansi-styles` package directly.
2017-06-20 21:37:29 +02:00
Sindre Sorhus
0412cdf07b Minor code improvements 2017-06-20 21:17:16 +02:00
Sindre Sorhus
249b9ac7e7 ES2015ify the codebase 2017-06-20 19:21:14 +02:00
Josh Junon
cb3f2308e1 Add RGB (256/Truecolor) support (#140) 2017-06-20 19:02:09 +02:00
Josh
0d2144904b check parent builder object for enabled status (#142) 2017-01-30 04:10:02 -05:00
Sindre Sorhus
4ce73b632b make XO happy 2016-10-17 23:50:22 +07:00
Sindre Sorhus
d939a3f9bc fix XO lint issue 2016-06-16 14:36:05 +02:00
Sindre Sorhus
a125eb0e72 OS X → macOS 2016-06-14 18:20:49 +02:00
Sindre Sorhus
18c64ad7ba cleanup #92 2016-01-17 12:38:10 +01:00
Martin Heidegger
05f87e25e1 Close #92 PR: Closing before and reopening the style after a line break. 2016-01-17 12:35:27 +01:00
Steve Mao
8417f175ab Close #95 PR: tweak defining proto. 2016-01-09 16:20:22 +01:00
vdemedes
04cae226cc remove has-ansi and strip-ansi dependencies 2015-12-12 23:55:01 +01:00
Sindre Sorhus
409f95eef5 add XO
https://github.com/sindresorhus/xo
2015-08-20 03:05:43 +07:00
Luke Page
4006cc0b41 Remove un-necessary function name. Fixes #80 2015-08-19 16:57:06 +01:00
Joshua Appelman
922ac4b0aa Makes dim when gray a noop on windows terminals.
Fixes #58
2015-07-01 04:11:18 +02:00
Joshua Appelman
dde7287192 Removes needless "|| ''". 2015-07-01 01:59:47 +02:00
Sindre Sorhus
c63e95c58b code style 2015-06-30 18:05:11 +02:00
Wei Kin Huang
e3272e8449 Close #60 PR: Don't override windows blue when in xterm mode. Fixes #59 2015-04-26 16:00:01 +07:00
Sindre Sorhus
99614e760f ternarify 2015-02-17 15:24:13 +07:00
David Keijser
72d1c11e43 Close #54 PR: export classy chalk object to create isolated ctx. Fixes #46, Fixes #46 2015-02-17 15:18:18 +07:00
Sindre Sorhus
fc6a9b27dc force blue color to be use bright blue on Windows - fixes #36
as the normal blue color is illegible
2014-12-05 16:27:16 +07:00
Sindre Sorhus
21143174c4 bump ansi-styles
the gray alias is now in ansi-styles
2014-11-23 18:56:00 +07:00
Joshua Appelman
0234fe987d Reverses application of styles, now left-to-right
The styles' application order used to to be right-to-left e.g.:
```javascript
console.log(chalk.red.reset.blue('something'))
// red
```

Where now it has been reversed. E.g.:
```javascript
console.log(chalk.red.reset.blue('something'))
// blue
```

It seems to me that this is the more intuitive application order.

Closes #41
2014-08-22 21:28:38 +02:00
Sean McArthur
7ef6f4c48a dont use slice on arguments
~21% increase with multiple arguments
2014-07-09 10:56:43 -07:00
Sean McArthur
42918337e5 return a new function for each getter
- defines the getters onto a proto
- the function returned has its __proto__ set to our proto

fixes #32
2014-07-09 10:54:59 -07:00
Sindre Sorhus
e12289964d use String constructor rather than + for coercion 2014-06-26 15:09:37 +02:00
Joshua Appelman
580fe4d718 Replaces Array.prototype.reduce with a for loop.
As this is possibly the hottest code path, this speeds up average total
execution time with about 25%, benchmarking shows.
2014-06-26 14:49:03 +02:00
Sindre Sorhus
135852fd92 Merge pull request #27 from jbnicolai/optimize
Performance optimizations (ca. Factor 75)
2014-06-26 00:05:05 +02:00
Joshua Appelman
b0523a4438 Performance optimizations (ca. Factor 75)
- Precomputed style function
- Skip arguments to array + join if there's only one argument (the
  common case)
- Merge multiple return statements to one

To calculate the performance benefit:

```javascript
var chalk = require('./index.js');
console.time('100000 iterations');
for (var i = 0; i < 100000; i++) {
	chalk.red('A string that is about 80 characters long (normal use I think?)');
}
console.timeEnd('100000 iterations');
```

Running this before this commit:
```shell
for i in {1..5}; do node time.js; done
100000 iterations: 19485ms
100000 iterations: 18933ms
100000 iterations: 19365ms
100000 iterations: 19332ms
100000 iterations: 18660ms
```

After:
```shell
100000 iterations: 268ms
100000 iterations: 261ms
100000 iterations: 264ms
100000 iterations: 259ms
100000 iterations: 254ms
```

Performance gain, taking the middle result of both:
```shell
19332 / 261 = 74.~
```

Closes #16
2014-06-26 00:01:20 +02:00
Sindre Sorhus
90bd6477d6 add .hasColor() method - fixes #23 2014-06-24 21:34:11 +02:00
Sindre Sorhus
763b167349 refactor and extract the RegExp escaping 2014-06-24 17:13:41 +02:00
Joshua Appelman
d16b0ce367 Adds support for nested chalk expressions.
green(a + blue(b) + c) will now look the same as green(a) +
blue(b) + green(c), as expected. In the previous implementation the
output would have been green(a) + blue(b) + c, because the reset code of
the second expression would close all expressions around it as well.

Now this reset code is replaced by a start code of the outer lying
expression, both stopping the inner and re-starting the outer.
2014-06-23 13:25:47 +02:00
Sindre Sorhus
144421dc16 has-color => supports-color 2014-06-14 03:49:42 +02:00
Sindre Sorhus
cf7eb2d0c7 various tweaks 2014-06-04 01:47:53 +02:00
Sindre Sorhus
b0addb86d6 Update index.js 2013-12-16 19:25:01 +01:00
Sindre Sorhus
d2a1052042 use index.js 2013-12-13 20:22:40 +01:00
Renamed from chalk.js (Browse further)