index.js
function getProperties (header) {
    return header.split(',').map((split) => {
        const components = split.replace(/\s+/, '').split(';');
        const priorityRegex = /^q=([0-1](\.[0-9]{1,3})?)$/;

        /* assign null to priority when invaild quarity values */
        return {
            lang: components[0],
            priority: components[1] ? priorityRegex.test(components[1]) ? parseFloat(components[1].split('=')[1]) : null : 1
        }
    }).filter((property) => {
        return property.priority === null ? false : bcp47.check(property.lang);
    }).sort((a, b) => {
        return a.priority < b.priority ? 1 : a.priority > b.priority ? -1 : 0;
    });
}
function getProperties (header) {
    return header.split(',').map((split) => {
        const components = split.replace(/\s+/, '').split(';');
        const priorityRegex = /^q=([0-1](\.[0-9]{1,3})?)$/;

        /* assign null to priority when invaild quarity values */
        return {
            lang: components[0],
            priority: components[1] ? priorityRegex.test(components[1]) ? parseFloat(components[1].split('=')[1]) : null : 1
        }
    }).filter((property) => {
        return property.priority === null ? false : bcp47.check(property.lang);
    }).sort((a, b) => {
        return a.priority < b.priority ? 1 : a.priority > b.priority ? -1 : 0;
    });
}
function getProperties ( header ) { return header . split ( ',' ) . map ( ( split ) => { const components = split . replace ( / \s+ / , '' ) . split ( ';' ) ; const priorityRegex = / ^q=([0-1](\.[0-9]{1,3})?)$ / ; /* assign null to priority when invaild quarity values */ return { lang : components [ 0 ] , priority : components [ 1 ] ? priorityRegex . test ( components [ 1 ] ) ? parseFloat ( components [ 1 ] . split ( '=' ) [ 1 ] ) : null : 1 } } ) . filter ( ( property ) => { return property . priority === null ? false : bcp47 . check ( property . lang ) ; } ) . sort ( ( a , b ) => { return a . priority < b . priority ? 1 : a . priority > b . priority ? - 1 : 0 ; } ) ; }
analyze HTTP accept-language header
@param  {string} header
@return {array}
analyze HTTP accept - language header