Class: FilterStorage

FilterStorage

filterStorage implementation.

Members

(private) _needsSave :boolean

Will be set to true if a FilterStorage#saveToDisk call arrives while FilterStorage#saveToDisk is already running (delayed execution).
Type:
  • boolean
Source:

(private) _saving :boolean

Will be set to true if FilterStorage#saveToDisk is running (reentrance protection).
Type:
  • boolean
Source:

fileProperties :object

Map of properties listed in the filter storage file before the sections start. Right now this should be only the format version.
Type:
  • object
Source:

firstRun :boolean

Will be set to true if no patterns.ini file exists.
Type:
  • boolean
Source:

formatVersion :number

The version number of the patterns.ini format used.
Type:
  • number
Source:

initialized :boolean

Will be set to true after the initial FilterStorage#loadFromDisk call completes.
Type:
  • boolean
Source:

knownSubscriptions :Map.<string, Subscription>

Map of subscriptions already on the list, by their URL/identifier.
Type:
Source:

sourceFile :string

The file containing the subscriptions.
Type:
  • string
Source:

subscriptionCount :number

The number of subscriptions in the storage.
Type:
  • number
Source:

Methods

addFilter(filter, subscriptionopt, nullable, positionopt)

Adds a user-defined filter to the storage.
Parameters:
Name Type Attributes Description
filter Filter
subscription SpecialSubscription <optional>
<nullable>
The subscription that the filter should be added to.
position number <optional>
The position within the subscription at which the filter should be added. If not specified, the filter is added at the end of the subscription.
Source:

addSubscription(subscription)

Adds a subscription to the storage.
Parameters:
Name Type Description
subscription Subscription The subscription to be added.
Source:

(generator) exportData() → {string}

Generator serializing filter data and yielding it line by line.
Source:
Yields:
Type
string

getBackupFiles() → {Promise.<Array.<FileInfo>>}

Returns a promise resolving in a list of existing backup files.
Source:
Returns:
Type
Promise.<Array.<FileInfo>>

getBackupName(backupIndex) → {string}

Constructs the file name for a patterns.ini backup.
Parameters:
Name Type Description
backupIndex number Number of the backup file (1 being the most recent).
Source:
Returns:
Backup file name.
Type
string

getGroupForFilter(filter) → (nullable) {SpecialSubscription}

Finds the filter group that a filter should be added to by default. Will return null if this group doesn't exist yet.
Parameters:
Name Type Description
filter Filter
Source:
Returns:
Type
SpecialSubscription

importData(silent) → {TextSink}

Allows importing previously serialized filter data.
Parameters:
Name Type Description
silent boolean If true, no "load" notification will be sent out.
Source:
Returns:
The function to be called for each line of data. Calling it with null as the argument finalizes the import and replaces existing data. No changes will be applied before finalization, so import can be "aborted" by forgetting this callback.
Type
TextSink

increaseHitCount(filter)

Increases the hit count for a filter by one.
Parameters:
Name Type Description
filter Filter
Source:

loadFromDisk() → {Promise}

Loads all subscriptions from disk.
Source:
Returns:
A promise resolved or rejected when loading is complete.
Type
Promise

moveFilter(filter, subscription, oldPosition, newPosition)

Moves a user-defined filter to a new position.
Parameters:
Name Type Description
filter Filter
subscription SpecialSubscription The subscription where the filter is located.
oldPosition number The current position of the filter.
newPosition number The new position of the filter.
Source:

removeFilter(filter, subscriptionopt, nullable, positionopt)

Removes a user-defined filter from the storage.
Parameters:
Name Type Attributes Description
filter Filter
subscription SpecialSubscription <optional>
<nullable>
The subscription that the filter should be removed from. If not specified, the filter will be removed from all subscriptions.
position number <optional>
The position within the subscription at which the filter should be removed. If not specified, all instances of the filter will be removed.
Source:

removeSubscription(subscription)

Removes a subscription from the storage.
Parameters:
Name Type Description
subscription Subscription The subscription to be removed.
Source:

resetHitCounts(filtersopt, nullable)

Resets hit count for some filters.
Parameters:
Name Type Attributes Description
filters Array.<Filter> <optional>
<nullable>
The filters to be reset. If not specified, all filters will be reset.
Source:

restoreBackup(backupIndex, silent) → {Promise}

Restores an automatically created backup.
Parameters:
Name Type Description
backupIndex number Number of the backup to restore (1 being the most recent).
silent boolean If true, no "load" notification will be sent out.
Source:
Returns:
A promise resolved or rejected when restoration is complete.
Type
Promise

saveToDisk() → {Promise}

Saves all subscriptions back to disk.
Source:
Returns:
A promise resolved or rejected when saving is complete.
Type
Promise

(generator) subscriptions(filterTextopt, nullable) → {Subscription}

Yields subscriptions in the storage.
Parameters:
Name Type Attributes Default Description
filterText string <optional>
<nullable>
null The filter text for which to look. If specified, the function yields only those subscriptions that contain the given filter text. By default the function yields all subscriptions.
Source:
Yields:
Type
Subscription

updateSubscriptionFilters(subscription, filterText)

Replaces the list of filters in a subscription with a new list.
Parameters:
Name Type Description
subscription Subscription The subscription to be updated.
filterText Array.<string> The new filter text.
Source: