diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 13:37:43 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 13:37:43 -0600 |
commit | 16cfbd19157df76e7296dddb287412f1099feb33 (patch) | |
tree | e4bbf892066cceeaeeaee4c25e5365152412a1c3 /static/src/assets/trading-in-the-rain/Distributor.js | |
parent | 3cdee89c961ae9c836234f5aec87174a04a800a8 (diff) |
Move static assets to within srv
Diffstat (limited to 'static/src/assets/trading-in-the-rain/Distributor.js')
-rw-r--r-- | static/src/assets/trading-in-the-rain/Distributor.js | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/static/src/assets/trading-in-the-rain/Distributor.js b/static/src/assets/trading-in-the-rain/Distributor.js deleted file mode 100644 index fa6e9f2..0000000 --- a/static/src/assets/trading-in-the-rain/Distributor.js +++ /dev/null @@ -1,42 +0,0 @@ -function distribute(val, minOld, maxOld, minNew, maxNew) { - let scalar = (val - minOld) / (maxOld - minOld); - return minNew + ((maxNew - minNew) * scalar); -} - -function Distributor(capacity) { - this.cap = capacity; - - this.reset = () => { - this.arr = []; - this.arrSorted = []; - this.length = 0; - }; - this.reset(); - - // add adds the given value into the series, shifting off the oldest value if - // the series is at capacity. - this.add = (val) => { - this.arr.push(val); - if (this.arr.length >= this.cap) this.arr.shift(); - this.arrSorted = this.arr.slice(); // copy array - this.arrSorted.sort(); - this.length = this.arr.length; - }; - - // distribute finds where the given value falls within the series, and then - // scales that into the given range (inclusive). - this.distribute = (val, min, max) => { - if (this.length == 0) throw "cannot locate within empty Distributor"; - - let idx = this.length; - for (i in this.arrSorted) { - if (val < this.arrSorted[i]) { - idx = i; - break; - } - } - - return distribute(idx, 0, this.length, min, max); - }; -} - |