stuff
This commit is contained in:
5
buildfiles/app/node_modules/kuler/.travis.yml
generated
vendored
Normal file
5
buildfiles/app/node_modules/kuler/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "9"
|
||||
- "8"
|
||||
- "6"
|
7
buildfiles/app/node_modules/kuler/LICENSE
generated
vendored
Normal file
7
buildfiles/app/node_modules/kuler/LICENSE
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright 2014 Arnout Kazemier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
40
buildfiles/app/node_modules/kuler/README.md
generated
vendored
Normal file
40
buildfiles/app/node_modules/kuler/README.md
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
# kuler
|
||||
|
||||
Kuler is small and nifty node module that allows you to create terminal based
|
||||
colors using hex color codes, just like you're used to doing in your CSS. We're
|
||||
in a modern world now and terminals support more than 16 colors so we are stupid
|
||||
to not take advantage of this.
|
||||
|
||||
## Installation
|
||||
|
||||
The package is released in the public npm registry and can be installed by
|
||||
running:
|
||||
|
||||
```
|
||||
npm install --save kuler
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
To color a string simply pass it the string you want to have colored as first
|
||||
argument and the color as hex as second argument:
|
||||
|
||||
```js
|
||||
'use strict';
|
||||
|
||||
const kuler = require('kuler');
|
||||
const str = kuler('foo', '#FF6600');
|
||||
```
|
||||
|
||||
The color code sequence is automatically terminated at the end of the string so
|
||||
the colors do no bleed to other pieces of text. So doing:
|
||||
|
||||
```js
|
||||
console.log(kuler('red', '#F00'), 'normal');
|
||||
```
|
||||
|
||||
Will work without any issues.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
118
buildfiles/app/node_modules/kuler/index.js
generated
vendored
Normal file
118
buildfiles/app/node_modules/kuler/index.js
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Kuler: Color text using CSS colors
|
||||
*
|
||||
* @constructor
|
||||
* @param {String} text The text that needs to be styled
|
||||
* @param {String} color Optional color for alternate API.
|
||||
* @api public
|
||||
*/
|
||||
function Kuler(text, color) {
|
||||
if (color) return (new Kuler(text)).style(color);
|
||||
if (!(this instanceof Kuler)) return new Kuler(text);
|
||||
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* ANSI color codes.
|
||||
*
|
||||
* @type {String}
|
||||
* @private
|
||||
*/
|
||||
Kuler.prototype.prefix = '\x1b[';
|
||||
Kuler.prototype.suffix = 'm';
|
||||
|
||||
/**
|
||||
* Parse a hex color string and parse it to it's RGB equiv.
|
||||
*
|
||||
* @param {String} color
|
||||
* @returns {Array}
|
||||
* @api private
|
||||
*/
|
||||
Kuler.prototype.hex = function hex(color) {
|
||||
color = color[0] === '#' ? color.substring(1) : color;
|
||||
|
||||
//
|
||||
// Pre-parse for shorthand hex colors.
|
||||
//
|
||||
if (color.length === 3) {
|
||||
color = color.split('');
|
||||
|
||||
color[5] = color[2]; // F60##0
|
||||
color[4] = color[2]; // F60#00
|
||||
color[3] = color[1]; // F60600
|
||||
color[2] = color[1]; // F66600
|
||||
color[1] = color[0]; // FF6600
|
||||
|
||||
color = color.join('');
|
||||
}
|
||||
|
||||
var r = color.substring(0, 2)
|
||||
, g = color.substring(2, 4)
|
||||
, b = color.substring(4, 6);
|
||||
|
||||
return [ parseInt(r, 16), parseInt(g, 16), parseInt(b, 16) ];
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform a 255 RGB value to an RGV code.
|
||||
*
|
||||
* @param {Number} r Red color channel.
|
||||
* @param {Number} g Green color channel.
|
||||
* @param {Number} b Blue color channel.
|
||||
* @returns {String}
|
||||
* @api public
|
||||
*/
|
||||
Kuler.prototype.rgb = function rgb(r, g, b) {
|
||||
var red = r / 255 * 5
|
||||
, green = g / 255 * 5
|
||||
, blue = b / 255 * 5;
|
||||
|
||||
return this.ansi(red, green, blue);
|
||||
};
|
||||
|
||||
/**
|
||||
* Turns RGB 0-5 values into a single ANSI code.
|
||||
*
|
||||
* @param {Number} r Red color channel.
|
||||
* @param {Number} g Green color channel.
|
||||
* @param {Number} b Blue color channel.
|
||||
* @returns {String}
|
||||
* @api public
|
||||
*/
|
||||
Kuler.prototype.ansi = function ansi(r, g, b) {
|
||||
var red = Math.round(r)
|
||||
, green = Math.round(g)
|
||||
, blue = Math.round(b);
|
||||
|
||||
return 16 + (red * 36) + (green * 6) + blue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Marks an end of color sequence.
|
||||
*
|
||||
* @returns {String} Reset sequence.
|
||||
* @api public
|
||||
*/
|
||||
Kuler.prototype.reset = function reset() {
|
||||
return this.prefix +'39;49'+ this.suffix;
|
||||
};
|
||||
|
||||
/**
|
||||
* Colour the terminal using CSS.
|
||||
*
|
||||
* @param {String} color The HEX color code.
|
||||
* @returns {String} the escape code.
|
||||
* @api public
|
||||
*/
|
||||
Kuler.prototype.style = function style(color) {
|
||||
return this.prefix +'38;5;'+ this.rgb.apply(this, this.hex(color)) + this.suffix + this.text + this.reset();
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Expose the actual interface.
|
||||
//
|
||||
module.exports = Kuler;
|
64
buildfiles/app/node_modules/kuler/package.json
generated
vendored
Normal file
64
buildfiles/app/node_modules/kuler/package.json
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"kuler@2.0.0",
|
||||
"/home/shihaam/www/freezer.shihaam.me/app"
|
||||
]
|
||||
],
|
||||
"_from": "kuler@2.0.0",
|
||||
"_id": "kuler@2.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==",
|
||||
"_location": "/kuler",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "kuler@2.0.0",
|
||||
"name": "kuler",
|
||||
"escapedName": "kuler",
|
||||
"rawSpec": "2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@dabh/diagnostics"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz",
|
||||
"_spec": "2.0.0",
|
||||
"_where": "/home/shihaam/www/freezer.shihaam.me/app",
|
||||
"author": {
|
||||
"name": "Arnout Kazemier"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/3rd-Eden/kuler/issues"
|
||||
},
|
||||
"description": "Color your terminal using CSS/hex color codes",
|
||||
"devDependencies": {
|
||||
"assume": "^2.0.1",
|
||||
"mocha": "^5.1.1"
|
||||
},
|
||||
"homepage": "https://github.com/3rd-Eden/kuler",
|
||||
"keywords": [
|
||||
"kuler",
|
||||
"ansi",
|
||||
"color",
|
||||
"colour",
|
||||
"chalk",
|
||||
"css",
|
||||
"hex",
|
||||
"rgb",
|
||||
"rgv"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "kuler",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/3rd-Eden/kuler.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test.js"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
23
buildfiles/app/node_modules/kuler/test.js
generated
vendored
Normal file
23
buildfiles/app/node_modules/kuler/test.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
const { it, describe } = require('mocha');
|
||||
const assume = require('assume');
|
||||
const kuler = require('./');
|
||||
|
||||
describe('kuler', function () {
|
||||
it('renders colors in the terminal', function () {
|
||||
console.log(' VISUAL INSPECTION');
|
||||
console.log(' '+ kuler('red').style('F00'));
|
||||
console.log(' '+ kuler('black').style('#000'));
|
||||
console.log(' '+ kuler('white').style('#FFFFFF'));
|
||||
console.log(' '+ kuler('lime').style('AAFF5B'));
|
||||
console.log(' '+ kuler('violet').style('#ee82ee'));
|
||||
console.log(' '+ kuler('purple').style('#800080'));
|
||||
console.log(' '+ kuler('purple').style('#800080'), 'correctly reset to normal color');
|
||||
console.log(' '+ kuler('green', '#008000'));
|
||||
});
|
||||
|
||||
describe('#style', function () {
|
||||
it('has a style method', function () {
|
||||
assume(kuler('what').style).is.a('function');
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user