Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/color-convert/route.js

    rd565449 r0c6b92a  
    1 var conversions = require('./conversions');
     1const conversions = require('./conversions');
    22
    33/*
    4         this function routes a model to all other models.
     4        This function routes a model to all other models.
    55
    66        all functions that are routed have a property `.conversion` attached
     
    1313
    1414function buildGraph() {
    15         var graph = {};
     15        const graph = {};
    1616        // https://jsperf.com/object-keys-vs-for-in-with-closure/3
    17         var models = Object.keys(conversions);
     17        const models = Object.keys(conversions);
    1818
    19         for (var len = models.length, i = 0; i < len; i++) {
     19        for (let len = models.length, i = 0; i < len; i++) {
    2020                graph[models[i]] = {
    2121                        // http://jsperf.com/1-vs-infinity
     
    3131// https://en.wikipedia.org/wiki/Breadth-first_search
    3232function deriveBFS(fromModel) {
    33         var graph = buildGraph();
    34         var queue = [fromModel]; // unshift -> queue -> pop
     33        const graph = buildGraph();
     34        const queue = [fromModel]; // Unshift -> queue -> pop
    3535
    3636        graph[fromModel].distance = 0;
    3737
    3838        while (queue.length) {
    39                 var current = queue.pop();
    40                 var adjacents = Object.keys(conversions[current]);
     39                const current = queue.pop();
     40                const adjacents = Object.keys(conversions[current]);
    4141
    42                 for (var len = adjacents.length, i = 0; i < len; i++) {
    43                         var adjacent = adjacents[i];
    44                         var node = graph[adjacent];
     42                for (let len = adjacents.length, i = 0; i < len; i++) {
     43                        const adjacent = adjacents[i];
     44                        const node = graph[adjacent];
    4545
    4646                        if (node.distance === -1) {
     
    6262
    6363function wrapConversion(toModel, graph) {
    64         var path = [graph[toModel].parent, toModel];
    65         var fn = conversions[graph[toModel].parent][toModel];
     64        const path = [graph[toModel].parent, toModel];
     65        let fn = conversions[graph[toModel].parent][toModel];
    6666
    67         var cur = graph[toModel].parent;
     67        let cur = graph[toModel].parent;
    6868        while (graph[cur].parent) {
    6969                path.unshift(graph[cur].parent);
     
    7777
    7878module.exports = function (fromModel) {
    79         var graph = deriveBFS(fromModel);
    80         var conversion = {};
     79        const graph = deriveBFS(fromModel);
     80        const conversion = {};
    8181
    82         var models = Object.keys(graph);
    83         for (var len = models.length, i = 0; i < len; i++) {
    84                 var toModel = models[i];
    85                 var node = 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];
    8686
    8787                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.
    8989                        continue;
    9090                }
Note: See TracChangeset for help on using the changeset viewer.