ts-viewers-core
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -41,2 +41,25 @@ // Generated by dts-bundle-generator v5.9.0 | ||
} | ||
export declare class LinkedListNode<T> { | ||
data: T; | ||
next: LinkedListNode<T>; | ||
constructor(data: T); | ||
} | ||
export declare class LinkedList<T> { | ||
private _head; | ||
get head(): T; | ||
private _length; | ||
get length(): number; | ||
get tail(): T; | ||
constructor(head?: T); | ||
push(value: T): void; | ||
insert(value: T, n: number): T; | ||
replace(value: T, n: number): T; | ||
remove(n: number): T; | ||
clear(): void; | ||
get(n: number): T; | ||
pop(): T; | ||
has(value: T, comparator?: (a: T, b: T) => boolean): boolean; | ||
findIndex(value: T, comparator?: (a: T, b: T) => boolean): number; | ||
[Symbol.iterator](): Generator<T, void, unknown>; | ||
} | ||
export declare type Double = readonly [ | ||
@@ -43,0 +66,0 @@ x: number, |
@@ -297,2 +297,160 @@ /** | ||
class LinkedListNode { | ||
constructor(data) { | ||
this.data = data; | ||
} | ||
} | ||
class LinkedList { | ||
constructor(head) { | ||
this._length = 0; | ||
if (head) { | ||
this.push(head); | ||
} | ||
} | ||
get head() { | ||
return this._head.data; | ||
} | ||
get length() { | ||
return this._length; | ||
} | ||
get tail() { | ||
return this.get(this._length - 1); | ||
} | ||
push(value) { | ||
const node = new LinkedListNode(value); | ||
let current; | ||
if (!this._head) { | ||
this._head = node; | ||
} | ||
else { | ||
current = this._head; | ||
while (current.next) { | ||
current = current.next; | ||
} | ||
current.next = node; | ||
} | ||
this._length++; | ||
} | ||
insert(value, n) { | ||
if (n < 0 || n > this._length - 1) { | ||
return null; | ||
} | ||
const node = new LinkedListNode(value); | ||
let previous; | ||
let current = this._head; | ||
let i = 0; | ||
if (!n) { | ||
this._head = node; | ||
} | ||
else { | ||
while (i++ < n) { | ||
previous = current; | ||
current = current.next; | ||
} | ||
previous.next = node; | ||
} | ||
node.next = current; | ||
this._length++; | ||
return node.data; | ||
} | ||
replace(value, n) { | ||
if (n < 0 || n > this._length - 1) { | ||
return null; | ||
} | ||
const node = new LinkedListNode(value); | ||
let previous; | ||
let current = this._head; | ||
let i = 0; | ||
if (!n) { | ||
this._head = node; | ||
} | ||
else { | ||
while (i++ < n) { | ||
previous = current; | ||
current = current.next; | ||
} | ||
previous.next = node; | ||
} | ||
node.next = current.next; | ||
return current.data; | ||
} | ||
remove(n) { | ||
if (n < 0 || n > this._length - 1) { | ||
return null; | ||
} | ||
let previous; | ||
let current = this._head; | ||
let i = 0; | ||
if (!n) { | ||
this._head = current.next; | ||
} | ||
else { | ||
while (i++ < n) { | ||
previous = current; | ||
current = current.next; | ||
} | ||
previous.next = current.next; | ||
} | ||
this._length--; | ||
return current.data; | ||
} | ||
clear() { | ||
this._head = null; | ||
this._length = 0; | ||
} | ||
get(n) { | ||
if (n < 0 || n > this._length - 1) { | ||
return null; | ||
} | ||
let current = this._head; | ||
let i = 0; | ||
while (i++ < n) { | ||
current = current.next; | ||
} | ||
return current.data; | ||
} | ||
pop() { | ||
return this.remove(this._length - 1); | ||
} | ||
has(value, comparator) { | ||
if (!this._length) { | ||
return false; | ||
} | ||
comparator || (comparator = (a, b) => a === b); | ||
let current = this._head; | ||
let i = 0; | ||
while (i < this._length) { | ||
if (comparator(value, current.data)) { | ||
return true; | ||
} | ||
current = current.next; | ||
i++; | ||
} | ||
return false; | ||
} | ||
findIndex(value, comparator) { | ||
if (!this._length) { | ||
return -1; | ||
} | ||
comparator || (comparator = (a, b) => a === b); | ||
let current = this._head; | ||
let i = 0; | ||
while (i < this._length) { | ||
if (comparator(value, current.data)) { | ||
return i; | ||
} | ||
current = current.next; | ||
i++; | ||
} | ||
return -1; | ||
} | ||
*[Symbol.iterator]() { | ||
let current = this._head; | ||
while (current) { | ||
yield current.data; | ||
current = current.next; | ||
} | ||
} | ||
} | ||
class UUID { | ||
@@ -304,2 +462,2 @@ static getRandomUuid() { | ||
export { ByteUtils, DomUtils, EventService, UUID }; | ||
export { ByteUtils, DomUtils, EventService, LinkedList, LinkedListNode, UUID }; |
{ | ||
"name": "ts-viewers-core", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "browser image viewer with basic painting support", | ||
@@ -5,0 +5,0 @@ "module": "dist/ts-viewers-core.esm.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21532
548