~/bend-docscommunity

swpick.bend checks

raw source on the hub · import cswap-bend-cli@0.1.0.0/swpick.bend as Swpick

3 imports
import Base
import ./json.bend as Json
import ./store/seq.bend as SSeq

Types

type Cand source · line 10 · raw

Data

type Sel source · line 14 · raw

Data

The first candidate to switch to, with a warning for each one skipped on the way.

type Pick source · line 18 · raw

Data

type BestOut source · line 21 · raw

Data

Definitions

def skip_with source · line 25 · raw

@+w:String -> @+ex:Bool -> @+r:Sel -> Sel

def at_limit source · line 32 · raw

@+h:Maybe<&2, U32> -> Bool

def sel_step2 source · line 39 · raw

@+dis:Bool -> @+sw:Bool -> @+limit:Bool -> @+slot:String -> @+r:Sel -> Sel

def sel_step source · line 50 · raw

@+avail:Bool -> @+c:Cand -> @+r:Sel -> Sel

def select_next source · line 57 · raw

@+cs:List<&2, Cand> -> @+avail:Bool -> Sel

Walk cs (already in rotation order, current slot excluded) as switch() does. avail is next-available: skip accounts with no headroom.

def sel_n source · line 64 · raw

@+c:Bool -> @+x:Nat -> @+y:Nat -> Nat

def index_of source · line 71 · raw

@+xs:List<&2, String> -> @+x:String -> @+i:Nat -> Nat

def rotated2 source · line 78 · raw

@+xs:List<&2, String> -> @+idx:Nat -> List<&2, String>

def rotated source · line 83 · raw

@+xs:List<&2, String> -> @+anchor:Maybe<&2, String> -> List<&2, String>

The other slots in rotation order after anchor: offsets 1..n-1 of the cyclic sequence. An unknown anchor counts as index 0, as in the reference.

def better source · line 86 · raw

@+found:Bool -> @+h:U32 -> @+cur:Pick -> Bool

def sel_pick source · line 91 · raw

@+c:Bool -> @+x:Pick -> @+y:Pick -> Pick

def best_known source · line 98 · raw

@+cs:List<&2, Cand> -> @+cur:Pick -> Pick

def any_unknown source · line 107 · raw

@+cs:List<&2, Cand> -> Bool

def best4 source · line 116 · raw

@+wins:Bool -> @+s:String -> @+unknown:Bool -> @+exhausted:Bool -> BestOut

def best3 source · line 127 · raw

@+p:Pick -> @+cur:U32 -> @+unknown:Bool -> BestOut

def best2 source · line 132 · raw

@+cur:Maybe<&2, U32> -> @+others:List<&2, Cand> -> @+p:Pick -> BestOut

def select_best source · line 143 · raw

@+cur:Maybe<&2, U32> -> @+others:List<&2, Cand> -> BestOut

_select_best_switchable: others are the switchable, enabled slots but the current one. Switch only to strictly more headroom.

def pct2 source · line 150 · raw

@+parts:List<&2, String> -> U32

def pct_hundredths source · line 160 · raw

@+t:String -> U32

"90.0" -> 9000, "12.34" -> 1234 (hundredths of a percent).

def pct_of2 source · line 163 · raw

@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> Maybe<&2, U32>

def pct_of source · line 170 · raw

@+w:0x0717344745a30ebad1f19045228e8f18/json.Json -> Maybe<&2, U32>

def push_pct source · line 173 · raw

@+m:Maybe<&2, U32> -> @+rest:List<&2, U32> -> List<&2, U32>

def lower_all source · line 180 · raw

@+xs:List<&2, String> -> List<&2, String>

def mem source · line 187 · raw

@+x:String -> @+xs:List<&2, String> -> Bool

def scoped_pick source · line 194 · raw

@+hit:Bool -> @+m:Maybe<&2, U32> -> @+rest:List<&2, U32> -> List<&2, U32>

def scoped_pcts source · line 201 · raw

@+items:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+wanted:List<&2, String> -> List<&2, U32>

def window_pct2 source · line 208 · raw

@+m:Maybe<&2, 0x0717344745a30ebad1f19045228e8f18/json.Json> -> Maybe<&2, U32>

def window_pct source · line 215 · raw

@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+key:String -> Maybe<&2, U32>

def sel_l source · line 218 · raw

@+c:Bool -> @+x:List<&2, U32> -> @+y:List<&2, U32> -> List<&2, U32>

def pcts source · line 227 · raw

@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+models:List<&2, String> -> List<&2, U32>

The percentages relevant_windows looks at: 5h, 7d and, with models, the scoped windows named by them (or all of them for "all").

def max_pct source · line 231 · raw

@+xs:List<&2, U32> -> @+acc:U32 -> U32

def min_u32 source · line 238 · raw

@+a:U32 -> @+b:U32 -> U32

def headroom2 source · line 241 · raw

@+xs:List<&2, U32> -> Maybe<&2, U32>

def headroom source · line 249 · raw

@+row:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+models:List<&2, String> -> Maybe<&2, U32>

100 - the busiest relevant window, from a usage row's lastGood.

def usage_row source · line 253 · raw

@+usage:0x0717344745a30ebad1f19045228e8f18/json.Json -> @+slot:String -> 0x0717344745a30ebad1f19045228e8f18/json.Json

usage.json -> the lastGood object of a slot.

def sel_lc source · line 256 · raw

@+c:Bool -> @+x:List<&2, Cand> -> @+y:List<&2, Cand> -> List<&2, Cand>