Plan.js - Values composed of Strategies
Plan.js allows consumers to create values whose logic is broken up into individual and self-contained strategies. How those strategies interact with the end-value depends on the plan-type.
Install
npm install plan.js
bower install plan.js
Usage
var Plan = ; // => 110 // Bind to strategies // Strategy 1 value;
Docs
Plan()
Base class for Plans. Create a new instance:
var Plan = ;var planA = ;var planB = Plan;
To create your Plan, choose an inheritence method and implement your own valueOf
function. See Reduce for more details.
.set( key, val )
Sets a key to val on the object that will be bound to strategies.
.use( strategy )
Adds a strategy to the plan. Strategy may be function an object:
{}
.value()
Runs all strategies to get the value of the plan
.clone()
Clones the current instance, data and middleware intact.
Plan.Reduce( intialValue )
A reduce plan. Initial value is passed into the reduce chain.
Examples
var Plan = ;// Create a plan with initial value of 0var orderTotalPlan = 0; // Generic order total planorderTotalPlan // Sub-total // Promo Code // Sales tax // Only integer results in pennies // Create an order modelvar order = Object; // => 1949ordertotal;
License ISC