All files RouterOptions.js

100% Statements 11/11
100% Branches 6/6
100% Functions 4/4
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26        160x     159x 1x 158x 157x   1x     159x 159x       492x 53x        
import Options from './Options.js';
 
export default class RouterOptions extends Options {
    constructor (rawOptions) {
        super(rawOptions);
 
        let processMatchObjects;
        if (typeof rawOptions.processMatchObjects === 'function') {
            processMatchObjects = rawOptions.processMatchObjects;
        } else if (!rawOptions.hasOwnProperty('processMatchObjects') || rawOptions.processMatchObjects) {
            processMatchObjects = RouterOptions.sortMatchObjects;
        } else {
            processMatchObjects = (matchObjects) => matchObjects;
        }
 
        this.processMatchObjects = processMatchObjects;
        RouterOptions.setBooleanOption(this, 'onlyRoute', rawOptions, {onlyRoute: false});
    }
 
    static sortMatchObjects (matchObjects) {
        return matchObjects.sort((matchObject1, matchObject2) => {
            return matchObject2.options.priority - matchObject1.options.priority;
        });
    }
}