Socket
Socket
Sign inDemoInstall

kuler

Package Overview
Dependencies
0
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 2.0.0

11

index.js
'use strict';
var colornames = require('colornames');
/**

@@ -113,11 +111,2 @@ * Kuler: Color text using CSS colors

Kuler.prototype.style = function style(color) {
//
// We've been supplied a CSS color name instead of a hex color format so we
// need to transform it to proper CSS color and continue with our execution
// flow.
//
if (!/^#?(?:[0-9a-fA-F]{3}){1,2}$/.test(color)) {
color = colornames(color);
}
return this.prefix +'38;5;'+ this.rgb.apply(this, this.hex(color)) + this.suffix + this.text + this.reset();

@@ -124,0 +113,0 @@ };

5

package.json
{
"name": "kuler",
"version": "1.0.1",
"version": "2.0.0",
"description": "Color your terminal using CSS/hex color codes",

@@ -30,5 +30,2 @@ "main": "index.js",

"homepage": "https://github.com/3rd-Eden/kuler",
"dependencies": {
"colornames": "^1.1.1"
},
"devDependencies": {

@@ -35,0 +32,0 @@ "assume": "^2.0.1",

25

README.md

@@ -10,2 +10,5 @@ # kuler

The package is released in the public npm registry and can be installed by
running:
```

@@ -17,4 +20,4 @@ npm install --save kuler

Kuler provides a really low level API as we all have different opinions on how
to build and write coloring libraries. To use it you first have to require it:
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:

@@ -24,18 +27,6 @@ ```js

var kuler = require('kuler');
const kuler = require('kuler');
const str = kuler('foo', '#FF6600');
```
There are two different API's that you can use. A constructor based API which
uses a `.style` method to color your text:
```js
var str = kuler('foo').style('#FFF');
```
Or an alternate short version:
```js
var str = kuler('foo', 'red');
```
The color code sequence is automatically terminated at the end of the string so

@@ -45,3 +36,3 @@ the colors do no bleed to other pieces of text. So doing:

```js
console.log(kuler('red', 'red'), 'normal');
console.log(kuler('red', '#F00'), 'normal');
```

@@ -48,0 +39,0 @@

@@ -8,16 +8,12 @@ const { it, describe } = require('mocha');

console.log(' VISUAL INSPECTION');
console.log(' '+ kuler('red').style('red'));
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('violetred 1'));
console.log(' '+ kuler('purple').style('purple'));
console.log(' '+ kuler('purple').style('purple'), 'correctly reset to normal color');
console.log(' '+ kuler('green', 'green'));
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'));
});
it('supports color names and hex values', function () {
assume(kuler('black', 'black')).equals(kuler('black', '#000'));
})
describe('#style', function () {

@@ -24,0 +20,0 @@ it('has a style method', function () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc