Module: urlblock/bannedmanager

bannedmanager manages banned content providers. It uses a combination of local and online processing to reduce the time taken to find banned sites in constant time complexity O(k).
Although the exposed functions for the module are only add and checkPresenceInBanned, 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 bannedmanager, just use require like:

var banned = require('bannedmanager.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 bannedmanager asynchronously.
Parameters:
Name Type Description
URL String that needs to be added
Example
banned.add("http://www.google.com");

<inner> checkPresenceInBanned(URL)

Checks for the presence of a provided URL in bannedmanager.
Parameters:
Name Type Description
URL String to check in bannedmanager
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
banned.checkPresenceInBanned("https://www.google.com").then(result => {
	if(result) {
		console.log("Good");
 } else {
		console.log("Bad");	
	}
});