bets
v0.9.5
Published
Fixed odds bets library.
Downloads
20
Maintainers
Readme
bets.js
Fixed odds bets library.
Installation
npm install bets --save
Usage
var bets = require('bets');
var b = bets();
b.lines()
.set(1, {oddsNum: 1, oddsDen: 2}) // set line "1"
.set({1: {...}, 2: {...}}) // set all lines
.set([{...}, {...}]) // use an array instead
.get(1) // get line "1"
.get() // get all lines
b.wagers()
.set(1, {lineIds: [1], amount: 5}); // set wager "1"
.set({1: {...}, 2: {...}}); // set all wagers
.set([{...}, {...}]); // use an array instead
b.wagers().totalRisk(); // get total risk
b.wagers().totalPayout(); // get total payout
b.wagers()
.at(1) // select wager "1"
.odds() // get its odds
.amount(7) // change its amount
.parts()
.at(0)
.lineId(2) // change its line id
.lineId() // get its line id
b
.lines()
.set({...})
.done() // finish with lines collection
.wagers()
.set({...})
.done(); // finish with wagers collection
// place a parlay bet
b.wagers()
.at(2)
.type('parlay')
.parts()
.at(0).lineId(1).done()
.at(1).lineId(2).done()
.at(2).lineId(3).done()
.done()
.amount(20);
// use an object instead
b.wagers().set(2, {
risk: 20,
type: 'parlay',
parts: [
{lineId: 1},
{lineId: 2},
{lineId: 3},
]
});
Active/Inactive
Activate/deactivate wagers to alter the total risk/payout:
var b = bets();
b.lines().set(1, {oddsNum: 2, oddsDen: 1});
b.wagers().set(1, {risk: 10, lineIds: [1]});
b.wagers().set(2, {risk: 5, lineIds: [1]});
b.wagers.totalPayout(); // 30
b.wagers().at(2).active(false);
b.wagers.totalPayout(); // 20
Config
You can change property names of the underlying data (risk, oddsNum, oddsDen, lineIds, etc...). For example, changing risk to amount:
var bets = require('bets');
var conf = {wager: {risk: 'amount'}};
var b = bets(conf); // init config
b = bets().config(conf); // or do it later
b.wagers().at(1).risk(5);
b.wagers().get(); // {1: {amount: 5}}
b.wagers().set(1, {amount: 10});
b.wagers().at(1).risk(); // 10
Global
Declare a new global library with the config data of your choice.
var Bets = require('bets');
var bets = Bets
.global()
.config({line: {id: 'lineID'}})
.config({wager: {risk: 'amount'}});