Implementations of common data structures and algorithms in JavaScript with modern ES6 and plus.
This project depends on babel to compile ES6 into more compatible JavaScript, and jest to run tests.
Clone this repo and run
$ npm install
to install dependencies.
Run
$ npm test path/to/test/file
to execute a test file. So for example,
$ npm test ./tests/stack.test.js
will execute the test files for stack.
Tests can also be run in watch mode, type
$ npm test -- --watch
will watch all the tests.
Test coverage can be found in ./coverage/lcov-report/index.html
(not committed to version control) after running the tests.
This project also has ESLint set up. The configuration mainly uses eslint recommended rules, along with the eslint-plugin-import rules to better support ES6 import statements. The config file can be found under root directory: .eslintrc.
To run the linter:
$ npx eslint path/to/file
with the path to a file or a directory. For example,
$ npx eslint ./src
will lint everything in the src
folder under root directory.
Adding a --fix
option will automatically fix some problems. For example, use the command below.
$ npx eslint --fix ./src
All implementation files are located in ./src
. If you run
npm run build
locally, these files will be compiled into ./lib
.
All test files are in ./tests
.