This solution to the classic Balanced Braces algorithm comes loaded with features.
- ES6 language features
- 100% code coverage
- Complete doc blocks for EVERY function
- CLI tool for visualizing the isBalanced function in action (omgz wow)
Please see the isBalanced
function doc block for all of the info regarding the implementation of the function. It includes details such as assumptions, time complexity, and space complexity.
To get started simply do the following:
- Make sure Node is installed
npm install
- installs dependencies (only jasmine/sinon for testing and istanbul for code coverage)npm start
- runs a script that stdouts all of the provided test cases (plus a few more)
The specs are created using the Jasmine testing framework and Sinon for stubs and spies. Istanbul is also used to analyze code coverage. To run the suite do the following:
npm test
- runs test suite and outputs code coverage results (100% across the board!)
I created a CLI tool that allows you run the isBalanced
function from the command line. Run it like this:
./cli/is-balanced.js '{{{foo();}}}{}'
- Runs the
isBalanced
function in standard mode, taking'{{{foo();}}}{}'
as the string parameter
- Runs the
./cli/is-balanced.js '{}{foo{}' -p
- runs the
isBalanced
function in render mode (b/c of the-p
flag), taking'{}{foo{}'
as the string parameter. Stdouts every1000ms
(default value, but this can also be specified)
- runs the
./cli/is-balanced.js '{{{}' 2000 -p
- runs the
isBalanced
function in render mode, taking'{{{}'
as the string parameter. Stdouts every2000ms
(instead of1000ms
from the previous example)
- runs the