Scientist
A Javascript library for carefully refactoring critical paths. Influenced heavily from github/scientist.
Scientist is built with and accepts Promises (or Functions that return Promises) in any experiment.
How to Science!
Here's a quick and dirty example of how to Science!
var Experiment = Experiment var experiment = 'getData'// use: the control. value will be returned by `.run`.experiment// try: the candidate. value will be reported in `.publish`.experiment// run: run the experiment.experiment
Science within Models
var Scientist = {}util MyModelprototype { var experiment = this // use: the control. value will be returned by `.run` experiment // try: the candidate. value will be reported in `.publish`. experiment // run: run the experiment. // NOTE: bluebird allows `.asCallback`, which can help in models w/ callbacks. experiment} var m = m
Publishing Results
A very simple publisher that will print results to the screen.
var Experiment = Experimentvar find = { Experiment}util /** * Publisher function. Takes a result, must return a Promise. * @param * @return */MyExperimentprototype { var control = var candidate = console console console console console console return Promise}
This publisher is used like so:
// as the first case, with just an Experiment:var experiment = 'foobar' // if you want to include the Scientist in the model:SomeModelprototype { var experiment = this // and continue with the experiment...}