PERIOD

PERIOD
Static Members
DAYS
WEEKS
MONTHS

PERIOD

Durations to estimate impact over

PERIOD
Static Members
DAYS
WEEKS
MONTHS

defaultConfig

A defult configuration map providing values for all input data fields. This lets you call the on-covid-19 API with just the input data you care about

defaultConfig
Static Members
region
reportedCases
population
totalHospitalBeds

defaultEstimator

A default estimator function that gets used if the on-covid-19 API is called without one.

defaultEstimator
Parameters
data (Object = defaultConfig) a map of input fields and values for the estimation. Default to defaultConfig
Returns
any: It just returns a template data structure

onCovid19

The onCovid19 api entrypoint function.

onCovid19
Parameters
config (Object = {}) the input data
estimator (Function = defaultEstimator) the function handling estimation
Returns
Object: An object on which you can call estimateImpactAfter(..) with the duration to estimate for. Calling estimateImpactAfter(..) then produces an object on which you can call days() , week() , weeks() , 'month()', or months() on, allowing you indicate the period to estimate for.
Example
import estimator from 'path/to/estimator.js';

const data = { population: 5000000, reportedCases: 247, ... }
const estimate = onCovid19(data, estimator)
   .estimateImpactAfter(30)
   .days();

whatPercentOf

Given an initial number value, this function lets you compute the percent of another value on the initial value

whatPercentOf
Parameters
divisor (Number) the divisor of your percentage computation
Returns
Object: An object on which you can call an "is" function with the (dividend) figure you want to compute it percentage. Calling the "is" function returns the final computed percentage value
Example
const salary = 1500000;
const whatPercentOfPay = whatPercentOf(salary);
const airtimeBurden = whatPercentOfPay.is(25000);
const tvSubscriptionBurden = whatPercentOfPay.is(20000);

whatIs

Declaratively compute the percentage of any value

whatIs
Parameters
percent (String) A string representing the percentage you want to calculate. e.g '7.5%'
Returns
Object: An object on which you can call an "of" function with the figure you want the percentage computed for. Calling the "of" function returns the final computed percentage value
Example
const salary = 1000000;
const vat = whatIs('7.5%').of(salary);

chain

Makes it super easy to build your estimation as a list of sequencial function that all take an input, which could be coming from the previously called function in the sequence, and returns an output which might be the final estimation or one that gets passed to the next function in the sequence

chain
Parameters
fns (...Function)
Returns
Function: A single function that calls your sequence of chained functions with the input data it receives
Example
const stepOne = ({data}) => {};
const stepTwo = ({data}) => {};
const stepThree = ({data}) => {};

const covid19ImpactEstimator = data => {
  const estimatorFactory = chain(stepOne, stepTwo, stepThree);
  return estimatorFactory({data});
}

const lagosNG = {reportedCases: 111, ...};
const estimate = onCovid19(lagosNG, covid19ImpactEstimator)
  .estimateImpactAfter(30)
  .days();