Skip to content

Commit 5f0c047

Browse files
v1.0.1
1 parent a014200 commit 5f0c047

File tree

3 files changed

+37
-29
lines changed

3 files changed

+37
-29
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [v1.0.1](https://github.com/alexeyraspopov/picocolors/releases/tag/v1.0.0)
4+
5+
- Updated color detection mechanism to work properly on Vercel Edge Runtime ([#64](https://github.com/alexeyraspopov/picocolors/pull/64))
6+
- Remove use of recursion to avoid possible stack overflow for very long inputs ([#56](https://github.com/alexeyraspopov/picocolors/pull/56))
7+
38
## [v1.0.0](https://github.com/alexeyraspopov/picocolors/releases/tag/v1.0.0)
49

510
- Removed several code elements to reduce the package size ([#31](https://github.com/alexeyraspopov/picocolors/pull/31))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "picocolors",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"main": "./picocolors.js",
55
"types": "./picocolors.d.ts",
66
"browser": {

picocolors.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,37 @@ let replaceClose = (string, close, replace, index) => {
2929
return result + string.substring(cursor)
3030
}
3131

32-
let createColors = (enabled = isColorSupported) => ({
33-
isColorSupported: enabled,
34-
reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
35-
bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
36-
dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
37-
italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
38-
underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
39-
inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
40-
hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
41-
strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
42-
black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
43-
red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
44-
green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
45-
yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
46-
blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
47-
magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
48-
cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
49-
white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
50-
gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
51-
bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
52-
bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
53-
bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
54-
bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
55-
bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
56-
bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
57-
bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
58-
bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
59-
})
32+
let createColors = (enabled = isColorSupported) => {
33+
let init = enabled ? formatter : () => String
34+
return {
35+
isColorSupported: enabled,
36+
reset: init("\x1b[0m", "\x1b[0m"),
37+
bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
38+
dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
39+
italic: init("\x1b[3m", "\x1b[23m"),
40+
underline: init("\x1b[4m", "\x1b[24m"),
41+
inverse: init("\x1b[7m", "\x1b[27m"),
42+
hidden: init("\x1b[8m", "\x1b[28m"),
43+
strikethrough: init("\x1b[9m", "\x1b[29m"),
44+
black: init("\x1b[30m", "\x1b[39m"),
45+
red: init("\x1b[31m", "\x1b[39m"),
46+
green: init("\x1b[32m", "\x1b[39m"),
47+
yellow: init("\x1b[33m", "\x1b[39m"),
48+
blue: init("\x1b[34m", "\x1b[39m"),
49+
magenta: init("\x1b[35m", "\x1b[39m"),
50+
cyan: init("\x1b[36m", "\x1b[39m"),
51+
white: init("\x1b[37m", "\x1b[39m"),
52+
gray: init("\x1b[90m", "\x1b[39m"),
53+
bgBlack: init("\x1b[40m", "\x1b[49m"),
54+
bgRed: init("\x1b[41m", "\x1b[49m"),
55+
bgGreen: init("\x1b[42m", "\x1b[49m"),
56+
bgYellow: init("\x1b[43m", "\x1b[49m"),
57+
bgBlue: init("\x1b[44m", "\x1b[49m"),
58+
bgMagenta: init("\x1b[45m", "\x1b[49m"),
59+
bgCyan: init("\x1b[46m", "\x1b[49m"),
60+
bgWhite: init("\x1b[47m", "\x1b[49m"),
61+
}
62+
}
6063

6164
module.exports = createColors()
6265
module.exports.createColors = createColors

0 commit comments

Comments
 (0)