jollections v0.0.11
Jollections
The missing standard template library for JavaScript. The package contains common data structures and algorithms.
To install the package, run npm install --save jollections
or yarn add jollections --dev
.
If you want to import it into your HTML via script
tag then you can use unpkg link like below:
<script src="https://unpkg.com/jollections@0.0.10/dist/bundle.umd.js"></script>
Usage
With ES6 modules:
import { SinglyLinkedList } from 'jollections';
const list = new SinglyLinkedList();
list.addFirst(1);
list.addFirst(0);
list.addLast(2);
Using in CommonJs environment:
const { PriorityQueue } = require('jollections');
const queue = new PriorityQueue((a, b) => a.weight - b.weight);
queue.enqueue({ vertex: 'A', weight: 2 });
queue.enqueue({ vertex: 'B', weight: 6 });
queue.enqueue({ vertex: 'C', weight: 1 });
queue.enqueue({ vertex: 'D', weight: 3 });
const nearestNeighbor = queue.dequeue();
console.log(nearestNeighbor); // { vertex: 'C', weight: 1 }
To use it in browser just import script
from unpkg inside your HTML and use it under Jollections
namespace:
<script src="https://unpkg.com/jollections@0.0.10/dist/bundle.umd.js"></script>
<script>
const { CircularLinkedList } = Jollections;
const linkedList = new CircularLinkedList();
linkedList.addLast(1);
linkedList.addLast(2);
linkedList.addLast(3);
linkedList.addLast(4);
console.log(linkedList.last()); // 4
linkedList.rotate();
console.log(linkedList.last()); // 1
linkedList.rotate();
console.log(linkedList.last()); // 2
</script>
Documentation
Soon...
Contribution
If you want to contribute, fork the repo, create your own branch (name does not matter as long as it makes sense) and start working. If Husky files are not executable by default make sure you make give them execute permission. It can be done by using following commands on Linux or Linux like environments:
chmod ug+x .husky/*
chmod ug+x .git/hooks/*
It will make sure that our Git hooks work properly. Hooks will check your commit messages and will run linter on each commit. Make sure your commits match conventional commits or your changes will not be accepted.