couleurs 6.0.12 → 6.0.13
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 +1 -1
- package/README.md +14 -168
- package/lib/index.js +28 -24
- package/package.json +1 -2
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2014-
|
|
3
|
+
Copyright (c) 2014-26 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,56 +1,17 @@
|
|
|
1
1
|
<!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
3
|
[](#)
|
|
11
4
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
5
|
# couleurs
|
|
23
6
|
|
|
24
|
-
[![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [](https://github.com/IonicaBizau/ama) [](https://github.com/IonicaBizau/ama) [](https://app.travis-ci.com/IonicaBizau/node-couleurs) [](https://www.npmjs.com/package/couleurs) [](https://www.npmjs.com/package/couleurs) [](https://www.codementor.io/@johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
|
|
25
8
|
|
|
26
9
|
<a href="https://www.buymeacoffee.com/H96WwChMy" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png" alt="Buy Me A Coffee"></a>
|
|
27
10
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
11
|
> Add some color and styles to your Node.JS strings.
|
|
35
12
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
13
|
[](#)
|
|
47
14
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
15
|
## :cloud: Installation
|
|
55
16
|
|
|
56
17
|
```sh
|
|
@@ -61,22 +22,8 @@ npm install --save couleurs
|
|
|
61
22
|
yarn add couleurs
|
|
62
23
|
```
|
|
63
24
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
25
|
## :clipboard: Example
|
|
77
26
|
|
|
78
|
-
|
|
79
|
-
|
|
80
27
|
```js
|
|
81
28
|
const colors = require("couleurs")
|
|
82
29
|
, FlatColors = require("flat-colors")
|
|
@@ -115,40 +62,11 @@ console.log("All combined"
|
|
|
115
62
|
);
|
|
116
63
|
```
|
|
117
64
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
## :question: Get Help
|
|
130
|
-
|
|
131
|
-
There are few ways to get help:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
|
|
136
|
-
2. For bug reports and feature requests, open issues. :bug:
|
|
137
|
-
3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
65
|
## :memo: Documentation
|
|
146
66
|
|
|
147
|
-
|
|
148
67
|
### `Couleurs(setStringProto, fg)`
|
|
149
68
|
|
|
150
69
|
#### Params
|
|
151
|
-
|
|
152
70
|
- **Boolean|undefined** `setStringProto`: If `true`, the prototype of String class will be modified.
|
|
153
71
|
- **String|Array** `fg`: An optional foreground color.
|
|
154
72
|
|
|
@@ -174,110 +92,38 @@ Converts the internal object into string.
|
|
|
174
92
|
### `proto()`
|
|
175
93
|
Modifies the `String` prototype to contain the `Couleurs` methods.
|
|
176
94
|
|
|
95
|
+
## :question: Get Help
|
|
177
96
|
|
|
97
|
+
There are a few ways to get help:
|
|
178
98
|
|
|
99
|
+
1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long as you add a link to your Stack Overflow question.
|
|
100
|
+
2. For bug reports and feature requests, open issues. :bug:
|
|
101
|
+
3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
|
|
179
102
|
|
|
103
|
+
## :yum: How to Contribute
|
|
180
104
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
## :yum: How to contribute
|
|
191
105
|
Have an idea? Found a bug? See [how to contribute][contributing].
|
|
192
106
|
|
|
107
|
+
## :sparkling_heart: Support My Projects
|
|
193
108
|
|
|
194
|
-
|
|
195
|
-
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously,
|
|
196
|
-
this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute (even resell it).
|
|
197
|
-
|
|
198
|
-
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
|
|
109
|
+
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute it (even resell it).
|
|
199
110
|
|
|
111
|
+
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are a few ways you can do it:
|
|
200
112
|
|
|
201
113
|
- Starring and sharing the projects you like :rocket:
|
|
202
|
-
- [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you
|
|
114
|
+
- [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you for years if you buy me one. :grin: :book:
|
|
203
115
|
- [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
|
|
204
116
|
- [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
|
|
205
|
-
- **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
|
|
206
|
-
|
|
207
|
-

|
|
117
|
+
- **Bitcoin**—You can send me bitcoins at this address (or by scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
|
|
208
118
|
|
|
119
|
+

|
|
209
120
|
|
|
210
121
|
Thanks! :heart:
|
|
211
122
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
## :dizzy: Where is this library used?
|
|
228
|
-
If you are using this library in one of your projects, add it in this list. :sparkles:
|
|
229
|
-
|
|
230
|
-
- `3abn`
|
|
231
|
-
- `@phaticusthiccy/image-to-text`
|
|
232
|
-
- `@well-crafted/git-unsaved`
|
|
233
|
-
- `asciify-image`
|
|
234
|
-
- `asciify-pixel`
|
|
235
|
-
- `bible`
|
|
236
|
-
- `birthday`
|
|
237
|
-
- `bloggify-tools`
|
|
238
|
-
- `bug-killer`
|
|
239
|
-
- `cli-confeti`
|
|
240
|
-
- `cli-confetti`
|
|
241
|
-
- `cli-gh-cal`
|
|
242
|
-
- `cli-github`
|
|
243
|
-
- `cli-pie`
|
|
244
|
-
- `cli-sunset`
|
|
245
|
-
- `closeheat`
|
|
246
|
-
- `color-it`
|
|
247
|
-
- `csk-cli`
|
|
248
|
-
- `cute-logger`
|
|
249
|
-
- `fb-falafel`
|
|
250
|
-
- `git-issues`
|
|
251
|
-
- `git-issues1`
|
|
252
|
-
- `git-stats-colors`
|
|
253
|
-
- `git-unsaved`
|
|
254
|
-
- `github-emojify`
|
|
255
|
-
- `github-stats`
|
|
256
|
-
- `idea`
|
|
257
|
-
- `image-asciify-cli`
|
|
258
|
-
- `overlap`
|
|
259
|
-
- `terminal-rush`
|
|
260
|
-
- `tithe`
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
123
|
## :scroll: License
|
|
273
124
|
|
|
274
125
|
[MIT][license] © [Ionică Bizău][website]
|
|
275
126
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
127
|
[license]: /LICENSE
|
|
282
128
|
[website]: https://ionicabizau.net
|
|
283
129
|
[contributing]: /CONTRIBUTING.md
|
|
@@ -287,5 +133,5 @@ If you are using this library in one of your projects, add it in this list. :spa
|
|
|
287
133
|
[badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg
|
|
288
134
|
[badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg
|
|
289
135
|
[patreon]: https://www.patreon.com/ionicabizau
|
|
290
|
-
[amazon]:
|
|
136
|
+
[amazon]: https://amzn.eu/hRo9sIZ
|
|
291
137
|
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
|
package/lib/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
// Dependencies
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const typpy = require("typpy")
|
|
5
|
+
, colorConvert = require("color-convert")
|
|
6
|
+
, ansy = require("ansy")
|
|
7
|
+
, iterateObject = require("iterate-object")
|
|
8
|
+
;
|
|
9
9
|
|
|
10
10
|
// Constants
|
|
11
|
-
|
|
12
|
-
bold: ["\
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const MAP = {
|
|
12
|
+
bold: [ "\u001b[1m", "\u001b[22m" ]
|
|
13
|
+
, italic: [ "\u001b[3m", "\u001b[23m" ]
|
|
14
|
+
, underline: [ "\u001b[4m", "\u001b[24m" ]
|
|
15
|
+
, inverse: [ "\u001b[7m", "\u001b[27m" ]
|
|
16
|
+
, strike: [ "\u001b[9m", "\u001b[29m" ]
|
|
17
|
+
, fg: ["fg", "fg"]
|
|
18
|
+
, bg: ["bg", "bg"]
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -59,9 +59,9 @@ function prepareHandler(text, r, g, b) {
|
|
|
59
59
|
text = this.text;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
color: ""
|
|
64
|
-
|
|
62
|
+
let res = {
|
|
63
|
+
color: ""
|
|
64
|
+
, text: text
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
if (typpy(r, Array)) {
|
|
@@ -90,13 +90,17 @@ function toStr(start, color, text, end) {
|
|
|
90
90
|
|
|
91
91
|
function genMeth(start, end, name) {
|
|
92
92
|
return function (str, r, g, b) {
|
|
93
|
-
|
|
93
|
+
let res = prepareHandler.apply(this, arguments);
|
|
94
94
|
if (typpy(this.text, String)) {
|
|
95
|
-
this.styles.push([
|
|
95
|
+
this.styles.push([
|
|
96
|
+
start
|
|
97
|
+
, end
|
|
98
|
+
, res
|
|
99
|
+
]);
|
|
96
100
|
return this;
|
|
97
101
|
}
|
|
98
102
|
return toStr(start, res.color, res.text, end);
|
|
99
|
-
}
|
|
103
|
+
}
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
/**
|
|
@@ -108,15 +112,15 @@ function genMeth(start, end, name) {
|
|
|
108
112
|
* @return {String} Stringifies the couleurs internal data using ANSI styles.
|
|
109
113
|
*/
|
|
110
114
|
Couleurs.prototype.toString = function () {
|
|
111
|
-
|
|
112
|
-
this.styles.forEach(
|
|
115
|
+
let str = this.text;
|
|
116
|
+
this.styles.forEach(c => {
|
|
113
117
|
str = toStr(c[0], c[2].color, str, c[1]);
|
|
114
118
|
});
|
|
115
119
|
|
|
116
120
|
return str;
|
|
117
121
|
};
|
|
118
122
|
|
|
119
|
-
iterateObject(MAP,
|
|
123
|
+
iterateObject(MAP, (c, s) => {
|
|
120
124
|
Couleurs[s] = Couleurs.prototype[s] = genMeth(c[0], c[1], s);
|
|
121
125
|
});
|
|
122
126
|
|
|
@@ -128,11 +132,11 @@ iterateObject(MAP, function (c, s) {
|
|
|
128
132
|
* @function
|
|
129
133
|
*/
|
|
130
134
|
Couleurs.proto = function () {
|
|
131
|
-
iterateObject(MAP,
|
|
135
|
+
iterateObject(MAP, (s, c) => {
|
|
132
136
|
String.prototype[c] = function (r, g, b) {
|
|
133
137
|
return Couleurs[c](String(this), r, g, b);
|
|
134
138
|
};
|
|
135
139
|
});
|
|
136
140
|
};
|
|
137
141
|
|
|
138
|
-
module.exports = Couleurs;
|
|
142
|
+
module.exports = Couleurs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "couleurs",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.13",
|
|
4
4
|
"description": "Add some color and styles to your Node.JS strings.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"cli.js",
|
|
53
53
|
"index.js",
|
|
54
54
|
"index.d.ts",
|
|
55
|
-
"package-lock.json",
|
|
56
55
|
"bloggify.js",
|
|
57
56
|
"bloggify.json",
|
|
58
57
|
"bloggify/"
|