{"_id":"wurfl","_rev":"11-cd6f961535c9d9cad95cc1ad97cb057e","name":"wurfl","description":"NodeJS library for loading Wireless Universal Resource File (wurfl) xml file efficiently into memory for use in applications that need to lookup mobile device capabilities by their user agent.","dist-tags":{"latest":"0.3.1"},"versions":{"0.1.0":{"name":"wurfl","author":{"name":"Jacob Wright","email":"jacwright@gmail.com","url":"jacwright.com"},"version":"0.1.0","main":"./lib/wurfl","description":"NodeJS library for loading Wireless Universal Resource File (wurfl) xml file efficiently into memory for use in applications that need to lookup mobile device capabilities by their user agent.","scripts":{"test":"node test/test.js"},"dependencies":{"node-expat":"1.4.0","webworker":"0.8.4"},"homepage":"https://github.com/touchads/node-wurfl-api","repository":{"type":"git","url":"git://github.com/touchads/node-wurfl-api.git"},"_npmJsonOpts":{"file":"/Users/jacob.wright/.npm/wurfl/0.1.0/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"wurfl@0.1.0","devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.18","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"e5ec27036a342588d93c7ebf4d8f1c6acc2c49bd","tarball":"https://registry.npmjs.org/wurfl/-/wurfl-0.1.0.tgz","integrity":"sha512-7xHGyVbnSufps8qDu13qke7Wjwb0lRlFMoDKohjK9G7ZrHS0eJH+3aBYwSQb50cOZxNggyxjythOYwjJQVji3g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4S7Sv9zvtS3av0fxQtXycDm7UZkrSmIQGp+r1FWdBKwIgM3xQORxOD4pRqTe+EpDIn71F4e7UWMnmTvc4jCdikOY="}]},"maintainers":[{"name":"jacwright","email":"jacwright@gmail.com"}]},"0.2.0":{"name":"wurfl","author":{"name":"Jacob Wright","email":"jacwright@gmail.com","url":"jacwright.com"},"version":"0.2.0","main":"./lib/wurfl","description":"NodeJS library for loading Wireless Universal Resource File (wurfl) xml file efficiently into memory for use in applications that need to lookup mobile device capabilities by their user agent.","scripts":{"test":"node test/test.js"},"dependencies":{"node-expat":"1.4.0","webworker":"0.8.4"},"homepage":"https://github.com/touchads/node-wurfl-api","repository":{"type":"git","url":"git://github.com/touchads/node-wurfl-api.git"},"_npmJsonOpts":{"file":"/Users/jacob.wright/.npm/wurfl/0.2.0/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"wurfl@0.2.0","devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.18","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"5af74db478b3ba7758333b5515425a5c67202f8d","tarball":"https://registry.npmjs.org/wurfl/-/wurfl-0.2.0.tgz","integrity":"sha512-pbvj5QporQ1StGxyGfR0eRwv/KiJihZIjGiXOqevVf6TyzAgKNGDv+2ZCzd5xg3iHvovOcMT534h3aDqbkWOiA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICB16Cqw+hh9b3mwzCxFPCcKwOgrHV1r1o17zfIe46gxAiBdqfESdhC9wy9C9Te2KrumV7ywnu2wlfoTi0yo8mvtxQ=="}]},"maintainers":[{"name":"jacwright","email":"jacwright@gmail.com"}]},"0.3.0":{"name":"wurfl","author":{"name":"Jacob Wright","email":"jacwright@gmail.com","url":"jacwright.com"},"version":"0.3.0","main":"./lib/wurfl","description":"NodeJS library for loading Wireless Universal Resource File (wurfl) xml file efficiently into memory for use in applications that need to lookup mobile device capabilities by their user agent.","scripts":{"test":"node test/test.js"},"dependencies":{"node-expat":"1.4.1","backgrounder":"0.2.7"},"homepage":"https://github.com/touchads/node-wurfl-api","repository":{"type":"git","url":"git://github.com/touchads/node-wurfl-api.git"},"_npmUser":{"name":"jacwright","email":"jacwright@gmail.com"},"_id":"wurfl@0.3.0","devDependencies":{},"engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.1.0-beta-10","_nodeVersion":"v0.6.7","_defaultsLoaded":true,"dist":{"shasum":"3c0b2e6777bc5f7f354034e54cd0351d8292f040","tarball":"https://registry.npmjs.org/wurfl/-/wurfl-0.3.0.tgz","integrity":"sha512-jmCD5a7/FzKVe2F0BS1vmDoHnqElPzuGeeCmU3cT+KZopQnT57Ll2C9QWNxdILBj6e/eRoToYH+l39rmJKRpBQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDVWWF7utoGBRjb7nHDfUhp1PL6111qqBR0qf5f+8SwUAIhANPJg1SmaDW0zQx7bK4RtvjZeWouRc2CLP164wWoO+DG"}]},"readme":"wurfl.js\n========\n\nwurfl.js is a node.js library to make it easy to use wurfl. What is wurfl? From the site http://wurfl.sourceforge.net/:\n\n```\nWURFL is a Device Description Repository (DDR), i.e. a software\ncomponent which contains the descriptions of thousands of mobile\ndevices. In its simplest incarnation, WURFL is an XML\nconfiguration file plus a set of programming APIs to access the\ndata in real-time environments.\n```\n\nUsage\n-----\n\n### Installation\n\nInstall node.js (http://nodejs.org) first, then npm (http://npmjs.org), then:\n\n```bash\nnpm install wurfl\n```\n\n### Usage\n\nBasic usage allows getting up and running quickly.\n\n```javascript\nvar wurfl = require('wurfl');\n\nwurfl.loadSync();\n\n// wurfl xml file is finished loading into a memory-efficient structure\n\nvar userAgent = 'Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; O2 Xda 2s;PPC;240x320; PPC; 240x320)';\nvar deviceInfo = wurfl.get(userAgent);\nconsole.log(deviceInfo.model_name); // \"Xda IIs\"\n```\n\nYou may want to use your own (read \"updated\") wurfl.xml file. This is easy:\n\n```javascript\nvar wurflFile = __dirname + '/wurfl.xml';\nwurfl.loadSync(wurflFile);\n```\n\nLoading and parsing a large xml file can be take awhile and be CPU-heavy. You may use load() to asynchronously load the xml file:\n\n```javascript\nwurfl.load(function() {\n\t// ready to use, wurfl.get(userAgent);\n});\n```\n\nOr with your own xml file:\n\n```javascript\nwurfl.load(myWurflFile, function() {\n\t// my own file\n});\n```\n\nWhen using your own file, it would be great to update the file without needing to restart the node.js server:\n\n```javascript\nwurfl.watch(myWurflFile);\n```\n\nWhen updating using watch it will always be asynchronous. The data structure will be updated automatically when the file is changed. You may also be notified when that happens if you want to know when it gets updated:\n\n```javascript\nwurfl.watch(myWurflFile, function() {\n\tconsole.log('XML file updated');\n});\n```\n\nIf you want to reduce memory usage even further, you can specify the the groups you are interested in, the rest will be left out completely. For example, if you only care about the \"display\" capabilities:\n\n```javascript\nwurfl.loadSync({ groups: [ 'display' ] });\n```\n\nWhen specifying groups the \"file\" parameter needs to be an options hash with `groups` and optionally `file`. You can use this in loadSync(options), load(options, callback), and watch(options, callback).\n\n```javascript\nvar options = { file: __dirname + '/wurfl.xml', groups: [ 'display' ] };\nwurfl.loadSync(options);\nwurfl.watch(options);\n```\n\nThe most common use-case is to load the file up when your script starts synchronously since you need it to exist before you start querying against it, but then add a watch to asynchronously update it later:\n\n```javascript\nvar wurfl = require('wurfl');\nvar wurflFile = __dirname + '/wurfl.xml';\n\nwurfl.loadSync(wurflFile);\nwurfl.watch(myWurflFile);\n\nvar userAgent = 'Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; O2 Xda 2s;PPC;240x320; PPC; 240x320)';\nvar deviceInfo = wurfl.get(userAgent);\nconsole.log(deviceInfo.model_name); // \"Xda IIs\"\n```\n\nThat's all for the API:\n\n*  wurfl.loadSync(optFileName)\n*  wurfl.load(optFileName, optCallback)\n*  wurfl.watch(optFileName, optCallback)\n*  wurfl.get(userAgent)\n\nTo see what properties are available in the info object you get back from wurfl.get() look at the wurfl.xml file. Each group is an object on info (e.g. info.css is a group) and each capability is a property on the group (e.g. info.css.css_spriting is a capability).\n\n### Optimizations\n\nThe devices in the wurfl.xml file \"inherit\" from other devices, specified in the XML by the fall_back attribute. In order to optimize for memory and not duplicate the base properties over and over again for every single device, I've structured the groups to have their own class that extends the fall_back group class. I've set all the capabilites for a group on its prototype object. And for groups that weren't overridden, the device just points to its fall_back device's group. This way, when you access a group's capability it will pull it from the group's prototype object or from further up the prototype chain back to the top-level group instance.\n\nIn addition to optimizing for memory I've also added a worker using node-webworkers to load and parse the XML file in a separate process from the main script. This allows the wurfl data to be loaded and/or updated without blocking a large chunk of time from your main script. This can be up to several seconds to load and parse the XML file. The worker is lazily created however, so if you only use loadSync() and get() it won't create the worker.\n","maintainers":[{"name":"jacwright","email":"jacwright@gmail.com"}]},"0.3.1":{"name":"wurfl","author":{"name":"Jacob Wright","email":"jacwright@gmail.com","url":"jacwright.com"},"version":"0.3.1","main":"./lib/wurfl","description":"NodeJS library for loading Wireless Universal Resource File (wurfl) xml file efficiently into memory for use in applications that need to lookup mobile device capabilities by their user agent.","scripts":{"test":"node test/test.js"},"dependencies":{"node-expat":"2.0.0","backgrounder":"0.2.7"},"homepage":"https://github.com/touchads/node-wurfl-api","repository":{"type":"git","url":"git://github.com/touchads/node-wurfl-api.git"},"readme":"wurfl.js\n========\n\nwurfl.js is a node.js library to make it easy to use wurfl. What is wurfl? From the site http://wurfl.sourceforge.net/:\n\n```\nWURFL is a Device Description Repository (DDR), i.e. a software\ncomponent which contains the descriptions of thousands of mobile\ndevices. In its simplest incarnation, WURFL is an XML\nconfiguration file plus a set of programming APIs to access the\ndata in real-time environments.\n```\n\nUsage\n-----\n\n### Installation\n\nInstall node.js (http://nodejs.org) first, then npm (http://npmjs.org), then:\n\n```bash\nnpm install wurfl\n```\n\n### Usage\n\nBasic usage allows getting up and running quickly.\n\n```javascript\nvar wurfl = require('wurfl');\n\nwurfl.loadSync();\n\n// wurfl xml file is finished loading into a memory-efficient structure\n\nvar userAgent = 'Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; O2 Xda 2s;PPC;240x320; PPC; 240x320)';\nvar deviceInfo = wurfl.get(userAgent);\nconsole.log(deviceInfo.product_info.model_name); // \"Xda IIs\"\n```\n\nYou may want to use your own (read \"updated\") wurfl.xml file. This is easy:\n\n```javascript\nvar wurflFile = __dirname + '/wurfl.xml';\nwurfl.loadSync(wurflFile);\n```\n\nLoading and parsing a large xml file can be take awhile and be CPU-heavy. You may use load() to asynchronously load the xml file:\n\n```javascript\nwurfl.load(function() {\n\t// ready to use, wurfl.get(userAgent);\n});\n```\n\nOr with your own xml file:\n\n```javascript\nwurfl.load(myWurflFile, function() {\n\t// my own file\n});\n```\n\nWhen using your own file, it would be great to update the file without needing to restart the node.js server:\n\n```javascript\nwurfl.watch(myWurflFile);\n```\n\nWhen updating using watch it will always be asynchronous. The data structure will be updated automatically when the file is changed. You may also be notified when that happens if you want to know when it gets updated:\n\n```javascript\nwurfl.watch(myWurflFile, function() {\n\tconsole.log('XML file updated');\n});\n```\n\nIf you want to reduce memory usage even further, you can specify the the groups you are interested in, the rest will be left out completely. For example, if you only care about the \"display\" capabilities:\n\n```javascript\nwurfl.loadSync({ groups: [ 'display' ] });\n```\n\nWhen specifying groups the \"file\" parameter needs to be an options hash with `groups` and optionally `file`. You can use this in loadSync(options), load(options, callback), and watch(options, callback).\n\n```javascript\nvar options = { file: __dirname + '/wurfl.xml', groups: [ 'display' ] };\nwurfl.loadSync(options);\nwurfl.watch(options);\n```\n\nThe most common use-case is to load the file up when your script starts synchronously since you need it to exist before you start querying against it, but then add a watch to asynchronously update it later:\n\n```javascript\nvar wurfl = require('wurfl');\nvar wurflFile = __dirname + '/wurfl.xml';\n\nwurfl.loadSync(wurflFile);\nwurfl.watch(myWurflFile);\n\nvar userAgent = 'Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; O2 Xda 2s;PPC;240x320; PPC; 240x320)';\nvar deviceInfo = wurfl.get(userAgent);\nconsole.log(deviceInfo.model_name); // \"Xda IIs\"\n```\n\nThat's all for the API:\n\n*  wurfl.loadSync(optFileName)\n*  wurfl.load(optFileName, optCallback)\n*  wurfl.watch(optFileName, optCallback)\n*  wurfl.get(userAgent)\n\nTo see what properties are available in the info object you get back from wurfl.get() look at the wurfl.xml file. Each group is an object on info (e.g. info.css is a group) and each capability is a property on the group (e.g. info.css.css_spriting is a capability).\n\n### Optimizations\n\nThe devices in the wurfl.xml file \"inherit\" from other devices, specified in the XML by the fall_back attribute. In order to optimize for memory and not duplicate the base properties over and over again for every single device, I've structured the groups to have their own class that extends the fall_back group class. I've set all the capabilites for a group on its prototype object. And for groups that weren't overridden, the device just points to its fall_back device's group. This way, when you access a group's capability it will pull it from the group's prototype object or from further up the prototype chain back to the top-level group instance.\n\nIn addition to optimizing for memory I've also added a worker using node-webworkers to load and parse the XML file in a separate process from the main script. This allows the wurfl data to be loaded and/or updated without blocking a large chunk of time from your main script. This can be up to several seconds to load and parse the XML file. The worker is lazily created however, so if you only use loadSync() and get() it won't create the worker.\n","readmeFilename":"README.md","_id":"wurfl@0.3.1","dist":{"shasum":"5f439d50c17ce78794b3e5bcd76323c56a754545","tarball":"https://registry.npmjs.org/wurfl/-/wurfl-0.3.1.tgz","integrity":"sha512-f3ZmJDLwUVdgGXMPhI/9I4CY1qsUNpuf8dhHlecNonQEaBl4HzOFKc83+tA7ov1LxnHCX9B2SgGZzVTYAHkcyw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFIiUkoSQaVVA6uQU2W5MYsjKMzl/gtWPtDMB9/SfaUPAiEAmWGXyz6ILiPwBDLQlRmOcvjVo+Z2WbuGlQNSwcWN3mY="}]},"_npmVersion":"1.1.65","_npmUser":{"name":"jacwright","email":"jacwright@gmail.com"},"maintainers":[{"name":"jacwright","email":"jacwright@gmail.com"}]}},"maintainers":[{"name":"jacwright","email":"jacwright@gmail.com"}],"time":{"modified":"2022-06-29T04:12:22.658Z","created":"2011-10-10T15:32:58.464Z","0.1.0":"2011-10-10T15:32:58.794Z","0.2.0":"2011-10-11T00:48:19.482Z","0.3.0":"2012-01-24T18:35:13.531Z","0.3.1":"2013-02-07T20:36:12.630Z"},"author":{"name":"Jacob Wright","email":"jacwright@gmail.com","url":"jacwright.com"},"repository":{"type":"git","url":"git://github.com/touchads/node-wurfl-api.git"}}