Changeset 0c6b92a for imaps-frontend/node_modules/color-convert/route.js
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/color-convert/route.js
rd565449 r0c6b92a 1 varconversions = require('./conversions');1 const conversions = require('./conversions'); 2 2 3 3 /* 4 this function routes a model to all other models.4 This function routes a model to all other models. 5 5 6 6 all functions that are routed have a property `.conversion` attached … … 13 13 14 14 function buildGraph() { 15 vargraph = {};15 const graph = {}; 16 16 // https://jsperf.com/object-keys-vs-for-in-with-closure/3 17 varmodels = Object.keys(conversions);17 const models = Object.keys(conversions); 18 18 19 for ( varlen = models.length, i = 0; i < len; i++) {19 for (let len = models.length, i = 0; i < len; i++) { 20 20 graph[models[i]] = { 21 21 // http://jsperf.com/1-vs-infinity … … 31 31 // https://en.wikipedia.org/wiki/Breadth-first_search 32 32 function deriveBFS(fromModel) { 33 vargraph = buildGraph();34 var queue = [fromModel]; // unshift -> queue -> pop33 const graph = buildGraph(); 34 const queue = [fromModel]; // Unshift -> queue -> pop 35 35 36 36 graph[fromModel].distance = 0; 37 37 38 38 while (queue.length) { 39 varcurrent = queue.pop();40 varadjacents = Object.keys(conversions[current]);39 const current = queue.pop(); 40 const adjacents = Object.keys(conversions[current]); 41 41 42 for ( varlen = adjacents.length, i = 0; i < len; i++) {43 varadjacent = adjacents[i];44 varnode = graph[adjacent];42 for (let len = adjacents.length, i = 0; i < len; i++) { 43 const adjacent = adjacents[i]; 44 const node = graph[adjacent]; 45 45 46 46 if (node.distance === -1) { … … 62 62 63 63 function wrapConversion(toModel, graph) { 64 varpath = [graph[toModel].parent, toModel];65 varfn = conversions[graph[toModel].parent][toModel];64 const path = [graph[toModel].parent, toModel]; 65 let fn = conversions[graph[toModel].parent][toModel]; 66 66 67 varcur = graph[toModel].parent;67 let cur = graph[toModel].parent; 68 68 while (graph[cur].parent) { 69 69 path.unshift(graph[cur].parent); … … 77 77 78 78 module.exports = function (fromModel) { 79 vargraph = deriveBFS(fromModel);80 varconversion = {};79 const graph = deriveBFS(fromModel); 80 const conversion = {}; 81 81 82 varmodels = Object.keys(graph);83 for ( varlen = models.length, i = 0; i < len; i++) {84 vartoModel = models[i];85 varnode = graph[toModel];82 const models = Object.keys(graph); 83 for (let len = models.length, i = 0; i < len; i++) { 84 const toModel = models[i]; 85 const node = graph[toModel]; 86 86 87 87 if (node.parent === null) { 88 // no possible conversion, or this node is the source model.88 // No possible conversion, or this node is the source model. 89 89 continue; 90 90 }
Note:
See TracChangeset
for help on using the changeset viewer.