diff --git a/package-lock.json b/package-lock.json index 809a2792..b1a5125b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "i18next": "22.4.15", "i18next-icu": "2.3.0", "intl-messageformat": "10.5.3", - "just-throttle": "4.2.0", "mailgun.js": "8.2.1" }, "devDependencies": { @@ -76,7 +75,6 @@ "bootstrap": "5.3.2", "clsx": "2.0.0", "cross-env": "7.0.3", - "debounce": "1.2.1", "eslint": "8.53.0", "eslint-config-stylelint": "20.0.0", "eslint-import-resolver-typescript": "3.6.1", @@ -123,6 +121,7 @@ "stylelint-order": "6.0.3", "stylelint-scss": "5.3.0", "swiper": "9.4.1", + "throttle-debounce": "5.0.0", "typescript": "5.2.2", "typograf": "7.1.0", "uniqolor": "1.1.0", @@ -5102,6 +5101,15 @@ "throttle-debounce": "^3.0.1" } }, + "node_modules/@remirror/core-helpers/node_modules/throttle-debounce": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-3.0.1.tgz", + "integrity": "sha512-dTEWWNu6JmeVXY0ZYoPuH5cRIwc0MeGbJwah9KUNYSJwommQpCzTySTpEe8Gs1J23aeWEuAobe4Ag7EHVt/LOg==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/@remirror/types": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@remirror/types/-/types-1.0.1.tgz", @@ -13946,11 +13954,6 @@ "node": ">=4.0" } }, - "node_modules/just-throttle": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/just-throttle/-/just-throttle-4.2.0.tgz", - "integrity": "sha512-/iAZv1953JcExpvsywaPKjSzfTiCLqeguUTE6+VmK15mOcwxBx7/FHrVvS4WEErMR03TRazH8kcBSHqMagYIYg==" - }, "node_modules/kebab-case": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/kebab-case/-/kebab-case-1.0.2.tgz", @@ -18252,12 +18255,12 @@ "dev": true }, "node_modules/throttle-debounce": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-3.0.1.tgz", - "integrity": "sha512-dTEWWNu6JmeVXY0ZYoPuH5cRIwc0MeGbJwah9KUNYSJwommQpCzTySTpEe8Gs1J23aeWEuAobe4Ag7EHVt/LOg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-5.0.0.tgz", + "integrity": "sha512-2iQTSgkkc1Zyk0MeVrt/3BvuOXYPl/R8Z0U2xxo9rjwNciaHDG3R+Lm6dh4EeUci49DanvBnuqI6jshoQQRGEg==", "dev": true, "engines": { - "node": ">=10" + "node": ">=12.22" } }, "node_modules/through": { diff --git a/package.json b/package.json index 6abc61e1..0378a2b7 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "i18next": "22.4.15", "i18next-icu": "2.3.0", "intl-messageformat": "10.5.3", - "just-throttle": "4.2.0", "mailgun.js": "8.2.1" }, "devDependencies": { @@ -97,7 +96,6 @@ "bootstrap": "5.3.2", "clsx": "2.0.0", "cross-env": "7.0.3", - "debounce": "1.2.1", "eslint": "8.53.0", "eslint-config-stylelint": "20.0.0", "eslint-import-resolver-typescript": "3.6.1", @@ -144,6 +142,7 @@ "stylelint-order": "6.0.3", "stylelint-scss": "5.3.0", "swiper": "9.4.1", + "throttle-debounce": "5.0.0", "typescript": "5.2.2", "typograf": "7.1.0", "uniqolor": "1.1.0", diff --git a/src/components/NotificationsPanel/NotificationsPanel.tsx b/src/components/NotificationsPanel/NotificationsPanel.tsx index 2618895f..30619e70 100644 --- a/src/components/NotificationsPanel/NotificationsPanel.tsx +++ b/src/components/NotificationsPanel/NotificationsPanel.tsx @@ -9,7 +9,7 @@ import { PAGE_SIZE, useNotifications } from '../../context/notifications' import { NotificationView } from './NotificationView' import { EmptyMessage } from './EmptyMessage' import { Button } from '../_shared/Button' -import throttle from 'just-throttle' +import { throttle } from 'throttle-debounce' import { useSession } from '../../context/session' type Props = { @@ -132,7 +132,7 @@ export const NotificationsPanel = (props: Props) => { setIsLoading(false) } } - const handleScrollThrottled = throttle(handleScroll, 50) + const handleScrollThrottled = throttle(50, handleScroll) onMount(() => { scrollContainerRef.current.addEventListener('scroll', handleScrollThrottled) diff --git a/src/components/TableOfContents/TableOfContents.tsx b/src/components/TableOfContents/TableOfContents.tsx index 1efcdd4e..d35601e9 100644 --- a/src/components/TableOfContents/TableOfContents.tsx +++ b/src/components/TableOfContents/TableOfContents.tsx @@ -2,11 +2,10 @@ import { For, Show, createSignal, createEffect, on, onMount, onCleanup } from 's import { clsx } from 'clsx' import { DEFAULT_HEADER_OFFSET } from '../../stores/router' import { useLocalize } from '../../context/localize' -import debounce from 'debounce' import { Icon } from '../_shared/Icon' import styles from './TableOfContents.module.scss' import { isDesktop } from '../../utils/media-query' -import throttle from 'just-throttle' +import { throttle, debounce } from 'throttle-debounce' interface Props { variant: 'article' | 'editor' @@ -49,12 +48,12 @@ export const TableOfContents = (props: Props) => { setAreHeadingsLoaded(true) } - const debouncedUpdateHeadings = debounce(updateHeadings, 500) + const debouncedUpdateHeadings = debounce(500, updateHeadings) - const updateActiveHeader = throttle(() => { + const updateActiveHeader = throttle(50, () => { const newActiveIndex = headings().findLastIndex((heading) => isInViewport(heading)) setActiveHeaderIndex(newActiveIndex) - }, 50) + }) createEffect( on(