Imagine a directed acyclic graph of nodes that describes the user's intent to transform data in various ways.
Assume the following:
-
We have three types of nodes
- Data - a table data
- Join - joins two tables of data using a merge strategy
- Filter - given a table of data filters it and returns a result
-
The user is only interested in the results of certain
Interesting
nodes in the graph. -
The user can edit, add or remove nodes as they build their process and want to be notified when the results of an
Interesting
node have changed.
Take the following graph as an example when the user is interested in Data2 and Filter2. We want the following
- When
Data1
changes we want to execute the parts of the graph necessary to show the new data passed throughFilter2
. - When
Data2
changes we want to execute the parts of the graph necessary to show the new data passed throughData2
andFilter2
- We never want to execute more that the necessary number of steps to get the user new data
Write a function (and tests) that given a graph, the set of interesting
nodes, and a set of changed nodes returns a new graph containing just the operations we need to execute to display the new data.
Given the above graph, with interest in node Filter2
and a change in Join
return this graph [ 'Data1', 'Data2', 'Join', 'Filter2' ]
- Install node.js we love using nvm to mange node versions
- Install project dependencies
npm install
- Run the unit tests to make sure it worked
npm test
If you don't have a favorite editor I suggest webstorm setup as follows
- Install webstorm
- Open webstorm and
file > open...
this projects directory - Setup es6 -
file > settings > Languages and Frameworks > Javascript
from the dropdown chooseECMAScript 6
- Setup linter -
file > settings
in the search bar typeeslint
in the menu that comes up check theenable
box at the top
Install the project dependencies
npm install
Lint the code and run the tests on the commandline
npm test // lint and run tests
Start a development server and run the tests in the browser (useful for debugging)
npm run test-web
open localhost:8080/test.bundle // the tests are now running here