Comparing version 1.0.0 to 1.0.1
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); | ||
}); | ||
}); | ||
} | ||
} |
{ | ||
"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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
4713
3
128
1
2
1
+ Addedchai@^4.1.2
+ Addedchalk@^2.3.0
+ Addedansi-styles@3.2.1(transitive)
+ Addedassertion-error@1.1.0(transitive)
+ Addedchai@4.5.0(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcheck-error@1.0.3(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addeddeep-eql@4.1.4(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedget-func-name@2.0.2(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedloupe@2.3.7(transitive)
+ Addedpathval@1.1.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedtype-detect@4.1.0(transitive)