mirror of
https://github.com/zrwusa/data-structure-typed.git
synced 2024-11-23 12:54:04 +00:00
[project] Optimize the build configuration to be compatible with both earlier and later versions of Node.js. Switch to using tsup for UMD module output. Format code using an IDE.
This commit is contained in:
parent
b7dd86dad2
commit
e45854d3f4
1072
package-lock.json
generated
1072
package-lock.json
generated
File diff suppressed because it is too large
Load diff
31
package.json
31
package.json
|
@ -1,21 +1,23 @@
|
|||
{
|
||||
"name": "data-structure-typed",
|
||||
"version": "1.38.1",
|
||||
"version": "1.38.2",
|
||||
"description": "Data Structures of Javascript & TypeScript. Binary Tree, BST, Graph, Heap, Priority Queue, Linked List, Queue, Deque, Stack, AVL Tree, Tree Multiset, Trie, Directed Graph, Undirected Graph, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue.",
|
||||
"main": "dist/index.js",
|
||||
"module": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"source": "src/index.ts",
|
||||
"umd:main": "umd/bundle.min.js",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/mjs/index.js",
|
||||
"types": "dist/mjs/index.d.ts",
|
||||
"umd:main": "dist/umd/index.global.js",
|
||||
"exports": {
|
||||
"import": "./lib/index.js",
|
||||
"require": "./dist/index.js"
|
||||
".": {
|
||||
"import": "./dist/mjs/index.js",
|
||||
"require": "./dist/cjs/index.js",
|
||||
"types": "./dist/mjs/index.d.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:es6 && npm run build:commonjs && npm run build:umd && npm run build:docs",
|
||||
"build:es6": "rm -rf lib && tsc",
|
||||
"build:commonjs": "rm -rf dist && tsc --project tsconfig.prod.json",
|
||||
"build:umd": "webpack",
|
||||
"build": "npm run build:mjs && npm run build:cjs && npm run build:umd && npm run build:docs",
|
||||
"build:mjs": "rm -rf dist/mjs && tsc -p tsconfig.json",
|
||||
"build:cjs": "rm -rf dist/cjs && tsc -p tsconfig-cjs.json",
|
||||
"build:umd": "tsup",
|
||||
"build:docs": "typedoc --out docs ./src",
|
||||
"check": "tsc --noEmit",
|
||||
"lint:src": "eslint --fix 'src/**/*.{js,ts}'",
|
||||
|
@ -75,10 +77,9 @@
|
|||
"prettier": "^3.0.3",
|
||||
"ts-jest": "^29.1.1",
|
||||
"ts-loader": "^9.4.4",
|
||||
"tsup": "^7.2.0",
|
||||
"typedoc": "^0.25.1",
|
||||
"typescript": "^5.2.2",
|
||||
"webpack": "^5.88.2",
|
||||
"webpack-cli": "^5.1.4"
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"keywords": [
|
||||
"data",
|
||||
|
|
|
@ -152,7 +152,7 @@ export class AVLTree<N extends AVLTreeNode<N['val'], N> = AVLTreeNode> extends B
|
|||
// Balance Restoration: If a balance issue is discovered after inserting a node, it requires balance restoration operations. Balance restoration includes four basic cases where rotation operations need to be performed to fix the balance:
|
||||
switch (
|
||||
this._balanceFactor(A) // second O(1)
|
||||
) {
|
||||
) {
|
||||
case -2:
|
||||
if (A && A.left) {
|
||||
if (this._balanceFactor(A.left) <= 0) {
|
||||
|
|
|
@ -17,7 +17,7 @@ export class BinaryIndexedTree {
|
|||
* @param - - `frequency`: The default frequency value. It is optional and has a default
|
||||
* value of 0.
|
||||
*/
|
||||
constructor({frequency = 0, max}: {frequency?: number; max: number}) {
|
||||
constructor({frequency = 0, max}: { frequency?: number; max: number }) {
|
||||
this._freq = frequency;
|
||||
this._max = max;
|
||||
this._freqMap = {0: 0};
|
||||
|
|
|
@ -407,7 +407,7 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
|
|||
return -1;
|
||||
}
|
||||
|
||||
const stack: {node: N; depth: number}[] = [{node: beginRoot, depth: 0}];
|
||||
const stack: { node: N; depth: number }[] = [{node: beginRoot, depth: 0}];
|
||||
let maxHeight = 0;
|
||||
|
||||
while (stack.length > 0) {
|
||||
|
@ -842,7 +842,7 @@ export class BinaryTree<N extends BinaryTreeNode<N['val'], N> = BinaryTreeNode>
|
|||
_traverse(beginRoot);
|
||||
} else {
|
||||
// 0: visit, 1: print
|
||||
const stack: {opt: 0 | 1; node: N | null | undefined}[] = [{opt: 0, node: beginRoot}];
|
||||
const stack: { opt: 0 | 1; node: N | null | undefined }[] = [{opt: 0, node: beginRoot}];
|
||||
|
||||
while (stack.length > 0) {
|
||||
const cur = stack.pop();
|
||||
|
|
|
@ -37,8 +37,7 @@ export class TreeMultisetNode<
|
|||
*/
|
||||
export class TreeMultiset<N extends TreeMultisetNode<N['val'], N> = TreeMultisetNode>
|
||||
extends AVLTree<N>
|
||||
implements IBinaryTree<N>
|
||||
{
|
||||
implements IBinaryTree<N> {
|
||||
/**
|
||||
* The constructor function for a TreeMultiset class in TypeScript, which extends another class and sets an option to
|
||||
* merge duplicated values.
|
||||
|
|
|
@ -105,8 +105,7 @@ export abstract class AbstractEdge<V = any> {
|
|||
export abstract class AbstractGraph<
|
||||
V extends AbstractVertex<any> = AbstractVertex<any>,
|
||||
E extends AbstractEdge<any> = AbstractEdge<any>
|
||||
> implements IGraph<V, E>
|
||||
{
|
||||
> implements IGraph<V, E> {
|
||||
private _vertices: Map<VertexKey, V> = new Map<VertexKey, V>();
|
||||
|
||||
get vertices(): Map<VertexKey, V> {
|
||||
|
@ -554,14 +553,14 @@ export abstract class AbstractGraph<
|
|||
}
|
||||
|
||||
getMinDist &&
|
||||
distMap.forEach((d, v) => {
|
||||
if (v !== srcVertex) {
|
||||
if (d < minDist) {
|
||||
minDist = d;
|
||||
if (genPaths) minDest = v;
|
||||
}
|
||||
distMap.forEach((d, v) => {
|
||||
if (v !== srcVertex) {
|
||||
if (d < minDist) {
|
||||
minDist = d;
|
||||
if (genPaths) minDest = v;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
genPaths && getPaths(minDest);
|
||||
|
||||
|
@ -623,7 +622,7 @@ export abstract class AbstractGraph<
|
|||
if (vertexOrKey instanceof AbstractVertex) distMap.set(vertexOrKey, Infinity);
|
||||
}
|
||||
|
||||
const heap = new PriorityQueue<{key: number; val: V}>((a, b) => a.key - b.key);
|
||||
const heap = new PriorityQueue<{ key: number; val: V }>((a, b) => a.key - b.key);
|
||||
heap.add({key: 0, val: srcVertex});
|
||||
|
||||
distMap.set(srcVertex, 0);
|
||||
|
@ -852,7 +851,7 @@ export abstract class AbstractGraph<
|
|||
* `predecessor` property is a 2D array of vertices (or `null`) representing the predecessor vertices in the shortest
|
||||
* path between vertices in the
|
||||
*/
|
||||
floyd(): {costs: number[][]; predecessor: (V | null)[][]} {
|
||||
floyd(): { costs: number[][]; predecessor: (V | null)[][] } {
|
||||
const idAndVertices = [...this._vertices];
|
||||
const n = idAndVertices.length;
|
||||
|
||||
|
|
|
@ -64,8 +64,7 @@ export class DirectedEdge<V = any> extends AbstractEdge<V> {
|
|||
|
||||
export class DirectedGraph<V extends DirectedVertex<any> = DirectedVertex, E extends DirectedEdge<any> = DirectedEdge>
|
||||
extends AbstractGraph<V, E>
|
||||
implements IGraph<V, E>
|
||||
{
|
||||
implements IGraph<V, E> {
|
||||
/**
|
||||
* The constructor function initializes an instance of a class.
|
||||
*/
|
||||
|
|
|
@ -51,12 +51,11 @@ export class UndirectedEdge<V = number> extends AbstractEdge<V> {
|
|||
}
|
||||
|
||||
export class UndirectedGraph<
|
||||
V extends UndirectedVertex<any> = UndirectedVertex,
|
||||
E extends UndirectedEdge<any> = UndirectedEdge
|
||||
>
|
||||
V extends UndirectedVertex<any> = UndirectedVertex,
|
||||
E extends UndirectedEdge<any> = UndirectedEdge
|
||||
>
|
||||
extends AbstractGraph<V, E>
|
||||
implements IGraph<V, E>
|
||||
{
|
||||
implements IGraph<V, E> {
|
||||
/**
|
||||
* The constructor initializes a new Map object to store edges.
|
||||
*/
|
||||
|
|
|
@ -157,7 +157,7 @@ export class HashMap<K, V> {
|
|||
}
|
||||
}
|
||||
|
||||
*entries(): IterableIterator<[K, V]> {
|
||||
* entries(): IterableIterator<[K, V]> {
|
||||
for (const bucket of this.table) {
|
||||
if (bucket) {
|
||||
for (const [key, value] of bucket) {
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export class TreeMap {}
|
||||
export class TreeMap {
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export class TreeSet {}
|
||||
export class TreeSet {
|
||||
}
|
||||
|
|
|
@ -490,7 +490,7 @@ export class SinglyLinkedList<E = any> {
|
|||
return count;
|
||||
}
|
||||
|
||||
*[Symbol.iterator]() {
|
||||
* [Symbol.iterator]() {
|
||||
let current = this.head;
|
||||
|
||||
while (current) {
|
||||
|
|
|
@ -14,7 +14,7 @@ export class MatrixNTI2D<V = any> {
|
|||
* given initial value or 0 if not provided.
|
||||
* @param options - An object containing the following properties:
|
||||
*/
|
||||
constructor(options: {row: number; col: number; initialVal?: V}) {
|
||||
constructor(options: { row: number; col: number; initialVal?: V }) {
|
||||
const {row, col, initialVal} = options;
|
||||
this._matrix = new Array(row).fill(undefined).map(() => new Array(col).fill(initialVal || 0));
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ export class Vector2D {
|
|||
public x: number = 0,
|
||||
public y: number = 0,
|
||||
public w: number = 1 // needed for matrix multiplication
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The function checks if the x and y values of a point are both zero.
|
||||
|
|
|
@ -9,7 +9,8 @@ import {DoublyLinkedList} from '../linked-list';
|
|||
|
||||
// O(n) time complexity of obtaining the value
|
||||
// O(1) time complexity of adding at the beginning and the end
|
||||
export class Deque<E = any> extends DoublyLinkedList<E> {}
|
||||
export class Deque<E = any> extends DoublyLinkedList<E> {
|
||||
}
|
||||
|
||||
// O(1) time complexity of obtaining the value
|
||||
// O(n) time complexity of adding at the beginning and the end
|
||||
|
@ -19,9 +20,9 @@ export class ObjectDeque<E = number> {
|
|||
if (capacity !== undefined) this._capacity = capacity;
|
||||
}
|
||||
|
||||
private _nodes: {[key: number]: E} = {};
|
||||
private _nodes: { [key: number]: E } = {};
|
||||
|
||||
get nodes(): {[p: number]: E} {
|
||||
get nodes(): { [p: number]: E } {
|
||||
return this._nodes;
|
||||
}
|
||||
|
||||
|
@ -156,7 +157,7 @@ export class ObjectDeque<E = number> {
|
|||
return this._size <= 0;
|
||||
}
|
||||
|
||||
protected _seNodes(value: {[p: number]: E}) {
|
||||
protected _seNodes(value: { [p: number]: E }) {
|
||||
this._nodes = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ export class Queue<E = any> {
|
|||
return new Queue(this.nodes.slice(this.offset));
|
||||
}
|
||||
|
||||
*[Symbol.iterator]() {
|
||||
* [Symbol.iterator]() {
|
||||
for (const item of this.nodes) {
|
||||
yield item;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export type Direction = 'up' | 'right' | 'down' | 'left';
|
||||
|
||||
export type Turning = {[key in Direction]: Direction};
|
||||
export type Turning = { [key in Direction]: Direction };
|
||||
|
||||
export type NavigatorParams<T = any> = {
|
||||
matrix: T[][];
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export type ToThunkFn = () => ReturnType<TrlFn>;
|
||||
export type Thunk = () => ReturnType<ToThunkFn> & {__THUNK__: symbol};
|
||||
export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: symbol };
|
||||
export type TrlFn = (...args: any[]) => any;
|
||||
export type TrlAsyncFn = (...args: any[]) => any;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export type KeyValueObject = {[key: string]: any};
|
||||
export type KeyValueObject = { [key: string]: any };
|
||||
|
||||
export type KeyValueObjectWithKey = {[key: string]: any; key: string | number | symbol};
|
||||
export type KeyValueObjectWithKey = { [key: string]: any; key: string | number | symbol };
|
||||
|
||||
export type NonNumberNonObjectButDefined = string | boolean | symbol | null;
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ describe('Individual package BST operations test', () => {
|
|||
});
|
||||
|
||||
it('should perform various operations on a Binary Search Tree with object values', () => {
|
||||
const objBST = new BST<BSTNode<{key: number; keyA: number}>>();
|
||||
const objBST = new BST<BSTNode<{ key: number; keyA: number }>>();
|
||||
expect(objBST).toBeInstanceOf(BST);
|
||||
objBST.add(11, {key: 11, keyA: 11});
|
||||
objBST.add(3, {key: 3, keyA: 3});
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
|
||||
console.log(performance.now() - startTime);
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {AVLTree, CP, AVLTreeNode} from '../../../../src';
|
||||
import {AVLTree, AVLTreeNode, CP} from '../../../../src';
|
||||
|
||||
describe('AVL Tree Test', () => {
|
||||
it('should perform various operations on a AVL Tree', () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {BinaryIndexedTree} from '../../../../src';
|
||||
import {isDebugTest} from '../../../config';
|
||||
// import {isDebugTest} from '../../../config';
|
||||
|
||||
// const isDebug = isDebugTest;
|
||||
|
||||
|
@ -251,6 +251,7 @@ describe('BinaryIndexedTree additional tests', () => {
|
|||
expect(bit.lowerBound(200)).toBe(10);
|
||||
});
|
||||
});
|
||||
|
||||
function loopUpperBoundTests(bit: BinaryIndexedTree, values: number[]) {
|
||||
for (const value of values) {
|
||||
const index = bit.upperBound(value);
|
||||
|
|
|
@ -189,7 +189,7 @@ describe('BST operations test', () => {
|
|||
});
|
||||
|
||||
it('should perform various operations on a Binary Search Tree with object values', () => {
|
||||
const objBST = new BST<BSTNode<{key: number; keyA: number}>>();
|
||||
const objBST = new BST<BSTNode<{ key: number; keyA: number }>>();
|
||||
expect(objBST).toBeInstanceOf(BST);
|
||||
objBST.add(11, {key: 11, keyA: 11});
|
||||
objBST.add(3, {key: 3, keyA: 3});
|
||||
|
@ -260,7 +260,7 @@ describe('BST operations test', () => {
|
|||
objBST.perfectlyBalance();
|
||||
expect(objBST.isPerfectlyBalanced()).toBe(true);
|
||||
|
||||
const bfsNodesAfterBalanced: BSTNode<{key: number; keyA: number}>[] = [];
|
||||
const bfsNodesAfterBalanced: BSTNode<{ key: number; keyA: number }>[] = [];
|
||||
objBST.bfs(node => bfsNodesAfterBalanced.push(node));
|
||||
expect(bfsNodesAfterBalanced[0].key).toBe(8);
|
||||
expect(bfsNodesAfterBalanced[bfsNodesAfterBalanced.length - 1].key).toBe(16);
|
||||
|
@ -385,7 +385,7 @@ describe('BST operations test', () => {
|
|||
expect(bfsIDs[1]).toBe(12);
|
||||
expect(bfsIDs[2]).toBe(16);
|
||||
|
||||
const bfsNodes: BSTNode<{key: number; keyA: number}>[] = [];
|
||||
const bfsNodes: BSTNode<{ key: number; keyA: number }>[] = [];
|
||||
objBST.bfs(node => bfsNodes.push(node));
|
||||
expect(bfsNodes[0].key).toBe(2);
|
||||
expect(bfsNodes[1].key).toBe(12);
|
||||
|
|
|
@ -29,7 +29,7 @@ describe('Overall BinaryTree Test', () => {
|
|||
bfsIDs[0] === 11; // true
|
||||
expect(bfsIDs[0]).toBe(11);
|
||||
|
||||
const objBST = new BST<BSTNode<{key: number; keyA: number}>>();
|
||||
const objBST = new BST<BSTNode<{ key: number; keyA: number }>>();
|
||||
objBST.add(11, {key: 11, keyA: 11});
|
||||
objBST.add(3, {key: 3, keyA: 3});
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ describe('TreeMultiset operations test', () => {
|
|||
});
|
||||
|
||||
it('should perform various operations on a Binary Search Tree with object values', () => {
|
||||
const objTreeMultiset = new TreeMultiset<TreeMultisetNode<{key: number; keyA: number}>>();
|
||||
const objTreeMultiset = new TreeMultiset<TreeMultisetNode<{ key: number; keyA: number }>>();
|
||||
expect(objTreeMultiset).toBeInstanceOf(TreeMultiset);
|
||||
objTreeMultiset.add(11, {key: 11, keyA: 11});
|
||||
objTreeMultiset.add(3, {key: 3, keyA: 3});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {HashTableNode, HashTable} from '../../../../src';
|
||||
import {HashTable, HashTableNode} from '../../../../src';
|
||||
|
||||
describe('HashNode', () => {
|
||||
it('should create a HashNode with key and value', () => {
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('Heap Operation Test', () => {
|
|||
});
|
||||
|
||||
it('should object heap work well', function () {
|
||||
const minHeap = new MinHeap<{a: string; key: number}>((a, b) => a.key - b.key);
|
||||
const minHeap = new MinHeap<{ a: string; key: number }>((a, b) => a.key - b.key);
|
||||
minHeap.add({key: 1, a: 'a1'});
|
||||
minHeap.add({key: 6, a: 'a6'});
|
||||
minHeap.add({key: 2, a: 'a2'});
|
||||
|
@ -37,7 +37,7 @@ describe('Heap Operation Test', () => {
|
|||
i++;
|
||||
}
|
||||
|
||||
const maxHeap = new MaxHeap<{key: number; a: string}>((a, b) => b.key - a.key);
|
||||
const maxHeap = new MaxHeap<{ key: number; a: string }>((a, b) => b.key - a.key);
|
||||
maxHeap.add({key: 1, a: 'a1'});
|
||||
maxHeap.add({key: 6, a: 'a6'});
|
||||
maxHeap.add({key: 5, a: 'a5'});
|
||||
|
|
|
@ -3,7 +3,7 @@ import {bigO, magnitude} from '../../../utils';
|
|||
|
||||
describe('DoublyLinkedList Operation Test', () => {
|
||||
let list: DoublyLinkedList<number>;
|
||||
let objectList: DoublyLinkedList<{keyA: number}>;
|
||||
let objectList: DoublyLinkedList<{ keyA: number }>;
|
||||
|
||||
beforeEach(() => {
|
||||
list = new DoublyLinkedList();
|
||||
|
|
|
@ -3,10 +3,10 @@ import {bigO, magnitude} from '../../../utils';
|
|||
|
||||
describe('SinglyLinkedList Operation Test', () => {
|
||||
let list: SinglyLinkedList<number>;
|
||||
let objectList: SinglyLinkedList<{keyA: number}>;
|
||||
let objectList: SinglyLinkedList<{ keyA: number }>;
|
||||
beforeEach(() => {
|
||||
list = new SinglyLinkedList<number>();
|
||||
objectList = new SinglyLinkedList<{keyA: number}>();
|
||||
objectList = new SinglyLinkedList<{ keyA: number }>();
|
||||
});
|
||||
|
||||
describe('push', () => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Character, NavigatorParams, Turning, Navigator} from '../../../../src';
|
||||
import {Character, Navigator, NavigatorParams, Turning} from '../../../../src';
|
||||
|
||||
const exampleMatrix: number[][] = [
|
||||
[0, 0, 0, 0],
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('MaxPriorityQueue Operation Test', () => {
|
|||
});
|
||||
|
||||
it('should add elements and maintain heap property in a object MaxPriorityQueue', () => {
|
||||
const priorityQueue = new MaxPriorityQueue<{keyA: number}>((a, b) => b.keyA - a.keyA);
|
||||
const priorityQueue = new MaxPriorityQueue<{ keyA: number }>((a, b) => b.keyA - a.keyA);
|
||||
priorityQueue.refill([{keyA: 5}, {keyA: 3}, {keyA: 1}]);
|
||||
priorityQueue.add({keyA: 7});
|
||||
|
||||
|
@ -64,7 +64,7 @@ describe('MaxPriorityQueue Operation Test', () => {
|
|||
|
||||
it('should correctly heapify an object array', () => {
|
||||
const nodes = [{keyA: 5}, {keyA: 3}, {keyA: 7}, {keyA: 1}];
|
||||
const maxPQ = MaxPriorityQueue.heapify<{keyA: number}>(nodes, (a, b) => b.keyA - a.keyA);
|
||||
const maxPQ = MaxPriorityQueue.heapify<{ keyA: number }>(nodes, (a, b) => b.keyA - a.keyA);
|
||||
|
||||
expect(maxPQ.poll()?.keyA).toBe(7);
|
||||
expect(maxPQ.poll()?.keyA).toBe(5);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Deque, ArrayDeque, ObjectDeque} from '../../../../src';
|
||||
import {ArrayDeque, Deque, ObjectDeque} from '../../../../src';
|
||||
import {bigO} from '../../../utils';
|
||||
|
||||
describe('Deque Tests', () => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Queue, LinkedListQueue} from '../../../../src';
|
||||
import {LinkedListQueue, Queue} from '../../../../src';
|
||||
import {bigO, magnitude} from '../../../utils';
|
||||
|
||||
describe('Queue Operation Test', () => {
|
||||
|
|
|
@ -26,7 +26,7 @@ export const bigO = {
|
|||
|
||||
function findPotentialN(input: any): number {
|
||||
let longestArray: any[] = [];
|
||||
let mostProperties: {[key: string]: any} = {};
|
||||
let mostProperties: { [key: string]: any } = {};
|
||||
|
||||
function recurse(obj: any) {
|
||||
if (Array.isArray(obj)) {
|
||||
|
|
27
tsconfig-base.json
Normal file
27
tsconfig-base.json
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"baseUrl": "src",
|
||||
"declaration": true,
|
||||
"esModuleInterop": true,
|
||||
"inlineSourceMap": false,
|
||||
"lib": ["esnext"],
|
||||
"listEmittedFiles": false,
|
||||
"listFiles": false,
|
||||
"moduleResolution": "node",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"pretty": true,
|
||||
"resolveJsonModule": true,
|
||||
"rootDir": "src",
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"traceResolution": false,
|
||||
"types": ["node", "jest"]
|
||||
},
|
||||
"compileOnSave": false,
|
||||
"exclude": ["node_modules", "dist"],
|
||||
"include": [
|
||||
"./src/**/*.ts", // Include your .ts files
|
||||
]
|
||||
}
|
9
tsconfig-cjs.json
Normal file
9
tsconfig-cjs.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "./tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"outDir": "dist/cjs",
|
||||
"target": "ES2015",
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
|
@ -1,30 +1,9 @@
|
|||
{
|
||||
"extends": "./tsconfig-base.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES6",
|
||||
"module": "ES6",
|
||||
"outDir": "./lib",
|
||||
"declaration": true,
|
||||
"lib": [
|
||||
"ESNext"
|
||||
],
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"moduleResolution": "node",
|
||||
"skipLibCheck": true,
|
||||
"downlevelIteration": true,
|
||||
"removeComments": false,
|
||||
"experimentalDecorators": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
},
|
||||
|
||||
"include": ["src/**/*.ts", "src/**/*.js"],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib",
|
||||
"dist",
|
||||
"umd"
|
||||
]
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"outDir": "dist/mjs",
|
||||
"target": "ESNext"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES6",
|
||||
"module": "CommonJS",
|
||||
"outDir": "./dist",
|
||||
"declaration": true,
|
||||
"lib": [
|
||||
"ESNext"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"downlevelIteration": true,
|
||||
"removeComments": false,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.js"],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib",
|
||||
"dist",
|
||||
"umd"
|
||||
]
|
||||
}
|
||||
|
11
tsup.config.js
Normal file
11
tsup.config.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
export default [{
|
||||
entry: ['src/index.ts'],
|
||||
format: ["iife"],
|
||||
clean: true,
|
||||
sourcemap: true,
|
||||
minify: true,
|
||||
outDir: 'dist/umd',
|
||||
globalName: 'dataStructureTyped',
|
||||
platform: "browser",
|
||||
bundle: true
|
||||
}];
|
Loading…
Reference in a new issue