Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

colormaker

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colormaker - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

test.js

101

index.js

@@ -8,12 +8,19 @@ /**

* soon as possible.(lorenzogamboagarcia@gmail.com)
*
*/
'use strict';
const chalk = require('chalk');
// CONSTANTS
const HEX = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
const HEX = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
const RGB = 255;
const HSV = null;
const HSL = null;
const HSI = null;
const PRIMARY_COLORS = ["r","g","b"];
/**
* @description Generates a random rumber of 3 digits
* @param { number }
* @returns { string } A hexadecimal number
* @param { number } n Number of random colors
* @returns { string } 1/+ hexadecimal numbers
*/

@@ -37,5 +44,2 @@ module.exports.getRandomColors = function(n) {

console.log(this.getRandomColors(3));
/**

@@ -45,22 +49,81 @@ * @description Generates all the hexadecimal numbers that can make up

*
* @returns { array } A list of 256 hexacimal numbers
* @returns { array } A list of 4096 hexacimal colors
*/
module.exports.getAllColors = function() {
let color_list = [];
HEX.forEach(function(element) {
let color_list = [];
HEX.forEach(function(element) {
// Iterates over the second digit
HEX.forEach(function(element2) {
// Iterates over the second digit
HEX.forEach(function(element2) {
// Iterates over the second digit
HEX.forEach(function(element3) {
let hex_color = `#${element}${element2}${element3}`;
color_list.push(hex_color);
});
HEX.forEach(function(element3) {
let hex_color = `#${element}${element2}${element3}`;
color_list.push(hex_color);
});
});
return color_list;
});
return color_list;
}
/**
* @description Generates all the hexadecimal numbers that can make up
* to 3 digits but one of the digits its occupied by the charracter 'F'
* making the Red, Blue and Green the only colors available
*
* @returns { array } A list of 256 hexacimal colors
*/
module.exports.paintPrimary = function(color) {
if(PRIMARY_COLORS.includes(color)) return factoryPrimaryPainter(color);
return [];
}
/**
* @description Prints all the elements from an array with their
* respective colors
* @param { array } colors A set of colors
*/
module.exports.printer = function(colors) {
for (var index = 0; index < colors.length; index++) {
var element = colors[index];
console.log(chalk.hex(element).bold(element));
}
}
// console.log(this.getRandomColor());
//console.log('\x1b[36m%s\x1b[0m', 'I am cyan');
/**
* @description
* @param { string } primary_color Red, Green, Blue
*/
function factoryPrimaryPainter(primary_color) {
const result = [];
if(primary_color === 'r') {
HEX.forEach(function(element) {
// Iterates over the second digit
HEX.forEach(function(element1) {
let hex_color = `#F${element}${element1}`;
return result.push(hex_color);
});
});
}
if(primary_color === 'g') {
HEX.forEach(function(element) {
// Iterates over the second digit
HEX.forEach(function(element1) {
let hex_color = `#${element}F${element1}`;
return result.push(hex_color);
});
});
}
if(primary_color === 'b') {
HEX.forEach(function(element) {
// Iterates over the second digit
HEX.forEach(function(element1) {
let hex_color = `#${element}${element1}F`;
return result.push(hex_color);
});
});
}
}

13

package.json
{
"name": "colormaker",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},
"keywords": [],
"author": "",
"license": "ISC"
"license": "ISC",
"dependencies": {
"chai": "^4.1.2",
"chalk": "^2.3.0"
},
"devDependencies": {
"mocha": "^4.0.1"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc