Skip to content

Commit

Permalink
Small code formatting fixlets
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Benoit authored Jun 7, 2022
1 parent 328b7c3 commit 432b4da
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ node_modules
build
*.log
*.lock
.eslintcache
.DS_Store
TODO.md
2 changes: 1 addition & 1 deletion bit-set.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class BitSet implements Iterable<number> {

// Methods
clear(): void;
set(index: number, value?: boolean | number): void;
set(index: number, value?: boolean | number): void;
reset(index: number, value: boolean | number): void;
flip(index: number, value: boolean | number): void;
get(index: number): number;
Expand Down
2 changes: 1 addition & 1 deletion bit-vector.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class BitVector implements Iterable<number> {

// Methods
clear(): void;
set(index: number, value?: boolean | number): this;
set(index: number, value?: boolean | number): this;
reset(index: number, value: boolean | number): void;
flip(index: number, value: boolean | number): void;
reallocate(capacity: number): this;
Expand Down
4 changes: 2 additions & 2 deletions bk-tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
type DistanceFunction<T> = (a: T, b: T) => number;

export default class BKTree<T> {

// Members
distance: DistanceFunction<T>;
size: number;
Expand All @@ -20,5 +20,5 @@ export default class BKTree<T> {
inspect(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}, distance: DistanceFunction<I>): BKTree<I>;
static from<I>(iterable: Iterable<I> | {[key: string]: I}, distance: DistanceFunction<I>): BKTree<I>;
}
6 changes: 3 additions & 3 deletions fibonacci-heap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class FibonacciHeap<T> {

// Statics
static from<I>(
iterable: Iterable<I> | {[key: string] : I},
iterable: Iterable<I> | {[key: string]: I},
comparator?: FibonacciHeapComparator<I>
): FibonacciHeap<I>;
}
Expand All @@ -42,7 +42,7 @@ export class MinFibonacciHeap<T> {
inspect(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}): FibonacciHeap<I>;
static from<I>(iterable: Iterable<I> | {[key: string]: I}): FibonacciHeap<I>;
}

export class MaxFibonacciHeap<T> {
Expand All @@ -61,5 +61,5 @@ export class MaxFibonacciHeap<T> {
inspect(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}): FibonacciHeap<I>;
static from<I>(iterable: Iterable<I> | {[key: string]: I}): FibonacciHeap<I>;
}
2 changes: 1 addition & 1 deletion inverted-index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class InvertedIndex<D> implements Iterable<D> {

// Statics
static from<I>(
iterable: Iterable<I> | {[key: string] : I},
iterable: Iterable<I> | {[key: string]: I},
tokenizer?: Tokenizer | TokenizersTuple
): InvertedIndex<I>;
}
2 changes: 1 addition & 1 deletion linked-list.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export default class LinkedList<T> implements Iterable<T> {
inspect(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}): LinkedList<I>;
static from<I>(iterable: Iterable<I> | {[key: string]: I}): LinkedList<I>;
}
8 changes: 4 additions & 4 deletions lru-cache-with-delete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* Mnemonist LRUCacheWithDelete Typings
* =====================================
*/
import LRUCache from './lru-cache';
import LRUCache from './lru-cache';

export default class LRUCacheWithDelete<K, V> extends LRUCache<K, V> {
export default class LRUCacheWithDelete<K, V> extends LRUCache<K, V> {

delete(key: K): boolean;
delete(key: K): boolean;

remove<T>(key: K, missing?: T): V | T;
remove<T>(key: K, missing?: T): V | T;

}
4 changes: 2 additions & 2 deletions lru-cache-with-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (typeof Symbol !== 'undefined')
*
* @return {undefined}
*/
LRUCacheWithDelete.prototype.clear = function() {
LRUCacheWithDelete.prototype.clear = function() {
LRUCache.prototype.clear.call(this);
this.deletedSize = 0;
};
Expand Down Expand Up @@ -262,7 +262,7 @@ LRUCacheWithDelete.prototype.remove = function(key, missing = undefined) {
* @param {number} capacity - Cache's capacity.
* @return {LRUCacheWithDelete}
*/
LRUCacheWithDelete.from = function(iterable, Keys, Values, capacity) {
LRUCacheWithDelete.from = function(iterable, Keys, Values, capacity) {
if (arguments.length < 2) {
capacity = iterables.guessLength(iterable);

Expand Down
10 changes: 5 additions & 5 deletions lru-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function LRUCache(Keys, Values, capacity) {
if (typeof this.capacity !== 'number' || this.capacity <= 0)
throw new Error('mnemonist/lru-cache: capacity should be positive number.');
else if (!isFinite(this.capacity) || Math.floor(this.capacity) !== this.capacity)
throw new Error('mnemonist/lru-cache: capacity should be a finite positive integer.');
throw new Error('mnemonist/lru-cache: capacity should be a finite positive integer.');

var PointerArray = typed.getPointerArray(capacity);

Expand Down Expand Up @@ -235,12 +235,12 @@ LRUCache.prototype.get = function(key) {
* @return {any}
*/
LRUCache.prototype.peek = function(key) {
var pointer = this.items[key];
var pointer = this.items[key];

if (typeof pointer === 'undefined')
return;
if (typeof pointer === 'undefined')
return;

return this.V[pointer];
return this.V[pointer];
};

/**
Expand Down
8 changes: 4 additions & 4 deletions lru-map-with-delete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* Mnemonist LRUMapWithDelete Typings
* ===================================
*/
import LRUMap from './lru-map';
import LRUMap from './lru-map';

export default class LRUMapWithDelete<K, V> extends LRUMap<K, V> {
export default class LRUMapWithDelete<K, V> extends LRUMap<K, V> {

delete(key: K): boolean;
delete(key: K): boolean;

remove<T>(key: K, missing?: T): V | T;
remove<T>(key: K, missing?: T): V | T;

}
4 changes: 2 additions & 2 deletions lru-map-with-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (typeof Symbol !== 'undefined')
*
* @return {undefined}
*/
LRUMapWithDelete.prototype.clear = function() {
LRUMapWithDelete.prototype.clear = function() {
LRUMap.prototype.clear.call(this);
this.deletedSize = 0;
};
Expand Down Expand Up @@ -262,7 +262,7 @@ LRUMapWithDelete.prototype.remove = function(key, missing = undefined) {
* @param {number} capacity - Cache's capacity.
* @return {LRUMapWithDelete}
*/
LRUMapWithDelete.from = function(iterable, Keys, Values, capacity) {
LRUMapWithDelete.from = function(iterable, Keys, Values, capacity) {
if (arguments.length < 2) {
capacity = iterables.guessLength(iterable);

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "0.39.2",
"description": "Curated collection of data structures for the JavaScript/TypeScript.",
"scripts": {
"lint": "eslint ./*.js ./utils ./test",
"lint": "eslint --cache ./*.js ./utils ./test",
"lint:fix": "eslint --cache --fix ./*.js ./utils ./test",
"prepublishOnly": "npm run lint && npm test && npm run test:types",
"test": "mocha",
"test:types": "tsc --target es2015 --noEmit --noImplicitAny --noImplicitReturns ./test/types.ts"
Expand Down
2 changes: 1 addition & 1 deletion passjoin-index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class PassjoinIndex<T> implements Iterable<T> {

// Statics
static from<I>(
iterable: Iterable<I> | {[key: string] : I},
iterable: Iterable<I> | {[key: string]: I},
levenshtein: LevenshteinDistanceFunction<I>,
k: number
): PassjoinIndex<I>;
Expand Down
2 changes: 1 addition & 1 deletion queue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export default class Queue<T> implements Iterable<T> {
inspect(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}): Queue<I>;
static from<I>(iterable: Iterable<I> | {[key: string]: I}): Queue<I>;
static of<I>(...items: Array<I>): Queue<I>;
}
6 changes: 3 additions & 3 deletions set.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function add<T>(a: Set<T>, b: Set<T>): void;
export function subtract<T>(a: Set<T>, b: Set<T>): void;
export function intersect<T>(a: Set<T>, b: Set<T>): void;
export function disjunct<T>(a: Set<T>, b: Set<T>): void;
export function intersectionSize<T>(a: Set<T>, b:Set<T>): number;
export function unionSize<T>(a: Set<T>, b:Set<T>): number;
export function jaccard<T>(a: Set<T>, b:Set<T>): number;
export function intersectionSize<T>(a: Set<T>, b: Set<T>): number;
export function unionSize<T>(a: Set<T>, b: Set<T>): number;
export function jaccard<T>(a: Set<T>, b: Set<T>): number;
export function overlap<T>(a: Set<T>, b: Set<T>): number;
2 changes: 1 addition & 1 deletion stack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export default class Stack<T> implements Iterable<T> {
inspect(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}): Stack<I>;
static from<I>(iterable: Iterable<I> | {[key: string]: I}): Stack<I>;
static of<I>(...items: Array<I>): Stack<I>;
}
2 changes: 1 addition & 1 deletion static-disjoint-set.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import {ArrayLike} from './utils/types';

export default class StaticDisjointSet {

// Members
dimension: number;
size: number;
Expand Down
4 changes: 2 additions & 2 deletions static-interval-tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class StaticIntervalTree<T> {
intervalsContainingPoint(point: number): Array<T>;
intervalsOverlappingInterval(interval: T): Array<T>;
inspect(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}): StaticIntervalTree<I>;
static from<I>(iterable: Iterable<I> | {[key: string]: I}): StaticIntervalTree<I>;
}
2 changes: 1 addition & 1 deletion suffix-array.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* ==============================
*/
export default class SuffixArray {

// Members
array: Array<number>;
length: number;
Expand Down
4 changes: 2 additions & 2 deletions vector.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class Vector implements Iterable<number> {
toJSON(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}, ArrayClass: IArrayLikeConstructor, capacity?: number): Vector;
static from<I>(iterable: Iterable<I> | {[key: string]: I}, ArrayClass: IArrayLikeConstructor, capacity?: number): Vector;
}

declare class TypedVector implements Iterable<number> {
Expand Down Expand Up @@ -67,7 +67,7 @@ declare class TypedVector implements Iterable<number> {
toJSON(): any;

// Statics
static from<I>(iterable: Iterable<I> | {[key: string] : I}, capacity?: number): TypedVector;
static from<I>(iterable: Iterable<I> | {[key: string]: I}, capacity?: number): TypedVector;
}

export class Int8Vector extends TypedVector {}
Expand Down
2 changes: 1 addition & 1 deletion vp-tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class VPTree<T> {

// Statics
static from<I>(
iterable: Iterable<I> | {[key: string] : I},
iterable: Iterable<I> | {[key: string]: I},
distance: DistanceFunction<I>
): VPTree<I>;
}

0 comments on commit 432b4da

Please sign in to comment.