Skip to content

Commit

Permalink
Merge pull request #4 from chalk/main
Browse files Browse the repository at this point in the history
[pull] main from chalk:main
  • Loading branch information
devkadirselcuk committed Jul 16, 2021
2 parents e6d3ad6 + b68c8b5 commit 3103722
Show file tree
Hide file tree
Showing 22 changed files with 481 additions and 589 deletions.
2 changes: 1 addition & 1 deletion .github/funding.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github: [sindresorhus,Qix-]
github: [sindresorhus, Qix-]
open_collective: sindresorhus
tidelift: npm/chalk
custom: https://sindresorhus.com/donate
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ jobs:
node-version:
- 14
- 12
- 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
3 changes: 1 addition & 2 deletions benchmark.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* globals suite, bench */
'use strict';
const chalk = require('.');
import chalk from './index.js';

suite('chalk', () => {
const chalkRed = chalk.red;
Expand Down
19 changes: 8 additions & 11 deletions examples/rainbow.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict';
const chalk = require('..');
import chalk from '../source/index.js';
import convertColor from 'color-convert';
import updateLog from 'log-update';
import delay from 'yoctodelay';

const ignoreChars = /[^!-~]/g;

const delay = milliseconds => new Promise(resolve => {
setTimeout(resolve, milliseconds);
});

function rainbow(string, offset) {
if (!string || string.length === 0) {
return string;
Expand All @@ -17,10 +15,10 @@ function rainbow(string, offset) {
let hue = offset % 360;
const characters = [];
for (const character of string) {
if (character.match(ignoreChars)) {
if (ignoreChars.test(character)) {
characters.push(character);
} else {
characters.push(chalk.hsl(hue, 100, 50)(character));
characters.push(chalk.hex(convertColor.hsl.hex(hue, 100, 50))(character));
hue = (hue + hueStep) % 360;
}
}
Expand All @@ -29,9 +27,8 @@ function rainbow(string, offset) {
}

async function animateString(string) {
console.log();
for (let i = 0; i < 360 * 5; i++) {
console.log('\u001B[1F\u001B[G', rainbow(string, i));
for (let index = 0; index < 360 * 5; index++) {
updateLog(rainbow(string, index));
await delay(2); // eslint-disable-line no-await-in-loop
}
}
Expand Down
5 changes: 2 additions & 3 deletions examples/screenshot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';
const styles = require('ansi-styles');
const chalk = require('..');
import styles from 'ansi-styles';
import chalk from '../source/index.js';

// Generates screenshot
for (const key of Object.keys(styles)) {
Expand Down
Loading

0 comments on commit 3103722

Please sign in to comment.