Closed tobsn closed 12 years ago
The "memory-efficient structure" of this library uses the JavaScript prototype chain to look up the data as it is inherited down through a chain of phone entries. Because of this you will not see the full tree using console.log(deviceInfo). You are still able to get at the data (e.g. console.log(deviceInfo.display.physical_screen_height == 74
in the lookup for the user agent you provided above).
If you want to see the properties in a given object you may do a for-i-in.
var wurfl = require( 'wurfl' );
var options = { file: __dirname + '/wurfl.xml', groups: [ 'display' ] };
wurfl.loadSync( options ); // wurfl xml file is finished loading into a memory-efficient structure
var deviceInfo = wurfl.get( 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3' );
for (var i in deviceInfo.display) {
console.log(i, '=', deviceInfo.display[i]);
}
A couple of other things to note.
wurfl.loadSync( options );
Asynchronous: wurfl.load( function() {
...
You are doing both, so loading and parsing two files, the second old one is overwriting the one in your directory.groups: [ 'display' ]
you will only have the display object populated. If you want everything then leave out the groups option entirely. I'm not sure if you meant this or not.
Code:
Result:
same happens with the example XDA string - a fallback and an id is returned and that's where it stops. I think the solution would be to follow up up the fallback or id.
just cloned the git to be sure to have latest and checked against latest wurfl.xml and supplied wurfl.xml and both not return more data than pasted above.