Skip to content

Commit

Permalink
chore: use native flatMap (Uniswap#2231)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzmp authored Sep 3, 2021
1 parent 30cffb7 commit 416a3f9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 10 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"graphql-request": "^3.4.0",
"inter-ui": "^3.13.1",
"jest-styled-components": "^7.0.5",
"lodash.flatmap": "^4.5.0",
"luxon": "^1.25.0",
"ms.macro": "^2.0.0",
"multicodec": "^3.0.1",
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useAllCurrencyCombinations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Currency, Token } from '@uniswap/sdk-core'
import flatMap from 'lodash.flatmap'
import { useMemo } from 'react'
import { ADDITIONAL_BASES, BASES_TO_CHECK_TRADES_AGAINST, CUSTOM_BASES } from '../constants/routing'
import { useActiveWeb3React } from './web3'
Expand All @@ -20,7 +19,7 @@ export function useAllCurrencyCombinations(currencyA?: Currency, currencyB?: Cur
}, [chainId, tokenA, tokenB])

const basePairs: [Token, Token][] = useMemo(
() => flatMap(bases, (base): [Token, Token][] => bases.map((otherBase) => [base, otherBase])),
() => bases.flatMap((base): [Token, Token][] => bases.map((otherBase) => [base, otherBase])),
[bases]
)

Expand Down
3 changes: 1 addition & 2 deletions src/state/user/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { L2_CHAIN_IDS } from 'constants/chains'
import { SupportedLocale } from 'constants/locales'
import { L2_DEADLINE_FROM_NOW } from 'constants/misc'
import JSBI from 'jsbi'
import flatMap from 'lodash.flatmap'
import { useCallback, useMemo } from 'react'
import { shallowEqual } from 'react-redux'
import { useAppDispatch, useAppSelector } from 'state/hooks'
Expand Down Expand Up @@ -285,7 +284,7 @@ export function useTrackedTokenPairs(): [Token, Token][] {
const generatedPairs: [Token, Token][] = useMemo(
() =>
chainId
? flatMap(Object.keys(tokens), (tokenAddress) => {
? Object.keys(tokens).flatMap((tokenAddress) => {
const token = tokens[tokenAddress]
// for each token on the current chain,
return (
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13176,11 +13176,6 @@ lodash.debounce@^4.0.8:
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=

lodash.flatmap@^4.5.0:
version "4.5.0"
resolved "https://registry.npmjs.org/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz"
integrity sha1-74y/QI9uSCaGYzRTBcaswLd4cC4=

lodash.get@^4, lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz"
Expand Down

0 comments on commit 416a3f9

Please sign in to comment.