Prefer const over let over var

This commit is contained in:
Marshall Polaris 2022-05-24 13:17:39 -07:00
parent 7d1131aa6f
commit 5f3253966e
3 changed files with 6 additions and 6 deletions

View File

@ -170,7 +170,7 @@ export function calculateNumericDpmShares(
([amount]) => amount ([amount]) => amount
).map(([, i]) => i) ).map(([, i]) => i)
for (let i of order) { for (const i of order) {
const [bucket, bet] = bets[i] const [bucket, bet] = bets[i]
shares[i] = calculateDpmShares(totalShares, bet, bucket) shares[i] = calculateDpmShares(totalShares, bet, bucket)
totalShares = addObjects(totalShares, { [bucket]: shares[i] }) totalShares = addObjects(totalShares, { [bucket]: shares[i] })

View File

@ -1,9 +1,9 @@
import { union } from 'lodash' import { union } from 'lodash'
export const removeUndefinedProps = <T>(obj: T): T => { export const removeUndefinedProps = <T>(obj: T): T => {
let newObj: any = {} const newObj: any = {}
for (let key of Object.keys(obj)) { for (const key of Object.keys(obj)) {
if ((obj as any)[key] !== undefined) newObj[key] = (obj as any)[key] if ((obj as any)[key] !== undefined) newObj[key] = (obj as any)[key]
} }
@ -17,7 +17,7 @@ export const addObjects = <T extends { [key: string]: number }>(
const keys = union(Object.keys(obj1), Object.keys(obj2)) const keys = union(Object.keys(obj1), Object.keys(obj2))
const newObj = {} as any const newObj = {} as any
for (let key of keys) { for (const key of keys) {
newObj[key] = (obj1[key] ?? 0) + (obj2[key] ?? 0) newObj[key] = (obj1[key] ?? 0) + (obj2[key] ?? 0)
} }

View File

@ -5,7 +5,7 @@ export const randomString = (length = 12) =>
export function genHash(str: string) { export function genHash(str: string) {
// xmur3 // xmur3
for (var i = 0, h = 1779033703 ^ str.length; i < str.length; i++) { for (let i = 0, h = 1779033703 ^ str.length; i < str.length; i++) {
h = Math.imul(h ^ str.charCodeAt(i), 3432918353) h = Math.imul(h ^ str.charCodeAt(i), 3432918353)
h = (h << 13) | (h >>> 19) h = (h << 13) | (h >>> 19)
} }
@ -28,7 +28,7 @@ export function createRNG(seed: string) {
b >>>= 0 b >>>= 0
c >>>= 0 c >>>= 0
d >>>= 0 d >>>= 0
var t = (a + b) | 0 let t = (a + b) | 0
a = b ^ (b >>> 9) a = b ^ (b >>> 9)
b = (c + (c << 3)) | 0 b = (c + (c << 3)) | 0
c = (c << 21) | (c >>> 11) c = (c << 21) | (c >>> 11)