Module: urlblock/trustedmanager

trustedmanager manages trusted content providers. It uses a combination of local and online processing to reduce the time taken to find trusted sites in constant time complexity O(k).
Although the exposed functions for the module are only add and checkPresenceInTrusted, their implementation uses a variety of data-structures. Some of them being:
  1. Array: for base data of most visited sites.
  2. LFU-Cache: for frequently visited sites by the user.
  3. Hashtable: for items that aren't frequent, but accessed at some point of time.
To Do:
  • Add a server datastructure aggregating all websites and add an asynch call side by side

Example

To include trustedmanager, just use require like:

var trusted = require('trustedmanager.js');

Members


<inner> data

Imports data for base array from data modules. See module:data/URLBlocker

Methods


<inner> add(URL)

Adds a URL to the trustedmanager asynchronously.
Parameters:
Name Type Description
URL String that needs to be added
Example
trusted.add("http://www.google.com");

<inner> checkPresenceInTrusted(URL)

Checks for the presence of a provided URL in trustedmanager.
Parameters:
Name Type Description
URL String to check in trustedmanager
Returns:
A promise that returns a boolean true or false occording to whether the URL is present. It returns an error if rejected.
Type
Promise
Example
trusted.checkPresenceInTrusted("https://www.google.com").then(result => {
 if(result) {
     console.log("Good");
 } else {
     console.log("Bad"); 
 }
});