mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
chore(core/stdlib): fix lint
This commit is contained in:
@@ -52,7 +52,7 @@ export class BinaryHeap<T> implements BinaryHeapLike<T> {
|
||||
constructor(initialValues?: T[] | T, options?: BinaryHeapOptions<T>) {
|
||||
this.comparator = options?.comparator ?? defaultComparator;
|
||||
|
||||
if (initialValues != null) {
|
||||
if (initialValues !== null && initialValues !== undefined) {
|
||||
const items = isArray(initialValues) ? initialValues : [initialValues];
|
||||
this.heap.push(...items);
|
||||
this.heapify();
|
||||
|
||||
@@ -21,7 +21,7 @@ export class CircularBuffer<T> implements CircularBufferLike<T> {
|
||||
* @private
|
||||
* @type {(T | undefined)[]}
|
||||
*/
|
||||
private buffer: (T | undefined)[];
|
||||
private buffer: Array<T | undefined>;
|
||||
|
||||
/**
|
||||
* The index of the front element
|
||||
@@ -53,7 +53,7 @@ export class CircularBuffer<T> implements CircularBufferLike<T> {
|
||||
const requested = Math.max(items.length, initialCapacity ?? 0);
|
||||
const cap = Math.max(MIN_CAPACITY, nextPowerOfTwo(requested));
|
||||
|
||||
this.buffer = new Array(cap);
|
||||
this.buffer = Array.from<T | undefined>({ length: cap });
|
||||
|
||||
for (const item of items)
|
||||
this.pushBack(item);
|
||||
@@ -190,7 +190,7 @@ export class CircularBuffer<T> implements CircularBufferLike<T> {
|
||||
* @returns {this}
|
||||
*/
|
||||
clear() {
|
||||
this.buffer = new Array(MIN_CAPACITY);
|
||||
this.buffer = Array.from<T | undefined>({ length: MIN_CAPACITY });
|
||||
this.head = 0;
|
||||
this.count = 0;
|
||||
|
||||
@@ -203,7 +203,7 @@ export class CircularBuffer<T> implements CircularBufferLike<T> {
|
||||
* @returns {T[]}
|
||||
*/
|
||||
toArray() {
|
||||
const result = new Array<T>(this.count);
|
||||
const result = Array.from<T>({ length: this.count });
|
||||
|
||||
for (let i = 0; i < this.count; i++)
|
||||
result[i] = this.buffer[(this.head + i) & (this.buffer.length - 1)] as T;
|
||||
@@ -246,7 +246,7 @@ export class CircularBuffer<T> implements CircularBufferLike<T> {
|
||||
*/
|
||||
private grow() {
|
||||
const newCapacity = this.buffer.length << 1;
|
||||
const newBuffer = new Array<T | undefined>(newCapacity);
|
||||
const newBuffer = Array.from<T | undefined>({ length: newCapacity });
|
||||
|
||||
for (let i = 0; i < this.count; i++)
|
||||
newBuffer[i] = this.buffer[(this.head + i) & (this.buffer.length - 1)];
|
||||
|
||||
@@ -30,7 +30,7 @@ export class LinkedList<T> implements LinkedListLike<T> {
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
private count: number = 0;
|
||||
private count = 0;
|
||||
|
||||
/**
|
||||
* The first node in the list
|
||||
@@ -54,7 +54,7 @@ export class LinkedList<T> implements LinkedListLike<T> {
|
||||
* @param {(T[] | T)} [initialValues] The initial values to add to the list
|
||||
*/
|
||||
constructor(initialValues?: T[] | T) {
|
||||
if (initialValues != null) {
|
||||
if (initialValues !== null && initialValues !== undefined) {
|
||||
const items = isArray(initialValues) ? initialValues : [initialValues];
|
||||
|
||||
for (const item of items)
|
||||
@@ -258,7 +258,7 @@ export class LinkedList<T> implements LinkedListLike<T> {
|
||||
* @returns {T[]} Array of values from head to tail
|
||||
*/
|
||||
public toArray(): T[] {
|
||||
const result = new Array<T>(this.count);
|
||||
const result = Array.from<T>({ length: this.count });
|
||||
let current = this.first;
|
||||
let i = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user