ts-datastructs-algos
v0.2.3
Published
Data structures, algorithms, and other useful functions written in TypeScript. This package is still in development.
Downloads
6
Maintainers
Readme
ts-datastructs-algos
Data structures, algorithms, and other useful functions written in TypeScript.
This package is still in development.
Usage
Install the package from npmjs.com.
npm install ts-datastructs-algos
bun add ts-datastructs-algos
yarn add ts-datastructs-algos
Example
import { binarySearch } from 'ts-datastructs-algos'
const sortedArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
console.log(binarySearch(sortedArray, 5))
Exports
Algorithms
- hasDuplicates
- twoSums
Searches
- binarySearch
- linearSearch
Sorts
- bubbleSort
- insertionSort
- selectionSort
Structures
- SinglyLinkedList
- DoublyLinkedList
- Stack
- Queue
Other Utilities
- deepCopy
- swapArrayValues
Development
Contributions are welcome!
General Rules
- This project is intended to be readable by developers of all levels. This is intended to help developers contribute and learn concepts. Always avoid unnecessary shorthand code.
- Where possible, functions should be written in a immutable way and always return something.
- Include type checking at the beginning of functions for when TypeScript is not used or a runtime issue occurs.
- ESlint is provided for consistent styling. Do not modify the .eslintrc.yml file.
- Create a branch for your changes, create a pull request to 'development'. Pull requests on the 'main' branch are automatically published to npm.
- Avoid additional dependencies at all costs.
Prerequisites
This project uses bun.sh.
Install it first if you plan on developing for this project.
Packages
Install packages with: Bun:
bun install
Tests
Run tests with:
bun test
Test are located in the ./tests directory.
Building
bun run build
Note: bun build
will not work.
Build files are outputed to the ./dist folder.