kolor.js
function getConverters(from, to) {
        if (from === to) {
            return [];
        }

        if (CONVERTERS[from][to]) {
            return [to];
        }

        var queue = [from];
        var path = {};
        path[from] = [];

        while (queue.length) {
            var v = queue.shift();
            for (var w in CONVERTERS[v]) {
                if (!path[w]) {
                    queue.push(w);
                    path[w] = path[v].concat([w]);
                    if (w === to) {
                        return path[w];
                    }
                }
            }
        }

        return null;
    }
function getConverters(from, to) {
        if (from === to) {
            return [];
        }

        if (CONVERTERS[from][to]) {
            return [to];
        }

        var queue = [from];
        var path = {};
        path[from] = [];

        while (queue.length) {
            var v = queue.shift();
            for (var w in CONVERTERS[v]) {
                if (!path[w]) {
                    queue.push(w);
                    path[w] = path[v].concat([w]);
                    if (w === to) {
                        return path[w];
                    }
                }
            }
        }

        return null;
    }
function getConverters ( from , to ) { if ( from === to ) { return [ ] ; } if ( CONVERTERS [ from ] [ to ] ) { return [ to ] ; } var queue = [ from ] ; var path = { } ; path [ from ] = [ ] ; while ( queue . length ) { var v = queue . shift ( ) ; for ( var w in CONVERTERS [ v ] ) { if ( ! path [ w ] ) { queue . push ( w ) ; path [ w ] = path [ v ] . concat ( [ w ] ) ; if ( w === to ) { return path [ w ] ; } } } } return null ; }
Breadth-first search to find the conversion path
Breadth - first search to find the conversion path