kontroll 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/package.json +18 -14
package/dist/index.d.mts
CHANGED
|
@@ -27,7 +27,9 @@ interface KontrollCountdownOptions extends KontrollBaseOptions {
|
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Countdown for a period of ms then execute the first/replaced callback, based on `options.replace`.
|
|
30
|
+
*
|
|
30
31
|
* Calls while the timer haven't finished are dropped.
|
|
32
|
+
*
|
|
31
33
|
* ---
|
|
32
34
|
*
|
|
33
35
|
* Example
|
|
@@ -38,6 +40,7 @@ interface KontrollCountdownOptions extends KontrollBaseOptions {
|
|
|
38
40
|
* // 500ms passed
|
|
39
41
|
* // Result: 1
|
|
40
42
|
* ```
|
|
43
|
+
*
|
|
41
44
|
* ---
|
|
42
45
|
*
|
|
43
46
|
* Example with `options.replace=true`:
|
|
@@ -59,7 +62,9 @@ interface KontrollDebounceOptions extends KontrollBaseOptions {
|
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
61
64
|
* Creates a timer that will execute the callback upon finish, calls while the timer haven't finished recreates the timer.
|
|
65
|
+
*
|
|
62
66
|
* If `options.leading`, execute callback immediately for initial call.
|
|
67
|
+
*
|
|
63
68
|
* ---
|
|
64
69
|
*
|
|
65
70
|
* Example:
|
|
@@ -70,6 +75,7 @@ interface KontrollDebounceOptions extends KontrollBaseOptions {
|
|
|
70
75
|
* // 1000ms passed
|
|
71
76
|
* // Result: 2
|
|
72
77
|
* ```
|
|
78
|
+
*
|
|
73
79
|
* ---
|
|
74
80
|
*
|
|
75
81
|
* Example with `options.leading`:
|
|
@@ -94,9 +100,13 @@ interface KontrollThrottleOptions extends KontrollBaseOptions {
|
|
|
94
100
|
}
|
|
95
101
|
/**
|
|
96
102
|
* Executes the callback, and bypass any subsequent calls for a period of ms.
|
|
103
|
+
*
|
|
97
104
|
* Calls while the timer haven't finished are dropped.
|
|
105
|
+
*
|
|
98
106
|
* If `options.trailing` and calls while the timer haven't finished are received,
|
|
107
|
+
*
|
|
99
108
|
* an additional execution with last received arguments is performed.
|
|
109
|
+
*
|
|
100
110
|
* ---
|
|
101
111
|
*
|
|
102
112
|
* Example:
|
|
@@ -108,6 +118,7 @@ interface KontrollThrottleOptions extends KontrollBaseOptions {
|
|
|
108
118
|
* // 9999ms passed
|
|
109
119
|
* // (Nothing)
|
|
110
120
|
* ```
|
|
121
|
+
*
|
|
111
122
|
* ---
|
|
112
123
|
*
|
|
113
124
|
* Example with `options.trailing`:
|
|
@@ -127,4 +138,5 @@ interface KontrollThrottleOptions extends KontrollBaseOptions {
|
|
|
127
138
|
*/
|
|
128
139
|
declare function throttle(ms: number, callback: Fn, { key, trailing }?: KontrollThrottleOptions): KontrollClearer;
|
|
129
140
|
|
|
130
|
-
export {
|
|
141
|
+
export { clear, countdown, debounce, throttle };
|
|
142
|
+
export type { KontrollBaseOptions, KontrollClearer, KontrollCountdownOptions, KontrollDebounceOptions, KontrollStore, KontrollThrottleOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,9 @@ interface KontrollCountdownOptions extends KontrollBaseOptions {
|
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Countdown for a period of ms then execute the first/replaced callback, based on `options.replace`.
|
|
30
|
+
*
|
|
30
31
|
* Calls while the timer haven't finished are dropped.
|
|
32
|
+
*
|
|
31
33
|
* ---
|
|
32
34
|
*
|
|
33
35
|
* Example
|
|
@@ -38,6 +40,7 @@ interface KontrollCountdownOptions extends KontrollBaseOptions {
|
|
|
38
40
|
* // 500ms passed
|
|
39
41
|
* // Result: 1
|
|
40
42
|
* ```
|
|
43
|
+
*
|
|
41
44
|
* ---
|
|
42
45
|
*
|
|
43
46
|
* Example with `options.replace=true`:
|
|
@@ -59,7 +62,9 @@ interface KontrollDebounceOptions extends KontrollBaseOptions {
|
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
61
64
|
* Creates a timer that will execute the callback upon finish, calls while the timer haven't finished recreates the timer.
|
|
65
|
+
*
|
|
62
66
|
* If `options.leading`, execute callback immediately for initial call.
|
|
67
|
+
*
|
|
63
68
|
* ---
|
|
64
69
|
*
|
|
65
70
|
* Example:
|
|
@@ -70,6 +75,7 @@ interface KontrollDebounceOptions extends KontrollBaseOptions {
|
|
|
70
75
|
* // 1000ms passed
|
|
71
76
|
* // Result: 2
|
|
72
77
|
* ```
|
|
78
|
+
*
|
|
73
79
|
* ---
|
|
74
80
|
*
|
|
75
81
|
* Example with `options.leading`:
|
|
@@ -94,9 +100,13 @@ interface KontrollThrottleOptions extends KontrollBaseOptions {
|
|
|
94
100
|
}
|
|
95
101
|
/**
|
|
96
102
|
* Executes the callback, and bypass any subsequent calls for a period of ms.
|
|
103
|
+
*
|
|
97
104
|
* Calls while the timer haven't finished are dropped.
|
|
105
|
+
*
|
|
98
106
|
* If `options.trailing` and calls while the timer haven't finished are received,
|
|
107
|
+
*
|
|
99
108
|
* an additional execution with last received arguments is performed.
|
|
109
|
+
*
|
|
100
110
|
* ---
|
|
101
111
|
*
|
|
102
112
|
* Example:
|
|
@@ -108,6 +118,7 @@ interface KontrollThrottleOptions extends KontrollBaseOptions {
|
|
|
108
118
|
* // 9999ms passed
|
|
109
119
|
* // (Nothing)
|
|
110
120
|
* ```
|
|
121
|
+
*
|
|
111
122
|
* ---
|
|
112
123
|
*
|
|
113
124
|
* Example with `options.trailing`:
|
|
@@ -127,4 +138,5 @@ interface KontrollThrottleOptions extends KontrollBaseOptions {
|
|
|
127
138
|
*/
|
|
128
139
|
declare function throttle(ms: number, callback: Fn, { key, trailing }?: KontrollThrottleOptions): KontrollClearer;
|
|
129
140
|
|
|
130
|
-
export {
|
|
141
|
+
export { clear, countdown, debounce, throttle };
|
|
142
|
+
export type { KontrollBaseOptions, KontrollClearer, KontrollCountdownOptions, KontrollDebounceOptions, KontrollStore, KontrollThrottleOptions };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kontroll",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"packageManager": "pnpm@
|
|
4
|
+
"version": "1.0.4",
|
|
5
|
+
"packageManager": "pnpm@10.8.0",
|
|
6
6
|
"description": "kontroll (\"control\") is a tiny, dead-simple package for function behavior controls like debounce, countdown, throttle (limit).",
|
|
7
7
|
"author": "NamesMT <dangquoctrung123@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -58,21 +58,25 @@
|
|
|
58
58
|
"prepublishOnly": "pnpm run build"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@antfu/eslint-config": "^
|
|
62
|
-
"@types/node": "^
|
|
63
|
-
"@vitest/coverage-v8": "^
|
|
64
|
-
"eslint": "^9.
|
|
65
|
-
"lint-staged": "^15.
|
|
66
|
-
"simple-git-hooks": "^2.
|
|
67
|
-
"tsx": "^4.
|
|
68
|
-
"typescript": "^5.
|
|
69
|
-
"unbuild": "^
|
|
70
|
-
"vitest": "^
|
|
61
|
+
"@antfu/eslint-config": "^4.12.0",
|
|
62
|
+
"@types/node": "^22.14.0",
|
|
63
|
+
"@vitest/coverage-v8": "^3.1.1",
|
|
64
|
+
"eslint": "^9.24.0",
|
|
65
|
+
"lint-staged": "^15.5.0",
|
|
66
|
+
"simple-git-hooks": "^2.12.1",
|
|
67
|
+
"tsx": "^4.19.3",
|
|
68
|
+
"typescript": "^5.8.3",
|
|
69
|
+
"unbuild": "^3.5.0",
|
|
70
|
+
"vitest": "^3.1.1"
|
|
71
71
|
},
|
|
72
72
|
"pnpm": {
|
|
73
73
|
"overrides": {
|
|
74
|
-
"
|
|
75
|
-
}
|
|
74
|
+
"is-core-module": "npm:@nolyfill/is-core-module@^1"
|
|
75
|
+
},
|
|
76
|
+
"onlyBuiltDependencies": [
|
|
77
|
+
"esbuild",
|
|
78
|
+
"simple-git-hooks"
|
|
79
|
+
]
|
|
76
80
|
},
|
|
77
81
|
"simple-git-hooks": {
|
|
78
82
|
"pre-commit": "pnpm lint-staged"
|