es-toolkit
Advanced tools
Comparing version 1.0.4 to 1.1.0-dev.43
# es-toolkit Changelog | ||
## Version v1.1.0 | ||
Released on June 5th, 2024. | ||
- Support passing arguments to throttled and debounced functions. (https://github.com/toss/es-toolkit/pull/26) | ||
## Version v1.0.4 | ||
@@ -4,0 +10,0 @@ |
@@ -6,5 +6,5 @@ /** | ||
* | ||
* @param {() => void} func - The function to debounce. | ||
* @param {F} func - The function to debounce. | ||
* @param {number} debounceMs - The number of milliseconds to delay. | ||
* @returns {{ (): void; cancel: () => void }} A new debounced function with a `cancel` method. | ||
* @returns {F & { cancel: () => void }} A new debounced function with a `cancel` method. | ||
* | ||
@@ -22,4 +22,3 @@ * @example | ||
*/ | ||
declare function debounce(func: () => void, debounceMs: number): { | ||
(): void; | ||
declare function debounce<F extends (...args: any[]) => void>(func: F, debounceMs: number): F & { | ||
cancel: () => void; | ||
@@ -26,0 +25,0 @@ }; |
@@ -28,3 +28,3 @@ "use strict"; | ||
let timeoutId = null; | ||
const debounced = function() { | ||
const debounced = function(...args) { | ||
if (timeoutId != null) { | ||
@@ -34,3 +34,3 @@ clearTimeout(timeoutId); | ||
timeoutId = setTimeout(() => { | ||
func(); | ||
func(...args); | ||
}, debounceMs); | ||
@@ -37,0 +37,0 @@ }; |
@@ -32,3 +32,3 @@ "use strict"; | ||
let timeoutId = null; | ||
const debounced = function() { | ||
const debounced = function(...args) { | ||
if (timeoutId != null) { | ||
@@ -38,3 +38,3 @@ clearTimeout(timeoutId); | ||
timeoutId = setTimeout(() => { | ||
func(); | ||
func(...args); | ||
}, debounceMs); | ||
@@ -68,7 +68,7 @@ }; | ||
let lastCallTime; | ||
const throttledFunction = function() { | ||
const throttledFunction = function(...args) { | ||
const now = Date.now(); | ||
if (lastCallTime == null || now - lastCallTime >= throttleMs) { | ||
lastCallTime = now; | ||
func(); | ||
func(...args); | ||
} | ||
@@ -75,0 +75,0 @@ }; |
@@ -6,5 +6,5 @@ /** | ||
* | ||
* @param {() => void} func - The function to throttle. | ||
* @param {F} func - The function to throttle. | ||
* @param {number} throttleMs - The number of milliseconds to throttle executions to. | ||
* @returns {() => void} A new throttled function. | ||
* @returns {F} A new throttled function that accepts the same parameters as the original function. | ||
* | ||
@@ -27,4 +27,4 @@ * @example | ||
*/ | ||
declare function throttle(func: () => void, throttleMs: number): () => void; | ||
declare function throttle<F extends (...args: any[]) => void>(func: F, throttleMs: number): F; | ||
export { throttle }; |
@@ -28,7 +28,7 @@ "use strict"; | ||
let lastCallTime; | ||
const throttledFunction = function() { | ||
const throttledFunction = function(...args) { | ||
const now = Date.now(); | ||
if (lastCallTime == null || now - lastCallTime >= throttleMs) { | ||
lastCallTime = now; | ||
func(); | ||
func(...args); | ||
} | ||
@@ -35,0 +35,0 @@ }; |
@@ -348,3 +348,3 @@ "use strict"; | ||
let timeoutId = null; | ||
const debounced = function() { | ||
const debounced = function(...args) { | ||
if (timeoutId != null) { | ||
@@ -354,3 +354,3 @@ clearTimeout(timeoutId); | ||
timeoutId = setTimeout(() => { | ||
func(); | ||
func(...args); | ||
}, debounceMs); | ||
@@ -384,7 +384,7 @@ }; | ||
let lastCallTime; | ||
const throttledFunction = function() { | ||
const throttledFunction = function(...args) { | ||
const now = Date.now(); | ||
if (lastCallTime == null || now - lastCallTime >= throttleMs) { | ||
lastCallTime = now; | ||
func(); | ||
func(...args); | ||
} | ||
@@ -391,0 +391,0 @@ }; |
{ | ||
"name": "es-toolkit", | ||
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.", | ||
"version": "1.0.4", | ||
"version": "1.1.0-dev.43+795c83bd", | ||
"workspaces": [ | ||
@@ -193,3 +193,4 @@ "docs" | ||
"test": "vitest run --coverage --typecheck", | ||
"lint": "eslint ./src --ext .ts" | ||
"lint": "eslint ./src --ext .ts", | ||
"format": "prettier --write ." | ||
}, | ||
@@ -196,0 +197,0 @@ "main": "./dist/index.js", |
@@ -15,3 +15,2 @@ ![](./docs/public/og.png) | ||
## Contributing | ||
@@ -18,0 +17,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
470802
5101
2
31
1