Commit graph

369 commits

Author SHA1 Message Date
Joshua Appelman
9864ba4581 Bumps the number of dependants to 1700. 2014-08-30 23:05:34 +02:00
Joshua Appelman
410bd76ad3 Linewraps at 80 where markdown syntax allows. 2014-08-30 22:53:00 +02:00
Joshua Appelman
75f63a837a Updates documentation regarding style application order. 2014-08-22 21:47:59 +02:00
Sindre Sorhus
831ee826d5 Merge pull request #43 from jbnicolai/fix/issue-41
Reverses application of styles, now left-to-right
2014-08-22 21:41:53 +02: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
Sindre Sorhus
bc4f81d352 bump deps 2014-08-13 21:32:50 +02:00
Joshua Appelman
03b92b1bb8 Bumps escape-string-regexp to 1.0.1, slight speed improvement. 2014-07-12 02:38:57 +02:00
Joshua Appelman
994758f012 0.5.1 2014-07-09 22:25:13 +02:00
Joshua Appelman
ca250abed2 Merge pull request #33 from seanmonstar/_styles
fix caching of styles, fixes #32
2014-07-09 21:45:30 +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
3073fa3110 0.5.0 2014-07-04 23:24:19 +02:00
Sindre Sorhus
af175295fb use rawgithub to workaround npm website bug with relative image paths 2014-07-04 23:23:45 +02:00
Sindre Sorhus
3ab833de62 bench - increase iterations for more reliable results 2014-07-04 22:32:23 +02:00
Sindre Sorhus
d255f42a9e bench - minor code style tweaks 2014-07-04 22:29:02 +02:00
Sindre Sorhus
0dde0473e0 add benchmark to package.json
run with `npm run bench`
2014-07-04 22:28:30 +02:00
Joshua Appelman
2b859bb975 Adds performance to readme. 2014-07-04 21:30:02 +02:00
Joshua Appelman
3026d71e0e Adds benchmarking using matcha.
Run through:
```shell
./node_modules/matcha/bin/matcha benchmark.js
```

Results against current HEAD:
```shell
1,863,195 op/s » add colour
2,215,812 op/s » add several styles
  323,213 op/s » add nested styles
```

Results against the latest revision before optiziations, e122899
```shell
  26,714 op/s » add colour
  26,752 op/s » add several styles
  13,414 op/s » add nested styles
```

Closes #21
2014-07-04 21:30:02 +02:00
Sindre Sorhus
e12289964d use String constructor rather than + for coercion 2014-06-26 15:09:37 +02:00
Joshua Appelman
23eab5cdf4 Merge pull request #28 from jbnicolai/fast-js
Replaces Array.prototype.reduce with an explicit loop for performance.
2014-06-26 14:54:17 +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
Joshua Appelman
c8fe7c3966 Adds myself - jbnicolai - as a contributor. 2014-06-26 08:22:08 +02:00
Sindre Sorhus
d9d6e9d7f4 Update readme.md 2014-06-26 00:18:23 +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
732fb08e2b bump strip-ansi 2014-06-24 21:34:27 +02:00
Sindre Sorhus
90bd6477d6 add .hasColor() method - fixes #23 2014-06-24 21:34:11 +02:00
Sindre Sorhus
eff96c2c15 readme tweaks 2014-06-24 17:23:43 +02:00
Sindre Sorhus
763b167349 refactor and extract the RegExp escaping 2014-06-24 17:13:41 +02:00
Sindre Sorhus
1956792293 Merge pull request #25 from jbnicolai/nested-expressions
Adds support for nested chalk expressions.
2014-06-24 16:26:22 +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
1ec4985bc0 Delete screenshot.png 2014-06-22 01:31:17 +02:00
Sindre Sorhus
144421dc16 has-color => supports-color 2014-06-14 03:49:42 +02:00
Sindre Sorhus
90f012c793 1000+ dependents! ✌⊂(✰‿✰)つ✌ 2014-06-08 01:54:47 +02:00
Sindre Sorhus
cf7eb2d0c7 various tweaks 2014-06-04 01:47:53 +02:00
Sindre Sorhus
fa9bd4ebd9 bump ansi-styles 2014-06-04 01:41:17 +02:00
Sindre Sorhus
90e2260f58 Merge pull request #18 from tunnckoCore/patch-1
update "used by" (number of dependents)
2014-05-18 02:32:55 +02:00
Charlike Mike Reagent
449fa45b40 update "used by" (number of dependents) 2014-05-18 03:30:42 +03:00
Sindre Sorhus
d5d08a0995 Update readme.md 2014-04-03 22:57:06 +02:00
Sindre Sorhus
af4983c011 bump strip-ansi 2014-03-26 16:37:06 +01:00
Sindre Sorhus
d992309621 Update readme.md 2014-02-11 20:35:55 +01:00
Sindre Sorhus
ebf961e585 yay 2014-01-11 22:19:36 +01:00
Sindre Sorhus
13a555ede8 readme - add string substitution example
Fixes #8
2013-12-16 21:44:25 +01:00
Sindre Sorhus
b0addb86d6 Update index.js 2013-12-16 19:25:01 +01:00
Sindre Sorhus
0a33a270b1 0.4.0 2013-12-13 20:30:27 +01:00
Sindre Sorhus
d30fd3c3bd improve package.json 2013-12-13 20:27:10 +01:00
Sindre Sorhus
d2a1052042 use index.js 2013-12-13 20:22:40 +01:00
Sindre Sorhus
342686202d Improve docs 2013-12-13 20:21:51 +01:00
Sindre Sorhus
639f6b95cb simplify logic 2013-12-13 19:54:22 +01:00
Sindre Sorhus
fc53420ae4 Update readme.md 2013-12-13 19:53:00 +01:00