just-throttle and debounce replaced with throttle-debounce

This commit is contained in:
Igor Lobanov 2023-11-13 16:55:36 +01:00
parent 8ac7b104a8
commit e82beb868a
4 changed files with 21 additions and 20 deletions

25
package-lock.json generated
View File

@ -13,7 +13,6 @@
"i18next": "22.4.15", "i18next": "22.4.15",
"i18next-icu": "2.3.0", "i18next-icu": "2.3.0",
"intl-messageformat": "10.5.3", "intl-messageformat": "10.5.3",
"just-throttle": "4.2.0",
"mailgun.js": "8.2.1" "mailgun.js": "8.2.1"
}, },
"devDependencies": { "devDependencies": {
@ -76,7 +75,6 @@
"bootstrap": "5.3.2", "bootstrap": "5.3.2",
"clsx": "2.0.0", "clsx": "2.0.0",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"debounce": "1.2.1",
"eslint": "8.53.0", "eslint": "8.53.0",
"eslint-config-stylelint": "20.0.0", "eslint-config-stylelint": "20.0.0",
"eslint-import-resolver-typescript": "3.6.1", "eslint-import-resolver-typescript": "3.6.1",
@ -123,6 +121,7 @@
"stylelint-order": "6.0.3", "stylelint-order": "6.0.3",
"stylelint-scss": "5.3.0", "stylelint-scss": "5.3.0",
"swiper": "9.4.1", "swiper": "9.4.1",
"throttle-debounce": "5.0.0",
"typescript": "5.2.2", "typescript": "5.2.2",
"typograf": "7.1.0", "typograf": "7.1.0",
"uniqolor": "1.1.0", "uniqolor": "1.1.0",
@ -5102,6 +5101,15 @@
"throttle-debounce": "^3.0.1" "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": { "node_modules/@remirror/types": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/@remirror/types/-/types-1.0.1.tgz", "resolved": "https://registry.npmjs.org/@remirror/types/-/types-1.0.1.tgz",
@ -13946,11 +13954,6 @@
"node": ">=4.0" "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": { "node_modules/kebab-case": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/kebab-case/-/kebab-case-1.0.2.tgz", "resolved": "https://registry.npmjs.org/kebab-case/-/kebab-case-1.0.2.tgz",
@ -18252,12 +18255,12 @@
"dev": true "dev": true
}, },
"node_modules/throttle-debounce": { "node_modules/throttle-debounce": {
"version": "3.0.1", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-3.0.1.tgz", "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-5.0.0.tgz",
"integrity": "sha512-dTEWWNu6JmeVXY0ZYoPuH5cRIwc0MeGbJwah9KUNYSJwommQpCzTySTpEe8Gs1J23aeWEuAobe4Ag7EHVt/LOg==", "integrity": "sha512-2iQTSgkkc1Zyk0MeVrt/3BvuOXYPl/R8Z0U2xxo9rjwNciaHDG3R+Lm6dh4EeUci49DanvBnuqI6jshoQQRGEg==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=10" "node": ">=12.22"
} }
}, },
"node_modules/through": { "node_modules/through": {

View File

@ -34,7 +34,6 @@
"i18next": "22.4.15", "i18next": "22.4.15",
"i18next-icu": "2.3.0", "i18next-icu": "2.3.0",
"intl-messageformat": "10.5.3", "intl-messageformat": "10.5.3",
"just-throttle": "4.2.0",
"mailgun.js": "8.2.1" "mailgun.js": "8.2.1"
}, },
"devDependencies": { "devDependencies": {
@ -97,7 +96,6 @@
"bootstrap": "5.3.2", "bootstrap": "5.3.2",
"clsx": "2.0.0", "clsx": "2.0.0",
"cross-env": "7.0.3", "cross-env": "7.0.3",
"debounce": "1.2.1",
"eslint": "8.53.0", "eslint": "8.53.0",
"eslint-config-stylelint": "20.0.0", "eslint-config-stylelint": "20.0.0",
"eslint-import-resolver-typescript": "3.6.1", "eslint-import-resolver-typescript": "3.6.1",
@ -144,6 +142,7 @@
"stylelint-order": "6.0.3", "stylelint-order": "6.0.3",
"stylelint-scss": "5.3.0", "stylelint-scss": "5.3.0",
"swiper": "9.4.1", "swiper": "9.4.1",
"throttle-debounce": "5.0.0",
"typescript": "5.2.2", "typescript": "5.2.2",
"typograf": "7.1.0", "typograf": "7.1.0",
"uniqolor": "1.1.0", "uniqolor": "1.1.0",

View File

@ -9,7 +9,7 @@ import { PAGE_SIZE, useNotifications } from '../../context/notifications'
import { NotificationView } from './NotificationView' import { NotificationView } from './NotificationView'
import { EmptyMessage } from './EmptyMessage' import { EmptyMessage } from './EmptyMessage'
import { Button } from '../_shared/Button' import { Button } from '../_shared/Button'
import throttle from 'just-throttle' import { throttle } from 'throttle-debounce'
import { useSession } from '../../context/session' import { useSession } from '../../context/session'
type Props = { type Props = {
@ -132,7 +132,7 @@ export const NotificationsPanel = (props: Props) => {
setIsLoading(false) setIsLoading(false)
} }
} }
const handleScrollThrottled = throttle(handleScroll, 50) const handleScrollThrottled = throttle(50, handleScroll)
onMount(() => { onMount(() => {
scrollContainerRef.current.addEventListener('scroll', handleScrollThrottled) scrollContainerRef.current.addEventListener('scroll', handleScrollThrottled)

View File

@ -2,11 +2,10 @@ import { For, Show, createSignal, createEffect, on, onMount, onCleanup } from 's
import { clsx } from 'clsx' import { clsx } from 'clsx'
import { DEFAULT_HEADER_OFFSET } from '../../stores/router' import { DEFAULT_HEADER_OFFSET } from '../../stores/router'
import { useLocalize } from '../../context/localize' import { useLocalize } from '../../context/localize'
import debounce from 'debounce'
import { Icon } from '../_shared/Icon' import { Icon } from '../_shared/Icon'
import styles from './TableOfContents.module.scss' import styles from './TableOfContents.module.scss'
import { isDesktop } from '../../utils/media-query' import { isDesktop } from '../../utils/media-query'
import throttle from 'just-throttle' import { throttle, debounce } from 'throttle-debounce'
interface Props { interface Props {
variant: 'article' | 'editor' variant: 'article' | 'editor'
@ -49,12 +48,12 @@ export const TableOfContents = (props: Props) => {
setAreHeadingsLoaded(true) 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)) const newActiveIndex = headings().findLastIndex((heading) => isInViewport(heading))
setActiveHeaderIndex(newActiveIndex) setActiveHeaderIndex(newActiveIndex)
}, 50) })
createEffect( createEffect(
on( on(