Skip to content

Conversation

david-crespo
Copy link
Collaborator

@david-crespo david-crespo commented Jun 4, 2024

This is kind of a palate cleanser, nothing important. I saw this lovely library https://remedajs.com/ recommended by @TkDodo, so I tried it and it's very nice. We have some little utilities around arrays and objects and Remeda has drop-in replacements for them. The advantage of using Remeda is

  1. We can delete our tests for these utils because we know remeda is legit
  2. Anything else we need is just there
  3. Many of remeda's functions are curried and optimized for lazy evaluation as part of a pipeline, which means a filter().map().filter() chain doesn't have to loop through the list three times.

This PR makes our bundle only 300 bytes bigger after gzip, and that will probably go away after we get rid of the util functions completely instead of wrapping Remeda.

Copy link

vercel bot commented Jun 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Jun 4, 2024 7:58pm

import { useMemo } from 'react'

import { lowestBy, sortBy } from '~/util/array'
import * as R from 'remeda'
Copy link
Collaborator Author

@david-crespo david-crespo Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out this tree-shakes perfectly well, so we don't need to bother with manual

import { sortBy, firstBy } from 'remeda'

@david-crespo david-crespo merged commit 13ce748 into main Jun 6, 2024
@david-crespo david-crespo deleted the remeda branch June 6, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant