* Fix XO linting and update some dev dependencies
Fixes#275
* Add some badges to the readme
* Tiny travis.yml tweak
* Require Node.js 6
* Validate the `level` option
Fixes#248
* Add failing test for #234 (#235)
* Add type definitions badge (#286)
* Add Tidelift mention in the readme
* Replace RawGit URL
Fixes#305
* Fix ignore chars regex flags in rainbow example (#306)
Use global matches rather than stopping after the first match.
* Strict mode in Flow definition (#309)
* Add security section
* Add docs comments and tests for TypeScript definitions (#299)
Fixes#293
* Update dependencies and meta tweaks
* Type definition improvements
* Enforce `chalk.constructor` to be called with `new` in TypeScript
* Add extra level/enabled property info in the readme (#308)
* Code style tweaks
* Change tagged template literal argument type to accept `unknown` instead of just `string` (#316)
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
- 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
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.