| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,14 +3,16 @@ | |||
| 3 | 3 | const common = require('../common.js'); | |
| 4 | 4 | ||
| 5 | 5 | const { styleText } = require('node:util'); | |
| 6 | + const assert = require('node:assert'); | ||
| 6 | 7 | ||
| 7 | 8 | const bench = common.createBenchmark(main, { | |
| 8 | 9 | messageType: ['string', 'number', 'boolean', 'invalid'], | |
| 9 | 10 | format: ['red', 'italic', 'invalid'], | |
| 11 | + validateStream: [1, 0], | ||
| 10 | 12 | n: [1e3], | |
| 11 | 13 | }); | |
| 12 | 14 | ||
| 13 | - function main({ messageType, format, n }) { | ||
| 15 | + function main({ messageType, format, validateStream, n }) { | ||
| 14 | 16 | let str; | |
| 15 | 17 | switch (messageType) { | |
| 16 | 18 | case 'string': | |
@@ -29,8 +31,10 @@ function main({ messageType, format, n }) { | |||
| 29 | 31 | ||
| 30 | 32 | bench.start(); | |
| 31 | 33 | for (let i = 0; i < n; i++) { | |
| 34 | + let colored = ''; | ||
| 32 | 35 | try { | |
| 33 | - styleText(format, str); | ||
| 36 | + colored = styleText(format, str, { validateStream }); | ||
| 37 | + assert.ok(colored); // Attempt to avoid dead-code elimination | ||
| 34 | 38 | } catch { | |
| 35 | 39 | // eslint-disable no-empty | |
| 36 | 40 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments