lib/module.js
function getFirstViableCandidate(candidates) {
    for( const candidate of candidates) {
        const fileJS = `${candidate}.js`;
        if( Fs.existsSync(fileJS) ) return candidate;
        const fileXJS = `${candidate}.xjs`;
        if( Fs.existsSync(fileXJS) ) return candidate;
    }

    return candidates[0];
}
function getFirstViableCandidate(candidates) {
    for( const candidate of candidates) {
        const fileJS = `${candidate}.js`;
        if( Fs.existsSync(fileJS) ) return candidate;
        const fileXJS = `${candidate}.xjs`;
        if( Fs.existsSync(fileXJS) ) return candidate;
    }

    return candidates[0];
}
function getFirstViableCandidate ( candidates ) { for ( const candidate of candidates ) { const fileJS = ` ${ candidate } ` ; if ( Fs . existsSync ( fileJS ) ) return candidate ; const fileXJS = ` ${ candidate } ` ; if ( Fs . existsSync ( fileXJS ) ) return candidate ; } return candidates [ 0 ] ; }
A candidate is viable if the `js` or the `xjs` file exists.

@param {array} candidates - Pathes of module files (without extension).
@returns {string} The first candidate if no module has been found.
A candidate is viable if the js or the xjs file exists .