mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-21 08:35:35 +07:00
Changes
This commit is contained in:
@@ -16,12 +16,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Models a circular buffer of fixed size.
|
||||
*/
|
||||
export default class CircularBuffer<T> {
|
||||
private buffer: T[]
|
||||
public readonly capacity: number
|
||||
private readonly buffer: T[]
|
||||
|
||||
/**
|
||||
* Create a new circular buffer, that removes the oldes elements if the capacity is reached.
|
||||
* Create a new circular buffer, that removes the oldest elements if the capacity is reached.
|
||||
*
|
||||
* @param capacity - the capacity of this queue
|
||||
* @throws error if the capacity is <= 0
|
||||
@@ -35,12 +38,16 @@ export default class CircularBuffer<T> {
|
||||
this.buffer = []
|
||||
}
|
||||
|
||||
get size(): number {
|
||||
return this.buffer.length
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the buffer is empty.
|
||||
*
|
||||
* @returns true if the buffer is empty otherwise false
|
||||
*/
|
||||
public isEmpty() : boolean {
|
||||
public isEmpty(): boolean {
|
||||
return this.buffer.length === 0
|
||||
}
|
||||
|
||||
@@ -49,7 +56,7 @@ export default class CircularBuffer<T> {
|
||||
*
|
||||
* @returns true if the buffer is full otherwise false
|
||||
*/
|
||||
public isFull() : boolean {
|
||||
public isFull(): boolean {
|
||||
return this.buffer.length === this.capacity
|
||||
}
|
||||
|
||||
@@ -58,7 +65,7 @@ export default class CircularBuffer<T> {
|
||||
*
|
||||
* @param item - item that should be enqueued
|
||||
*/
|
||||
public enqueue(item: T) : void {
|
||||
public enqueue(item: T): void {
|
||||
if (this.isFull()) {
|
||||
this.buffer.shift()
|
||||
}
|
||||
@@ -71,11 +78,7 @@ export default class CircularBuffer<T> {
|
||||
*
|
||||
* @returns the buffer
|
||||
*/
|
||||
public toArray() : T[] {
|
||||
public toArray(): T[] {
|
||||
return [...this.buffer]
|
||||
}
|
||||
|
||||
get size() : number {
|
||||
return this.buffer.length
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
/*
|
||||
* This script is responsible for some tools.
|
||||
*/
|
||||
import { browser } from 'webextension-polyfill-ts'
|
||||
import {browser} from 'webextension-polyfill-ts'
|
||||
|
||||
declare const InstallTrigger: any
|
||||
|
||||
@@ -33,7 +33,7 @@ export class Utils {
|
||||
*
|
||||
* @returns Promise with true, iff the current browser runs on android otherwise false
|
||||
*/
|
||||
static async isAndroidOS() : Promise<boolean> {
|
||||
static async isAndroidOS(): Promise<boolean> {
|
||||
return (await browser.runtime.getPlatformInfo()).os === 'android'
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class Utils {
|
||||
*
|
||||
* @returns the browser name
|
||||
*/
|
||||
static getBrowser() : string {
|
||||
static getBrowser(): string {
|
||||
if (typeof InstallTrigger !== 'undefined') {
|
||||
return 'Firefox'
|
||||
}
|
||||
@@ -58,7 +58,7 @@ export class Utils {
|
||||
* @param url - the url, that should be decoded
|
||||
* @returns the decoded URL
|
||||
*/
|
||||
static decodeURL(url: string) : string {
|
||||
static decodeURL(url: string): string {
|
||||
let rtn = decodeURIComponent(url)
|
||||
|
||||
while (Utils.isEncodedURI(rtn)) {
|
||||
@@ -76,7 +76,7 @@ export class Utils {
|
||||
* @param uri - the URI to be checked
|
||||
* @returns true, iff the given URI is encoded otherwise false
|
||||
*/
|
||||
static isEncodedURI(uri: string) : boolean {
|
||||
static isEncodedURI(uri: string): boolean {
|
||||
return uri !== decodeURIComponent(uri || '')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user