Skip to content

Commit

Permalink
refactor: chunk function (#2435)
Browse files Browse the repository at this point in the history
  • Loading branch information
namgold authored Dec 8, 2023
1 parent 3868562 commit 3307e25
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/state/multicall/updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useMulticallContract } from 'hooks/useContract'
import useDebounce from 'hooks/useDebounce'
import { useBlockNumber } from 'state/application/hooks'
import { AppDispatch, AppState } from 'state/index'
import chunkArray from 'utils/chunkArray'
import { chunk } from 'utils/array'
import { CancelledError, RetryableError, retry } from 'utils/retry'

import {
Expand Down Expand Up @@ -177,7 +177,7 @@ export default function Updater(): null {
if (outdatedCallKeys.length === 0) return
const calls = outdatedCallKeys.map(key => parseCallKey(key))

const chunkedCalls = chunkArray(calls, CALL_CHUNK_SIZE)
const chunkedCalls = chunk(calls, CALL_CHUNK_SIZE)

if (cancellations.current?.blockNumber !== latestBlockNumber) {
cancellations.current?.cancellations?.forEach(c => c())
Expand Down
1 change: 1 addition & 0 deletions src/utils/array.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const chunk = <T>(arr: readonly T[], chunkSize: number): T[][] => {
if (chunkSize < 1) throw new Error('chunkSize must be gte 1')
const result = []
for (let i = 0; i < arr.length; i += chunkSize) {
result.push(arr.slice(i, i + chunkSize))
Expand Down
11 changes: 0 additions & 11 deletions src/utils/chunkArray.ts

This file was deleted.

0 comments on commit 3307e25

Please sign in to comment.