Comparing version 1.0.1 to 1.0.2
111
index.js
@@ -11,2 +11,3 @@ /** | ||
const fs = require('fs'); | ||
const chalk = require('chalk'); | ||
@@ -16,7 +17,3 @@ | ||
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"]; | ||
const PRIMARY_COLORS = ["r", "g", "b"]; | ||
@@ -28,13 +25,8 @@ /** | ||
*/ | ||
module.exports.getRandomColors = function(n) { | ||
module.exports.getRandomColors = n => { | ||
let colors = []; | ||
var n = n || 1; | ||
for (var index = 0; index < n; index++) { | ||
let color = "#"; | ||
for (let x = 0; x < 3; x++) { | ||
let hexacimal = HEX[Math.floor(Math.random() * HEX.length)]; | ||
color += hexacimal; | ||
} | ||
for (let index = 0; index < n; index++) { | ||
let color = '#'+(Math.random()*0xFFFFFF<<0).toString(16); | ||
colors.push(color); | ||
@@ -52,15 +44,13 @@ } | ||
*/ | ||
module.exports.getAllColors = function() { | ||
module.exports.getAllColors = () => { | ||
let color_list = []; | ||
HEX.forEach(function(element) { | ||
// Iterates over the second digit | ||
HEX.forEach(function(element2) { | ||
// Iterates over the second digit | ||
HEX.forEach(function(element3) { | ||
HEX.forEach(element => | ||
HEX.forEach(element2 => { | ||
HEX.forEach(element3 => { | ||
let hex_color = `#${element}${element2}${element3}`; | ||
color_list.push(hex_color); | ||
}); | ||
}); | ||
}); | ||
}) | ||
})) | ||
@@ -77,5 +67,4 @@ return color_list; | ||
*/ | ||
module.exports.paintPrimary = function(color) { | ||
if(PRIMARY_COLORS.includes(color)) return factoryPrimaryPainter(color); | ||
module.exports.paintPrimary = color => { | ||
if (PRIMARY_COLORS.includes(color)) return factoryPrimaryPainter(color); | ||
@@ -86,14 +75,2 @@ 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)); | ||
} | ||
} | ||
/** | ||
* @description | ||
@@ -103,31 +80,49 @@ * @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); | ||
const result = []; | ||
if (primary_color === 'r') { | ||
HEX.forEach( element => { | ||
HEX.forEach(element1 => { | ||
let hex_color = `#${element}${element1}0000`; | ||
result.push(hex_color); | ||
}); | ||
}); | ||
return result; | ||
} | ||
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 === 'g') { | ||
HEX.forEach( element => { | ||
HEX.forEach(element1 => { | ||
let hex_color = `#00${element}${element1}00`; | ||
result.push(hex_color); | ||
}); | ||
}); | ||
}); | ||
return result; | ||
} | ||
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); | ||
if (primary_color === 'b') { | ||
HEX.forEach( element => { | ||
HEX.forEach(element1 => { | ||
let hex_color = `#0000${element}${element1}`; | ||
result.push(hex_color); | ||
}); | ||
}); | ||
return result; | ||
} | ||
} | ||
} | ||
/****************************************** | ||
* COLORMAKER UTILITIES * | ||
******************************************/ | ||
/** | ||
* @description Prints all the elements from an array with their | ||
* respective colors | ||
* @param { array } colors A set of colors | ||
*/ | ||
module.exports.printer = colors => { | ||
for (let index = 0; index < colors.length; index++) { | ||
var element = colors[index]; | ||
console.log(chalk.hex(element).bold(element)); | ||
} | ||
} |
{ | ||
"name": "colormaker", | ||
"version": "1.0.1", | ||
"description": "", | ||
"version": "1.0.2", | ||
"description": "NPM module that supplies a bunch of methods to generate colors according to a pattern", | ||
"main": "index.js", | ||
@@ -9,4 +9,4 @@ "scripts": { | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"keywords": ["npm", "utility", "color", "hexadecimal", "rgb"], | ||
"author": "Lorenzo Gamboa", | ||
"license": "ISC", | ||
@@ -13,0 +13,0 @@ "dependencies": { |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
5207
4
2
1
31
122
2