nl_tokens: Gets the detected options .
pl_tokens: function getDetectedOptions ( detected , handlers ) { var options = { } ; Object . keys ( detected ) . forEach ( function ( option ) { // List of all the detected variants from the stylesheet // for the given option: var values = detected [ option ] ; var i ; if ( ! values . length ) { // If there are no values for the option, check if there is // a default one: for ( i = handlers . length ; i -- ; ) { if ( handlers [ i ] . name === option && handlers [ i ] . detectDefault !== undefined ) { options [ option ] = handlers [ i ] . detectDefault ; break ; } } } else if ( values . length === 1 ) { options [ option ] = <mask> [ 0 ] ; } else { // If there are more than one value for the option, find // the most popular one; `variants` would be populated // with the popularity for different values. var variants = { } ; var bestGuess = null ; var maximum = 0 ; for ( i = values . length ; i -- ; ) { var currentValue = values [ i ] ; // Count the current value: if ( variants [ currentValue ] ) { variants [ currentValue ] ++ ; } else { variants [ currentValue ] = 1 ; } // If the current variant is the most popular one, treat // it as the best guess: if ( variants [ currentValue ] >= maximum ) { maximum = variants [ currentValue ] ; bestGuess = currentValue ; } } if ( bestGuess !== null ) { options [ option ] = bestGuess ; } } } ) ; return options ; }