Socket
Socket
Sign inDemoInstall

color-hash

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-hash - npm Package Compare versions

Comparing version 1.0.3 to 1.1.1

.github/workflows/node.js.yml

2

coverage/coverage.json

@@ -1,1 +0,1 @@

{"/home/zenozeng/home/code/color-hash/lib/bkdr-hash.js":{"path":"/home/zenozeng/home/code/color-hash/lib/bkdr-hash.js","s":{"1":1,"2":8,"3":8,"4":8,"5":8,"6":8,"7":8,"8":360014,"9":356706,"10":360014,"11":8,"12":1},"b":{"1":[356706,3308]},"f":{"1":8},"fnMap":{"1":{"name":"(anonymous_1)","line":7,"loc":{"start":{"line":7,"column":15},"end":{"line":7,"column":29}}}},"statementMap":{"1":{"start":{"line":7,"column":0},"end":{"line":22,"column":2}},"2":{"start":{"line":8,"column":4},"end":{"line":8,"column":19}},"3":{"start":{"line":9,"column":4},"end":{"line":9,"column":20}},"4":{"start":{"line":10,"column":4},"end":{"line":10,"column":17}},"5":{"start":{"line":12,"column":4},"end":{"line":12,"column":15}},"6":{"start":{"line":14,"column":4},"end":{"line":14,"column":62}},"7":{"start":{"line":15,"column":4},"end":{"line":20,"column":5}},"8":{"start":{"line":16,"column":8},"end":{"line":18,"column":9}},"9":{"start":{"line":17,"column":12},"end":{"line":17,"column":42}},"10":{"start":{"line":19,"column":8},"end":{"line":19,"column":47}},"11":{"start":{"line":21,"column":4},"end":{"line":21,"column":16}},"12":{"start":{"line":24,"column":0},"end":{"line":24,"column":26}}},"branchMap":{"1":{"line":16,"type":"if","locations":[{"start":{"line":16,"column":8},"end":{"line":16,"column":8}},{"start":{"line":16,"column":8},"end":{"line":16,"column":8}}]}}},"/home/zenozeng/home/code/color-hash/lib/color-hash.js":{"path":"/home/zenozeng/home/code/color-hash/lib/color-hash.js","s":{"1":2,"2":2,"3":4,"4":4,"5":12,"6":3,"7":12,"8":4,"9":2,"10":7,"11":7,"12":7,"13":7,"14":21,"15":1,"16":21,"17":4,"18":21,"19":5,"20":16,"21":7,"22":9,"23":1,"24":8,"25":21,"26":2,"27":4,"28":4,"29":8,"30":8,"31":4,"32":4,"33":4,"34":2,"35":6,"36":6,"37":6,"38":6,"39":6,"40":6,"41":6,"42":6,"43":2,"44":2,"45":2,"46":2,"47":1,"48":1,"49":2},"b":{"1":[3,9],"2":[4,3],"3":[1,20],"4":[4,17],"5":[5,16],"6":[7,9],"7":[1,8],"8":[4,1],"9":[8,4],"10":[6,2],"11":[4,3]},"f":{"1":4,"2":12,"3":7,"4":21,"5":4,"6":8,"7":6,"8":2,"9":1},"fnMap":{"1":{"name":"(anonymous_1)","line":9,"loc":{"start":{"line":9,"column":14},"end":{"line":9,"column":33}}},"2":{"name":"(anonymous_2)","line":11,"loc":{"start":{"line":11,"column":21},"end":{"line":11,"column":37}}},"3":{"name":"(anonymous_3)","line":29,"loc":{"start":{"line":29,"column":14},"end":{"line":29,"column":32}}},"4":{"name":"(anonymous_4)","line":35,"loc":{"start":{"line":35,"column":37},"end":{"line":35,"column":53}}},"5":{"name":"(anonymous_5)","line":60,"loc":{"start":{"line":60,"column":16},"end":{"line":60,"column":34}}},"6":{"name":"(anonymous_6)","line":63,"loc":{"start":{"line":63,"column":57},"end":{"line":63,"column":73}}},"7":{"name":"(anonymous_7)","line":81,"loc":{"start":{"line":81,"column":26},"end":{"line":81,"column":40}}},"8":{"name":"(anonymous_8)","line":101,"loc":{"start":{"line":101,"column":26},"end":{"line":101,"column":40}}},"9":{"name":"(anonymous_9)","line":112,"loc":{"start":{"line":112,"column":26},"end":{"line":112,"column":40}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},"2":{"start":{"line":9,"column":0},"end":{"line":18,"column":2}},"3":{"start":{"line":10,"column":4},"end":{"line":10,"column":18}},"4":{"start":{"line":11,"column":4},"end":{"line":16,"column":7}},"5":{"start":{"line":12,"column":8},"end":{"line":14,"column":9}},"6":{"start":{"line":13,"column":12},"end":{"line":13,"column":21}},"7":{"start":{"line":15,"column":8},"end":{"line":15,"column":34}},"8":{"start":{"line":17,"column":4},"end":{"line":17,"column":15}},"9":{"start":{"line":29,"column":0},"end":{"line":53,"column":2}},"10":{"start":{"line":30,"column":4},"end":{"line":30,"column":13}},"11":{"start":{"line":32,"column":4},"end":{"line":32,"column":50}},"12":{"start":{"line":33,"column":4},"end":{"line":33,"column":22}},"13":{"start":{"line":35,"column":4},"end":{"line":52,"column":7}},"14":{"start":{"line":36,"column":8},"end":{"line":38,"column":9}},"15":{"start":{"line":37,"column":12},"end":{"line":37,"column":20}},"16":{"start":{"line":39,"column":8},"end":{"line":41,"column":9}},"17":{"start":{"line":40,"column":12},"end":{"line":40,"column":20}},"18":{"start":{"line":42,"column":8},"end":{"line":50,"column":9}},"19":{"start":{"line":43,"column":12},"end":{"line":43,"column":44}},"20":{"start":{"line":44,"column":15},"end":{"line":50,"column":9}},"21":{"start":{"line":45,"column":12},"end":{"line":45,"column":22}},"22":{"start":{"line":46,"column":15},"end":{"line":50,"column":9}},"23":{"start":{"line":47,"column":12},"end":{"line":47,"column":52}},"24":{"start":{"line":49,"column":12},"end":{"line":49,"column":22}},"25":{"start":{"line":51,"column":8},"end":{"line":51,"column":39}},"26":{"start":{"line":60,"column":0},"end":{"line":72,"column":2}},"27":{"start":{"line":61,"column":4},"end":{"line":61,"column":28}},"28":{"start":{"line":63,"column":4},"end":{"line":66,"column":7}},"29":{"start":{"line":64,"column":8},"end":{"line":64,"column":43}},"30":{"start":{"line":65,"column":8},"end":{"line":65,"column":101}},"31":{"start":{"line":68,"column":4},"end":{"line":68,"column":19}},"32":{"start":{"line":69,"column":4},"end":{"line":69,"column":19}},"33":{"start":{"line":71,"column":4},"end":{"line":71,"column":41}},"34":{"start":{"line":81,"column":0},"end":{"line":92,"column":2}},"35":{"start":{"line":82,"column":4},"end":{"line":82,"column":16}},"36":{"start":{"line":83,"column":4},"end":{"line":83,"column":30}},"37":{"start":{"line":85,"column":4},"end":{"line":85,"column":19}},"38":{"start":{"line":86,"column":4},"end":{"line":86,"column":32}},"39":{"start":{"line":87,"column":4},"end":{"line":87,"column":37}},"40":{"start":{"line":88,"column":4},"end":{"line":88,"column":42}},"41":{"start":{"line":89,"column":4},"end":{"line":89,"column":37}},"42":{"start":{"line":91,"column":4},"end":{"line":91,"column":21}},"43":{"start":{"line":101,"column":0},"end":{"line":104,"column":2}},"44":{"start":{"line":102,"column":4},"end":{"line":102,"column":28}},"45":{"start":{"line":103,"column":4},"end":{"line":103,"column":36}},"46":{"start":{"line":112,"column":0},"end":{"line":115,"column":2}},"47":{"start":{"line":113,"column":4},"end":{"line":113,"column":28}},"48":{"start":{"line":114,"column":4},"end":{"line":114,"column":24}},"49":{"start":{"line":117,"column":0},"end":{"line":117,"column":27}}},"branchMap":{"1":{"line":12,"type":"if","locations":[{"start":{"line":12,"column":8},"end":{"line":12,"column":8}},{"start":{"line":12,"column":8},"end":{"line":12,"column":8}}]},"2":{"line":32,"type":"cond-expr","locations":[{"start":{"line":32,"column":22},"end":{"line":32,"column":33}},{"start":{"line":32,"column":36},"end":{"line":32,"column":49}}]},"3":{"line":36,"type":"if","locations":[{"start":{"line":36,"column":8},"end":{"line":36,"column":8}},{"start":{"line":36,"column":8},"end":{"line":36,"column":8}}]},"4":{"line":39,"type":"if","locations":[{"start":{"line":39,"column":8},"end":{"line":39,"column":8}},{"start":{"line":39,"column":8},"end":{"line":39,"column":8}}]},"5":{"line":42,"type":"if","locations":[{"start":{"line":42,"column":8},"end":{"line":42,"column":8}},{"start":{"line":42,"column":8},"end":{"line":42,"column":8}}]},"6":{"line":44,"type":"if","locations":[{"start":{"line":44,"column":15},"end":{"line":44,"column":15}},{"start":{"line":44,"column":15},"end":{"line":44,"column":15}}]},"7":{"line":46,"type":"if","locations":[{"start":{"line":46,"column":15},"end":{"line":46,"column":15}},{"start":{"line":46,"column":15},"end":{"line":46,"column":15}}]},"8":{"line":61,"type":"binary-expr","locations":[{"start":{"line":61,"column":14},"end":{"line":61,"column":21}},{"start":{"line":61,"column":25},"end":{"line":61,"column":27}}]},"9":{"line":64,"type":"binary-expr","locations":[{"start":{"line":64,"column":16},"end":{"line":64,"column":21}},{"start":{"line":64,"column":25},"end":{"line":64,"column":42}}]},"10":{"line":65,"type":"cond-expr","locations":[{"start":{"line":65,"column":76},"end":{"line":65,"column":90}},{"start":{"line":65,"column":93},"end":{"line":65,"column":100}}]},"11":{"line":71,"type":"binary-expr","locations":[{"start":{"line":71,"column":16},"end":{"line":71,"column":28}},{"start":{"line":71,"column":32},"end":{"line":71,"column":40}}]}}}}
{"/home/runner/work/cd/cd/package/lib/bkdr-hash.js":{"path":"/home/runner/work/cd/cd/package/lib/bkdr-hash.js","s":{"1":1,"2":8,"3":8,"4":8,"5":8,"6":8,"7":8,"8":360014,"9":356706,"10":360014,"11":8,"12":1},"b":{"1":[356706,3308]},"f":{"1":8},"fnMap":{"1":{"name":"(anonymous_1)","line":7,"loc":{"start":{"line":7,"column":15},"end":{"line":7,"column":29}}}},"statementMap":{"1":{"start":{"line":7,"column":0},"end":{"line":22,"column":2}},"2":{"start":{"line":8,"column":4},"end":{"line":8,"column":19}},"3":{"start":{"line":9,"column":4},"end":{"line":9,"column":20}},"4":{"start":{"line":10,"column":4},"end":{"line":10,"column":17}},"5":{"start":{"line":12,"column":4},"end":{"line":12,"column":15}},"6":{"start":{"line":14,"column":4},"end":{"line":14,"column":62}},"7":{"start":{"line":15,"column":4},"end":{"line":20,"column":5}},"8":{"start":{"line":16,"column":8},"end":{"line":18,"column":9}},"9":{"start":{"line":17,"column":12},"end":{"line":17,"column":42}},"10":{"start":{"line":19,"column":8},"end":{"line":19,"column":47}},"11":{"start":{"line":21,"column":4},"end":{"line":21,"column":16}},"12":{"start":{"line":24,"column":0},"end":{"line":24,"column":26}}},"branchMap":{"1":{"line":16,"type":"if","locations":[{"start":{"line":16,"column":8},"end":{"line":16,"column":8}},{"start":{"line":16,"column":8},"end":{"line":16,"column":8}}]}}},"/home/runner/work/cd/cd/package/lib/color-hash.js":{"path":"/home/runner/work/cd/cd/package/lib/color-hash.js","s":{"1":2,"2":2,"3":4,"4":4,"5":12,"6":3,"7":12,"8":4,"9":2,"10":7,"11":7,"12":7,"13":7,"14":21,"15":1,"16":21,"17":4,"18":21,"19":5,"20":16,"21":7,"22":9,"23":1,"24":8,"25":21,"26":1,"27":78937,"28":2,"29":26314,"30":26314,"31":52628,"32":52628,"33":26314,"34":26314,"35":26314,"36":1,"37":26314,"38":25,"39":26314,"40":5,"41":26314,"42":24840,"43":26314,"44":2,"45":26316,"46":26316,"47":26316,"48":22720,"49":22720,"50":22720,"51":3596,"52":26316,"53":26316,"54":26316,"55":26316,"56":26316,"57":2,"58":2,"59":2,"60":2,"61":1,"62":1,"63":2},"b":{"1":[3,9],"2":[4,3],"3":[1,20],"4":[4,17],"5":[5,16],"6":[7,9],"7":[1,8],"8":[26314,1],"9":[4,52624],"10":[52626,2],"11":[1,26313],"12":[25,26289],"13":[26314,26309],"14":[5,26309],"15":[110,24730],"16":[110,24730],"17":[26314,3],"18":[22720,3596]},"f":{"1":4,"2":12,"3":7,"4":21,"5":78937,"6":26314,"7":52628,"8":24840,"9":26316,"10":2,"11":1},"fnMap":{"1":{"name":"(anonymous_1)","line":9,"loc":{"start":{"line":9,"column":14},"end":{"line":9,"column":33}}},"2":{"name":"(anonymous_2)","line":11,"loc":{"start":{"line":11,"column":21},"end":{"line":11,"column":37}}},"3":{"name":"(anonymous_3)","line":29,"loc":{"start":{"line":29,"column":14},"end":{"line":29,"column":32}}},"4":{"name":"(anonymous_4)","line":35,"loc":{"start":{"line":35,"column":37},"end":{"line":35,"column":53}}},"5":{"name":"isArray","line":55,"loc":{"start":{"line":55,"column":0},"end":{"line":55,"column":20}}},"6":{"name":"(anonymous_6)","line":64,"loc":{"start":{"line":64,"column":16},"end":{"line":64,"column":34}}},"7":{"name":"(anonymous_7)","line":67,"loc":{"start":{"line":67,"column":57},"end":{"line":67,"column":73}}},"8":{"name":"(anonymous_8)","line":84,"loc":{"start":{"line":84,"column":37},"end":{"line":84,"column":54}}},"9":{"name":"(anonymous_9)","line":101,"loc":{"start":{"line":101,"column":26},"end":{"line":101,"column":40}}},"10":{"name":"(anonymous_10)","line":127,"loc":{"start":{"line":127,"column":26},"end":{"line":127,"column":40}}},"11":{"name":"(anonymous_11)","line":138,"loc":{"start":{"line":138,"column":26},"end":{"line":138,"column":40}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},"2":{"start":{"line":9,"column":0},"end":{"line":18,"column":2}},"3":{"start":{"line":10,"column":4},"end":{"line":10,"column":18}},"4":{"start":{"line":11,"column":4},"end":{"line":16,"column":7}},"5":{"start":{"line":12,"column":8},"end":{"line":14,"column":9}},"6":{"start":{"line":13,"column":12},"end":{"line":13,"column":21}},"7":{"start":{"line":15,"column":8},"end":{"line":15,"column":34}},"8":{"start":{"line":17,"column":4},"end":{"line":17,"column":15}},"9":{"start":{"line":29,"column":0},"end":{"line":53,"column":2}},"10":{"start":{"line":30,"column":4},"end":{"line":30,"column":13}},"11":{"start":{"line":32,"column":4},"end":{"line":32,"column":50}},"12":{"start":{"line":33,"column":4},"end":{"line":33,"column":22}},"13":{"start":{"line":35,"column":4},"end":{"line":52,"column":7}},"14":{"start":{"line":36,"column":8},"end":{"line":38,"column":9}},"15":{"start":{"line":37,"column":12},"end":{"line":37,"column":20}},"16":{"start":{"line":39,"column":8},"end":{"line":41,"column":9}},"17":{"start":{"line":40,"column":12},"end":{"line":40,"column":20}},"18":{"start":{"line":42,"column":8},"end":{"line":50,"column":9}},"19":{"start":{"line":43,"column":12},"end":{"line":43,"column":44}},"20":{"start":{"line":44,"column":15},"end":{"line":50,"column":9}},"21":{"start":{"line":45,"column":12},"end":{"line":45,"column":22}},"22":{"start":{"line":46,"column":15},"end":{"line":50,"column":9}},"23":{"start":{"line":47,"column":12},"end":{"line":47,"column":52}},"24":{"start":{"line":49,"column":12},"end":{"line":49,"column":22}},"25":{"start":{"line":51,"column":8},"end":{"line":51,"column":39}},"26":{"start":{"line":55,"column":0},"end":{"line":57,"column":1}},"27":{"start":{"line":56,"column":4},"end":{"line":56,"column":66}},"28":{"start":{"line":64,"column":0},"end":{"line":92,"column":2}},"29":{"start":{"line":65,"column":4},"end":{"line":65,"column":28}},"30":{"start":{"line":67,"column":4},"end":{"line":70,"column":7}},"31":{"start":{"line":68,"column":8},"end":{"line":68,"column":64}},"32":{"start":{"line":69,"column":8},"end":{"line":69,"column":57}},"33":{"start":{"line":72,"column":4},"end":{"line":72,"column":19}},"34":{"start":{"line":73,"column":4},"end":{"line":73,"column":19}},"35":{"start":{"line":75,"column":4},"end":{"line":77,"column":5}},"36":{"start":{"line":76,"column":8},"end":{"line":76,"column":59}},"37":{"start":{"line":78,"column":4},"end":{"line":80,"column":5}},"38":{"start":{"line":79,"column":8},"end":{"line":79,"column":36}},"39":{"start":{"line":81,"column":4},"end":{"line":83,"column":5}},"40":{"start":{"line":82,"column":8},"end":{"line":82,"column":25}},"41":{"start":{"line":84,"column":4},"end":{"line":89,"column":7}},"42":{"start":{"line":85,"column":8},"end":{"line":88,"column":10}},"43":{"start":{"line":91,"column":4},"end":{"line":91,"column":41}},"44":{"start":{"line":101,"column":0},"end":{"line":118,"column":2}},"45":{"start":{"line":102,"column":4},"end":{"line":102,"column":16}},"46":{"start":{"line":103,"column":4},"end":{"line":103,"column":30}},"47":{"start":{"line":105,"column":4},"end":{"line":111,"column":5}},"48":{"start":{"line":106,"column":8},"end":{"line":106,"column":65}},"49":{"start":{"line":107,"column":8},"end":{"line":107,"column":32}},"50":{"start":{"line":108,"column":8},"end":{"line":108,"column":115}},"51":{"start":{"line":110,"column":8},"end":{"line":110,"column":23}},"52":{"start":{"line":112,"column":4},"end":{"line":112,"column":32}},"53":{"start":{"line":113,"column":4},"end":{"line":113,"column":37}},"54":{"start":{"line":114,"column":4},"end":{"line":114,"column":42}},"55":{"start":{"line":115,"column":4},"end":{"line":115,"column":37}},"56":{"start":{"line":117,"column":4},"end":{"line":117,"column":21}},"57":{"start":{"line":127,"column":0},"end":{"line":130,"column":2}},"58":{"start":{"line":128,"column":4},"end":{"line":128,"column":28}},"59":{"start":{"line":129,"column":4},"end":{"line":129,"column":36}},"60":{"start":{"line":138,"column":0},"end":{"line":141,"column":2}},"61":{"start":{"line":139,"column":4},"end":{"line":139,"column":28}},"62":{"start":{"line":140,"column":4},"end":{"line":140,"column":24}},"63":{"start":{"line":143,"column":0},"end":{"line":143,"column":27}}},"branchMap":{"1":{"line":12,"type":"if","locations":[{"start":{"line":12,"column":8},"end":{"line":12,"column":8}},{"start":{"line":12,"column":8},"end":{"line":12,"column":8}}]},"2":{"line":32,"type":"cond-expr","locations":[{"start":{"line":32,"column":22},"end":{"line":32,"column":33}},{"start":{"line":32,"column":36},"end":{"line":32,"column":49}}]},"3":{"line":36,"type":"if","locations":[{"start":{"line":36,"column":8},"end":{"line":36,"column":8}},{"start":{"line":36,"column":8},"end":{"line":36,"column":8}}]},"4":{"line":39,"type":"if","locations":[{"start":{"line":39,"column":8},"end":{"line":39,"column":8}},{"start":{"line":39,"column":8},"end":{"line":39,"column":8}}]},"5":{"line":42,"type":"if","locations":[{"start":{"line":42,"column":8},"end":{"line":42,"column":8}},{"start":{"line":42,"column":8},"end":{"line":42,"column":8}}]},"6":{"line":44,"type":"if","locations":[{"start":{"line":44,"column":15},"end":{"line":44,"column":15}},{"start":{"line":44,"column":15},"end":{"line":44,"column":15}}]},"7":{"line":46,"type":"if","locations":[{"start":{"line":46,"column":15},"end":{"line":46,"column":15}},{"start":{"line":46,"column":15},"end":{"line":46,"column":15}}]},"8":{"line":65,"type":"binary-expr","locations":[{"start":{"line":65,"column":14},"end":{"line":65,"column":21}},{"start":{"line":65,"column":25},"end":{"line":65,"column":27}}]},"9":{"line":68,"type":"cond-expr","locations":[{"start":{"line":68,"column":38},"end":{"line":68,"column":43}},{"start":{"line":68,"column":46},"end":{"line":68,"column":63}}]},"10":{"line":69,"type":"cond-expr","locations":[{"start":{"line":69,"column":32},"end":{"line":69,"column":46}},{"start":{"line":69,"column":49},"end":{"line":69,"column":56}}]},"11":{"line":75,"type":"if","locations":[{"start":{"line":75,"column":4},"end":{"line":75,"column":4}},{"start":{"line":75,"column":4},"end":{"line":75,"column":4}}]},"12":{"line":78,"type":"if","locations":[{"start":{"line":78,"column":4},"end":{"line":78,"column":4}},{"start":{"line":78,"column":4},"end":{"line":78,"column":4}}]},"13":{"line":78,"type":"binary-expr","locations":[{"start":{"line":78,"column":8},"end":{"line":78,"column":39}},{"start":{"line":78,"column":43},"end":{"line":78,"column":64}}]},"14":{"line":81,"type":"if","locations":[{"start":{"line":81,"column":4},"end":{"line":81,"column":4}},{"start":{"line":81,"column":4},"end":{"line":81,"column":4}}]},"15":{"line":86,"type":"cond-expr","locations":[{"start":{"line":86,"column":52},"end":{"line":86,"column":53}},{"start":{"line":86,"column":56},"end":{"line":86,"column":65}}]},"16":{"line":87,"type":"cond-expr","locations":[{"start":{"line":87,"column":52},"end":{"line":87,"column":55}},{"start":{"line":87,"column":57},"end":{"line":87,"column":66}}]},"17":{"line":91,"type":"binary-expr","locations":[{"start":{"line":91,"column":16},"end":{"line":91,"column":28}},{"start":{"line":91,"column":32},"end":{"line":91,"column":40}}]},"18":{"line":105,"type":"if","locations":[{"start":{"line":105,"column":4},"end":{"line":105,"column":4}},{"start":{"line":105,"column":4},"end":{"line":105,"column":4}}]}}}}

@@ -10,3 +10,3 @@ var addSorting = (function () {

// returns the summary table element
function getTable() { return document.querySelector('.coverage-summary table'); }
function getTable() { return document.querySelector('.coverage-summary'); }
// returns the thead element of the summary table

@@ -136,3 +136,5 @@ function getTableHeader() { return getTable().querySelector('thead tr'); }

if (cols[i].sortable) {
el = getNthColumn(i).querySelector('.sorter');
// add the click event handler on the th so users
// dont have to click on those tiny arrows
el = getNthColumn(i).querySelector('.sorter').parentElement;
if (el.addEventListener) {

@@ -139,0 +141,0 @@ el.addEventListener('click', ithSorter(i));

@@ -1,2 +0,2 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.ColorHash=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ColorHash = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/**

@@ -82,2 +82,6 @@ * BKDR Hash (modified version)

function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
}
/**

@@ -92,4 +96,4 @@ * Color Hash Class

var LS = [options.lightness, options.saturation].map(function(param) {
param = param || [0.35, 0.5, 0.65]; // note that 3 is a prime
return Object.prototype.toString.call(param) === '[object Array]' ? param.concat() : [param];
param = param !== undefined ? param : [0.35, 0.5, 0.65]; // note that 3 is a prime
return isArray(param) ? param.concat() : [param];
});

@@ -100,2 +104,18 @@

if (typeof options.hue === 'number') {
options.hue = {min: options.hue, max: options.hue};
}
if (typeof options.hue === 'object' && !isArray(options.hue)) {
options.hue = [options.hue];
}
if (typeof options.hue === 'undefined') {
options.hue = [];
}
this.hueRanges = options.hue.map(function (range) {
return {
min: typeof range.min === 'undefined' ? 0 : range.min,
max: typeof range.max === 'undefined' ? 360: range.max
};
});
this.hash = options.hash || BKDRHash;

@@ -115,3 +135,9 @@ };

H = hash % 359; // note that 359 is a prime
if (this.hueRanges.length) {
var range = this.hueRanges[hash % this.hueRanges.length];
var hueResolution = 727; // note that 727 is a prime
H = ((hash / this.hueRanges.length) % hueResolution) * (range.max - range.min) / hueResolution + range.min;
} else {
H = hash % 359; // note that 359 is a prime
}
hash = parseInt(hash / 360);

@@ -151,2 +177,2 @@ S = this.S[hash % this.S.length];

},{"./bkdr-hash":1}]},{},[2])(2)
});
});

@@ -55,2 +55,6 @@ var BKDRHash = require('./bkdr-hash');

function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
}
/**

@@ -65,4 +69,4 @@ * Color Hash Class

var LS = [options.lightness, options.saturation].map(function(param) {
param = param || [0.35, 0.5, 0.65]; // note that 3 is a prime
return Object.prototype.toString.call(param) === '[object Array]' ? param.concat() : [param];
param = param !== undefined ? param : [0.35, 0.5, 0.65]; // note that 3 is a prime
return isArray(param) ? param.concat() : [param];
});

@@ -73,2 +77,18 @@

if (typeof options.hue === 'number') {
options.hue = {min: options.hue, max: options.hue};
}
if (typeof options.hue === 'object' && !isArray(options.hue)) {
options.hue = [options.hue];
}
if (typeof options.hue === 'undefined') {
options.hue = [];
}
this.hueRanges = options.hue.map(function (range) {
return {
min: typeof range.min === 'undefined' ? 0 : range.min,
max: typeof range.max === 'undefined' ? 360: range.max
};
});
this.hash = options.hash || BKDRHash;

@@ -88,3 +108,9 @@ };

H = hash % 359; // note that 359 is a prime
if (this.hueRanges.length) {
var range = this.hueRanges[hash % this.hueRanges.length];
var hueResolution = 727; // note that 727 is a prime
H = ((hash / this.hueRanges.length) % hueResolution) * (range.max - range.min) / hueResolution + range.min;
} else {
H = hash % 359; // note that 359 is a prime
}
hash = parseInt(hash / 360);

@@ -91,0 +117,0 @@ S = this.S[hash % this.S.length];

{
"name": "color-hash",
"version": "1.0.3",
"version": "1.1.1",
"description": "Generate color based on the given string (using HSL color space and BKDRHash).",
"main": "lib/color-hash.js",
"scripts": {
"prepublishOnly": "npm run test && npm run build",
"build": "browserify lib/color-hash.js -s ColorHash -o dist/color-hash.js",

@@ -20,4 +21,9 @@ "test": "istanbul cover _mocha"

"devDependencies": {
"rewire": "^2.1.5"
}
"browserify": "^14.4.0",
"istanbul": "^0.4.5",
"mocha": "^8.3.2",
"rewire": "^2.1.5",
"string-hash": "^1.1.3"
},
"dependencies": {}
}

@@ -14,9 +14,9 @@ # Color Hash

```bash
bower install color-hash
npm install color-hash
```
A UMD version of ColorHash was located in dist/.
A UMD version of ColorHash is located in `dist/`.
Note that Array.prototype.map was used in color-hash,
a pollfill must be provided if you want to use it in IE8.
Note that `Array.prototype.map` is used in `color-hash`,
a polyfill must be provided if you want to use it in IE8.

@@ -29,9 +29,9 @@ #### Basic

// in HSL, Hue ∈ [0, 360), Saturation ∈ [0, 1], Lightness ∈ [0, 1]
colorHash.hsl('Hello World'); // [ 235, 0.65, 0.35 ]
colorHash.hsl('Hello World'); // [ 225, 0.65, 0.35 ]
// in RGB, R, G, B ∈ [0, 255]
colorHash.rgb('Hello World'); // [ 31, 41, 147 ]
colorHash.rgb('Hello World'); // [ 135, 150, 197 ]
// in HEX
colorHash.hex('Hello World'); // '#1f2993'
colorHash.hex('Hello World'); // '#8796c5'
```

@@ -55,2 +55,16 @@

#### Custom Hue
```javascript
var colorHash = new ColorHash({hue: 90});
```
```javascript
var colorHash = new ColorHash({hue: {min: 90, max: 270}});
```
```javascript
var colorHash = new ColorHash({hue: [ {min: 30, max: 90}, {min: 180, max: 210}, {min: 270, max: 285} ]});
```
#### Custom Lightness

@@ -76,3 +90,3 @@

### Node.JS
### Node.js

@@ -95,3 +109,3 @@ ```bash

Use the hash function (default is BKDRHash) to calculate the hash of the given string,
It uses the `hash` function (default is BKDRHash) to calculate the hash of the given string.

@@ -117,4 +131,3 @@ ```

```bash
sudo npm install -g mocha
sudo npm install -g istanbul
npm install
npm test

@@ -130,3 +143,3 @@ ```

```bash
sudo npm install -g browserify
npm install
npm run build

@@ -133,0 +146,0 @@ ```

var assert = require('assert');
var rewire = require('rewire');
var ColorHash = rewire('../lib/color-hash');
var stringHash = require('string-hash');
var HSL2RGB = ColorHash.__get__('HSL2RGB');
var RGB2HEX = ColorHash.__get__('RGB2HEX');
describe('ColorHash', function() {
function assertHueWithinRange(options, expectedRange) {
return assertHueWithinRanges(options, [expectedRange]);
}
describe('#Lightness & Saturation', function() {
function assertHueWithinRanges(options, ranges) {
options = options || {};
if (typeof ranges === 'undefined' || !ranges.length || !ranges[0]) {
ranges = [{}];
}
options.hash = stringHash; // This hash function spreads its results more
it('should return the hash color based on default lightness and saturation', function() {
function hueOf(s) {
var colorHash = new ColorHash(options);
var hsl = colorHash.hsl(s);
return hsl[0];
}
ranges = ranges.map(function (range) {
return {
min: range.min,
max: range.max,
size: range.max - range.min,
minSeen: 1000,
maxSeen: -1000
};
});
var totalSize = ranges.reduce(function (sum, range) {
return sum + range.size;
}, 0);
var iterations = 10 * (totalSize + 1);
var hue;
for (var i = 0; i < iterations; i++) {
hue = hueOf('This is some padding, and then a counter: ' + i);
assert.ok(hue >= 0 || hue < 360, JSON.stringify(ranges, null, 2) + ' hue=' + hue + ' is outside parameters');
var withinAtLeastOneRange = ranges.reduce(function(withinAnyRangeYet, range) {
var withinThisRange = hue >= range.min && hue <= range.max;
if (withinThisRange) {
range.minSeen = Math.min(range.minSeen, hue);
range.maxSeen = Math.max(range.maxSeen, hue);
}
return withinAnyRangeYet || withinThisRange;
}, false);
assert.ok(withinAtLeastOneRange, JSON.stringify(ranges, null, 2) + ' hue=' + hue + ' is not within any range.');
}
ranges.forEach(function(range) {
assert.equal(Math.round(range.minSeen), range.min, '{min: ' + range.min + ', max: ' + range.max + '} actual minSeen=' + range.minSeen);
assert.equal(Math.round(range.maxSeen), range.max, '{min: ' + range.min + ', max: ' + range.max + '} actual maxSeen=' + range.maxSeen);
});
}
describe('ColorHash', function () {
describe('#Hue', function () {
it('should return the hash color based on default hue', function () {
assertHueWithinRange(undefined, {min: 0, max: 358}); // hash % 359 means maximum 358
});
it('should return the hash color based on numeric hue', function () {
assertHueWithinRange({hue: 10}, {min: 10, max: 10});
});
it('should return the hash color based on same min, max', function () {
var range = {min: 10, max: 10};
assertHueWithinRange({hue: range}, range);
});
it('should return the hash color based on the given hue {min, max}', function () {
var min, max, range;
for (min = 0; min < 361; min += 60) {
for (max = min + 1; max < 361; max += 60) {
range = {min: min, max: max};
assertHueWithinRange({hue: range}, range);
}
}
});
it('should have default value for min if only max is set', function () {
assertHueWithinRange({hue: {max: 10}}, {min: 0, max: 10});
});
it('should have default value for max if only min is set', function () {
assertHueWithinRange({hue: {min: 350}}, {min: 350, max: 360});
});
it('should return the hash color based on different hue ranges', function () {
var ranges = [
{min: 30, max: 90},
{min: 180, max: 210},
{min: 270, max: 285}
];
assertHueWithinRanges({hue: ranges}, ranges);
});
});
describe('#Lightness & Saturation', function () {
it('should return the hash color based on default lightness and saturation', function () {
var colorHash = new ColorHash();

@@ -18,3 +113,3 @@ var hsl = colorHash.hsl('');

it('should return the hash color based on the given lightness and saturation', function() {
it('should return the hash color based on the given lightness and saturation', function () {
var colorHash = new ColorHash({lightness: 0.5, saturation: 0.5});

@@ -25,3 +120,3 @@ var hsl = colorHash.hsl('');

it('should return the hash color based on the given lightness array and saturation array', function() {
it('should return the hash color based on the given lightness array and saturation array', function () {
var colorHash = new ColorHash({

@@ -36,6 +131,6 @@ lightness: [0.9, 1],

describe('#CustomHash', function() {
var customHash = function(str) {
describe('#CustomHash', function () {
var customHash = function (str) {
var hash = 0;
for(var i = 0; i < str.length; i++) {
for (var i = 0; i < str.length; i++) {
hash += str.charCodeAt(i);

@@ -50,9 +145,9 @@ }

it('#hsl: should return the hsl color based on the given hash function', function() {
it('#hsl: should return the hsl color based on the given hash function', function () {
assert.deepEqual(colorHash.hsl('abc'), hsl);
});
it('#rgb: should return the rgb color based on the given hash function', function() {
it('#rgb: should return the rgb color based on the given hash function', function () {
assert.deepEqual(colorHash.rgb('abc'), rgb);
});
it('#hex: should return the hex color based on the given hash function', function() {
it('#hex: should return the hex color based on the given hash function', function () {
assert.deepEqual(colorHash.hex('abc'), hex);

@@ -59,0 +154,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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