couleurs 6.0.11 → 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 +15 -163
- package/lib/index.js +28 -24
- package/package.json +3 -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,38 +62,12 @@ console.log("All combined"
|
|
|
115
62
|
);
|
|
116
63
|
```
|
|
117
64
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
## :question: Get Help
|
|
129
|
-
|
|
130
|
-
There are few ways to get help:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
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.
|
|
135
|
-
2. For bug reports and feature requests, open issues. :bug:
|
|
136
|
-
3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
65
|
## :memo: Documentation
|
|
143
66
|
|
|
144
|
-
|
|
145
67
|
### `Couleurs(setStringProto, fg)`
|
|
146
68
|
|
|
147
69
|
#### Params
|
|
148
|
-
|
|
149
|
-
- **Boolean** `setStringProto`: If `true`, the prototype of String class will be modified.
|
|
70
|
+
- **Boolean|undefined** `setStringProto`: If `true`, the prototype of String class will be modified.
|
|
150
71
|
- **String|Array** `fg`: An optional foreground color.
|
|
151
72
|
|
|
152
73
|
#### Return
|
|
@@ -171,107 +92,38 @@ Converts the internal object into string.
|
|
|
171
92
|
### `proto()`
|
|
172
93
|
Modifies the `String` prototype to contain the `Couleurs` methods.
|
|
173
94
|
|
|
95
|
+
## :question: Get Help
|
|
174
96
|
|
|
97
|
+
There are a few ways to get help:
|
|
175
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:
|
|
176
102
|
|
|
103
|
+
## :yum: How to Contribute
|
|
177
104
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
## :yum: How to contribute
|
|
188
105
|
Have an idea? Found a bug? See [how to contribute][contributing].
|
|
189
106
|
|
|
107
|
+
## :sparkling_heart: Support My Projects
|
|
190
108
|
|
|
191
|
-
|
|
192
|
-
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously,
|
|
193
|
-
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).
|
|
194
|
-
|
|
195
|
-
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).
|
|
196
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:
|
|
197
112
|
|
|
198
113
|
- Starring and sharing the projects you like :rocket:
|
|
199
|
-
- [![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:
|
|
200
115
|
- [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
|
|
201
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).
|
|
202
|
-
- **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
|
|
203
|
-
|
|
204
|
-

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

|
|
206
120
|
|
|
207
121
|
Thanks! :heart:
|
|
208
122
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
## :dizzy: Where is this library used?
|
|
225
|
-
If you are using this library in one of your projects, add it in this list. :sparkles:
|
|
226
|
-
|
|
227
|
-
- `bug-killer`
|
|
228
|
-
- `asciify-image`
|
|
229
|
-
- `cli-pie`
|
|
230
|
-
- `overlap`
|
|
231
|
-
- `color-it`
|
|
232
|
-
- `git-stats-colors`
|
|
233
|
-
- `cli-gh-cal`
|
|
234
|
-
- `cute-logger`
|
|
235
|
-
- `cli-confeti`
|
|
236
|
-
- `asciify-pixel`
|
|
237
|
-
- `bible`
|
|
238
|
-
- `fb-falafel`
|
|
239
|
-
- `git-issues1`
|
|
240
|
-
- `closeheat`
|
|
241
|
-
- `csk-cli`
|
|
242
|
-
- `tithe`
|
|
243
|
-
- `image-asciify-cli`
|
|
244
|
-
- `bloggify-tools`
|
|
245
|
-
- `3abn`
|
|
246
|
-
- `birthday`
|
|
247
|
-
- `cli-confetti`
|
|
248
|
-
- `cli-github`
|
|
249
|
-
- `cli-sunset`
|
|
250
|
-
- `git-unsaved`
|
|
251
|
-
- `idea`
|
|
252
|
-
- `github-emojify`
|
|
253
|
-
- `github-stats`
|
|
254
|
-
- `git-issues`
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
123
|
## :scroll: License
|
|
267
124
|
|
|
268
125
|
[MIT][license] © [Ionică Bizău][website]
|
|
269
126
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
127
|
[license]: /LICENSE
|
|
276
128
|
[website]: https://ionicabizau.net
|
|
277
129
|
[contributing]: /CONTRIBUTING.md
|
|
@@ -281,5 +133,5 @@ If you are using this library in one of your projects, add it in this list. :spa
|
|
|
281
133
|
[badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg
|
|
282
134
|
[badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg
|
|
283
135
|
[patreon]: https://www.patreon.com/ionicabizau
|
|
284
|
-
[amazon]:
|
|
136
|
+
[amazon]: https://amzn.eu/hRo9sIZ
|
|
285
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": {
|
|
@@ -51,8 +51,9 @@
|
|
|
51
51
|
"menu/",
|
|
52
52
|
"cli.js",
|
|
53
53
|
"index.js",
|
|
54
|
+
"index.d.ts",
|
|
54
55
|
"bloggify.js",
|
|
55
56
|
"bloggify.json",
|
|
56
57
|
"bloggify/"
|
|
57
58
|
]
|
|
58
|
-
}
|
|
59
|
+
}
|