Skip to content

Commit

Permalink
chore: remove lodash in favor of remeda
Browse files Browse the repository at this point in the history
  • Loading branch information
kahlstrm committed Jan 4, 2025
1 parent cacf90f commit 17a0510
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 28 deletions.
2 changes: 0 additions & 2 deletions apps/cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"dotenv": "^16.4.7",
"express": "^4.21.2",
"form-data": "^4.0.1",
"lodash": "^4.17.21",
"mailgun.js": "^10.2.4",
"nanoid": "^3.3.8",
"papaparse": "^5.4.1",
Expand All @@ -43,7 +42,6 @@
"@tietokilta/ui": "workspace:*",
"@types/express": "^4.17.21",
"@types/express-fileupload": "^1.5.1",
"@types/lodash": "^4.17.13",
"@types/papaparse": "^5.3.15",
"@types/react": "catalog:",
"copyfiles": "^2.4.1",
Expand Down
3 changes: 1 addition & 2 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"autoprefixer": "catalog:",
"clsx": "catalog:",
"date-fns": "^4.1.0",
"lodash": "^4.17.21",
"next": "^14.2.20",
"next-international": "^1.3.1",
"nextjs-toploader": "^3.7.15",
Expand All @@ -30,6 +29,7 @@
"react-markdown": "^9.0.1",
"remark": "^15.0.1",
"remark-gfm": "^4.0.0",
"remeda": "^2.19.0",
"server-only": "^0.0.1",
"sharp": "^0.33.5",
"strip-markdown": "^6.0.0",
Expand All @@ -46,7 +46,6 @@
"@tietokilta/cms-types": "workspace:*",
"@tietokilta/config-typescript": "workspace:*",
"@tietokilta/eslint-config": "workspace:*",
"@types/lodash": "^4.17.13",
"@types/mdast": "^4.0.4",
"@types/node": "catalog:",
"@types/qs": "^6.9.17",
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/events-display/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, ClockIcon, MapPinIcon } from "@tietokilta/ui";
import Link from "next/link";
import { Suspense } from "react";
import _ from "lodash";
import { chunk } from "remeda";
import { notFound } from "next/navigation";
import {
Pagination,
Expand Down Expand Up @@ -112,7 +112,7 @@ async function EventList({ currentPage = 1 }: { currentPage?: number }) {
return null;
}

const paginatedEvents = _.chunk(eventsList, 5);
const paginatedEvents = chunk(eventsList, 5);
const pageCount = paginatedEvents.length;

if (pageCount !== 0 && (currentPage < 1 || currentPage > pageCount)) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Image from "next/image";
import { useEffect, useState } from "react";
import { useScramble } from "use-scramble";
import _ from "lodash";
import { shuffle } from "remeda";
import { cn } from "../../lib/utils";

export interface ImageWithPhotographer {
Expand Down Expand Up @@ -86,7 +86,7 @@ export function Hero({
});

useEffect(() => {
const shuffledTexts = _.shuffle(texts);
const shuffledTexts = shuffle(texts);
setCurrentText(shuffledTexts[0]);

const interval = setInterval(() => {
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/honors-list/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AwardedHonor, Honor } from "@tietokilta/cms-types/payload";
import { ChevronDownIcon } from "@tietokilta/ui";
import _ from "lodash";
import type { JSX } from "react";
import { unique } from "remeda";
import { cn } from "../../lib/utils";

function AwardedPersonDropdown({
Expand Down Expand Up @@ -58,11 +58,11 @@ export function HonorsList({ honor }: { honor: Honor }): JSX.Element {
const awardedPersons = honor.awardedHonors.map(
(item) => item.awardedHonor as AwardedHonor,
);
const awardsByYear = _.groupBy(
const awardsByYear = Object.groupBy(
awardedPersons,
(awardedPerson) => awardedPerson.guildYear,
);
const years = _.uniq(
const years = unique(
awardedPersons.map((awardedPerson) => awardedPerson.guildYear),
).sort((a, b) => Number(b) - Number(a));

Expand All @@ -71,7 +71,7 @@ export function HonorsList({ honor }: { honor: Honor }): JSX.Element {
{Object.entries(years).map((awardYear) => (
<YearGroup
year={parseInt(awardYear[1], 10)}
awardedPersons={awardsByYear[awardYear[1]]}
awardedPersons={awardsByYear[awardYear[1]] ?? []}
key={awardYear[1]}
/>
))}
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/magazine-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type {
MagazineIssue,
Media,
} from "@tietokilta/cms-types/payload";
import _ from "lodash";
import Image from "next/image";
import { unique } from "remeda";
import TikLogo from "../../assets/TiK-logo.png";

function IssueCard({ issue }: { issue: MagazineIssue }) {
Expand Down Expand Up @@ -33,12 +33,12 @@ export function MagazineList({
}): React.ReactNode {
if (magazine.type !== "Alkorytmi" || !magazine.issues) return null;

const issuesByYear = _.groupBy(
const issuesByYear = Object.groupBy(
magazine.issues,
(issue) => (issue.issue as MagazineIssue).year,
);

const years = _.uniq(
const years = unique(
magazine.issues.map((issue) => (issue.issue as MagazineIssue).year),
).sort((a, b) => Number(b) - Number(a));

Expand All @@ -59,7 +59,7 @@ export function MagazineList({
</div>
<div className="grid max-w-64 grid-cols-1 items-baseline gap-8 min-[460px]:max-w-none min-[460px]:grid-cols-2 min-[660px]:grid-cols-3 lg:grid-cols-4">
{issuesByYear[year]
.sort(
?.sort(
(a, b) =>
Number((a.issue as MagazineIssue).issueNumber) -
Number((b.issue as MagazineIssue).issueNumber),
Expand Down
28 changes: 16 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 17a0510

Please sign in to comment.