/* ********************************************************************* * This Source Code Form is copyright of 51Degrees Mobile Experts Limited. * Copyright 2017 51Degrees Mobile Experts Limited, 5 Charlotte Close, * Caversham, Reading, Berkshire, United Kingdom RG4 7BY * * This Source Code Form is the subject of the following patents and patent * applications, owned by 51Degrees Mobile Experts Limited of 5 Charlotte * Close, Caversham, Reading, Berkshire, United Kingdom RG4 7BY: * European Patent No. 2871816; * European Patent Application No. 17184134.9; * United States Patent Nos. 9,332,086 and 9,350,823; and * United States Patent Application No. 15/686,066. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. * * If a copy of the MPL was not distributed with this file, You can obtain * one at http://mozilla.org/MPL/2.0/. * * This Source Code Form is "Incompatible With Secondary Licenses", as * defined by the Mozilla Public License, v. 2.0. ********************************************************************** */ /* Find profiles example of using 51Degrees device detection. The example shows how to:
  1. Set the configuration using a json object

    var config = {"dataFile" : require("fiftyonedegreeslitepattern"),
                  "properties" : "IsMobile",
                  "cacheSize" : 10000,
                  "poolSize" : 4
    };
    

  2. Instantiate the 51Degrees device detection provider with this connfiguration

    var provider = new fiftyonedegrees.provider(config);
    

  3. Retrieve all profiles from the data set which match the specified property value pair

    var profiles = provider.findProfiles("IsMobile", "True");
    

  4. Search with a list of profiles for another property value pair.

    profiles = provider.findProfiles("ScreenPixelsWidth", "1080", profiles)
    

*/ // Snippet Start // Include 51Degrees. var fiftyonedegrees = require("fiftyonedegreescore"); // Set the config. var config = {"dataFile" : require("fiftyonedegreeslitepattern"), "properties" : "IsMobile", "cacheSize" : 10000, "poolSize" : 4, }; console.log("Starting Find Profiles Example.\n"); /* Initialises the device detection provider with settings from the config. By default this will use the packaged Lite data file. For more info see: compare data options */ var provider = new fiftyonedegrees.provider(config); // Retrieve all the mobile profiles in the data set. var profiles = provider.findProfiles("IsMobile", "True"); console.log("There are " + profiles.count + " mobile profiles in the " + provider.getDataSetName() + " data file."); profiles = provider.findProfiles("ScreenPixelsWidth", "1080", profiles); console.log(profiles.count + " of them have a screen width of 1080 pixels."); // Retrieve all the non-mobile profiles in the data set. profiles = provider.findProfiles("IsMobile", "False"); console.log("There are " + profiles.count + " non-mobile profiles in the " + provider.getDataSetName() + " data set."); profiles = provider.findProfiles("ScreenPixelsWidth", "1080", profiles); console.log(profiles.count + " of them have a screen width of 1080 pixels."); // Snippet End