Skip to content

Instantly share code, notes, and snippets.

@DominicTobias-b1
DominicTobias-b1 / ReduxStore.ts
Created April 3, 2020 01:09
Multi-store Redux with hooks
interface ActionShape {
type: string
payload: unknown
}
interface DevTools {
connect: () => void
send: (action: string, payload: unknown) => void
}
@DominicTobias-b1
DominicTobias-b1 / math.test.ts
Created August 18, 2020 08:36
Round to tick size
import { round, floor, ceil, roundToTick, floorToTick, ceilToTick } from './math'
describe('math', () => {
it('round works up to 8 decimals and 999 million', () => {
expect(round(123.123456789, 0)).toEqual(123)
expect(round(123.123456789, 1)).toEqual(123.1)
expect(round(123.123456789, 2)).toEqual(123.12)
expect(round(123.123456789, 3)).toEqual(123.123)
expect(round(123.123456789, 4)).toEqual(123.1235)
expect(round(123.123456789, 5)).toEqual(123.12346)