@hypernym/colors 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/README.md +35 -0
- package/package.json +48 -0
- package/src/index.mjs +56 -0
- package/src/types/index.d.ts +30 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Ivo Dolenc, Hypernym Studio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @hypernym/colors
|
|
2
|
+
|
|
3
|
+
Ultra lightweight color utilities for console.
|
|
4
|
+
|
|
5
|
+
<sub><a href="https://github.com/hypernym-studio/colors">Repository</a> | <a href="https://www.npmjs.com/package/@hypernym/colors">Package</a> | <a href="https://github.com/hypernym-studio/colors/releases">Releases</a> | <a href="https://github.com/hypernym-studio/colors/discussions">Discussions</a></sub>
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i -D @hypernym/colors
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- TypeScript friendly
|
|
14
|
+
- Fully tree-shakeable
|
|
15
|
+
- No dependencies
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { bold, green, cyan } from '@hypernym/colors'
|
|
21
|
+
|
|
22
|
+
console.log(bold(green('hypernym')), cyan('colors'))
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Community
|
|
26
|
+
|
|
27
|
+
Feel free to use the official [discussions](https://github.com/hypernym-studio/colors/discussions) for any additional questions.
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
Developed in ðŸ‡ðŸ‡· Croatia
|
|
32
|
+
|
|
33
|
+
Released under the [MIT](LICENSE.txt) license.
|
|
34
|
+
|
|
35
|
+
© Hypernym Studio
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hypernym/colors",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "Hypernym Studio",
|
|
5
|
+
"description": "Ultra lightweight color utilities for console.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": "hypernym-studio/colors",
|
|
8
|
+
"homepage": "https://github.com/hypernym-studio/colors",
|
|
9
|
+
"funding": "https://github.com/sponsors/ivodolenc",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./src/types/index.d.ts",
|
|
14
|
+
"import": "./src/index.mjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"src"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"cli",
|
|
22
|
+
"node",
|
|
23
|
+
"ansi",
|
|
24
|
+
"color",
|
|
25
|
+
"colors",
|
|
26
|
+
"terminal",
|
|
27
|
+
"console",
|
|
28
|
+
"log",
|
|
29
|
+
"esm"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"lint": "ESLINT_USE_FLAT_CONFIG=true eslint -c .config/eslint.config.js .",
|
|
33
|
+
"lint:fix": "ESLINT_USE_FLAT_CONFIG=true eslint -c .config/eslint.config.js --fix .",
|
|
34
|
+
"format": "prettier --config .config/prettier.config.js --write ."
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@hypernym/eslint-config": "^2.0.0",
|
|
38
|
+
"@hypernym/prettier-config": "^2.0.0",
|
|
39
|
+
"@hypernym/tsconfig": "^1.0.1",
|
|
40
|
+
"@types/node": "^20.6.3",
|
|
41
|
+
"eslint": "^8.49.0",
|
|
42
|
+
"prettier": "^3.0.3",
|
|
43
|
+
"typescript": "^5.2.2"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=v18.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const _ = `\x1B[`
|
|
2
|
+
const reset = (v) => `${_}0m${v}${_}0m`
|
|
3
|
+
const bold = (v) => `${_}1m${v}${_}22m`
|
|
4
|
+
const dim = (v) => `${_}2m${v}${_}22m`
|
|
5
|
+
const italic = (v) => `${_}3m${v}${_}23m`
|
|
6
|
+
const underline = (v) => `${_}4m${v}${_}24m`
|
|
7
|
+
const inverse = (v) => `${_}7m${v}${_}27m`
|
|
8
|
+
const hidden = (v) => `${_}8m${v}${_}28m`
|
|
9
|
+
const crossout = (v) => `${_}9m${v}${_}29m`
|
|
10
|
+
const black = (v) => `${_}30m${v}${_}39m`
|
|
11
|
+
const bgBlack = (v) => `${_}40m${v}${_}49m`
|
|
12
|
+
const red = (v) => `${_}31m${v}${_}39m`
|
|
13
|
+
const bgRed = (v) => `${_}41m${v}${_}49m`
|
|
14
|
+
const green = (v) => `${_}32m${v}${_}39m`
|
|
15
|
+
const bgGreen = (v) => `${_}42m${v}${_}49m`
|
|
16
|
+
const yellow = (v) => `${_}33m${v}${_}39m`
|
|
17
|
+
const bgYellow = (v) => `${_}43m${v}${_}49m`
|
|
18
|
+
const blue = (v) => `${_}34m${v}${_}39m`
|
|
19
|
+
const bgBlue = (v) => `${_}44m${v}${_}49m`
|
|
20
|
+
const magenta = (v) => `${_}35m${v}${_}39m`
|
|
21
|
+
const bgMagenta = (v) => `${_}45m${v}${_}49m`
|
|
22
|
+
const cyan = (v) => `${_}36m${v}${_}39m`
|
|
23
|
+
const bgCyan = (v) => `${_}46m${v}${_}49m`
|
|
24
|
+
const white = (v) => `${_}37m${v}${_}39m`
|
|
25
|
+
const bgWhite = (v) => `${_}47m${v}${_}49m`
|
|
26
|
+
const gray = (v) => `${_}90m${v}${_}39m`
|
|
27
|
+
const bgGray = (v) => `${_}100m${v}${_}49m`
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
reset,
|
|
31
|
+
bold,
|
|
32
|
+
dim,
|
|
33
|
+
italic,
|
|
34
|
+
underline,
|
|
35
|
+
inverse,
|
|
36
|
+
hidden,
|
|
37
|
+
crossout,
|
|
38
|
+
black,
|
|
39
|
+
bgBlack,
|
|
40
|
+
red,
|
|
41
|
+
bgRed,
|
|
42
|
+
green,
|
|
43
|
+
bgGreen,
|
|
44
|
+
yellow,
|
|
45
|
+
bgYellow,
|
|
46
|
+
blue,
|
|
47
|
+
bgBlue,
|
|
48
|
+
magenta,
|
|
49
|
+
bgMagenta,
|
|
50
|
+
cyan,
|
|
51
|
+
bgCyan,
|
|
52
|
+
white,
|
|
53
|
+
bgWhite,
|
|
54
|
+
gray,
|
|
55
|
+
bgGray,
|
|
56
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type Color = (v: string | number) => string;
|
|
2
|
+
|
|
3
|
+
declare const reset: Color;
|
|
4
|
+
declare const bold: Color;
|
|
5
|
+
declare const dim: Color;
|
|
6
|
+
declare const italic: Color;
|
|
7
|
+
declare const underline: Color;
|
|
8
|
+
declare const inverse: Color;
|
|
9
|
+
declare const hidden: Color;
|
|
10
|
+
declare const crossout: Color;
|
|
11
|
+
declare const black: Color;
|
|
12
|
+
declare const bgBlack: Color;
|
|
13
|
+
declare const red: Color;
|
|
14
|
+
declare const bgRed: Color;
|
|
15
|
+
declare const green: Color;
|
|
16
|
+
declare const bgGreen: Color;
|
|
17
|
+
declare const yellow: Color;
|
|
18
|
+
declare const bgYellow: Color;
|
|
19
|
+
declare const blue: Color;
|
|
20
|
+
declare const bgBlue: Color;
|
|
21
|
+
declare const magenta: Color;
|
|
22
|
+
declare const bgMagenta: Color;
|
|
23
|
+
declare const cyan: Color;
|
|
24
|
+
declare const bgCyan: Color;
|
|
25
|
+
declare const white: Color;
|
|
26
|
+
declare const bgWhite: Color;
|
|
27
|
+
declare const gray: Color;
|
|
28
|
+
declare const bgGray: Color;
|
|
29
|
+
|
|
30
|
+
export { type Color, reset, bold, dim, italic, underline, inverse, hidden, crossout, black, bgBlack, red, bgRed, green, bgGreen, yellow, bgYellow, blue, bgBlue, magenta, bgMagenta, cyan, bgCyan, white, bgWhite, gray, bgGray };
|