kontroll 1.0.2 → 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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 NamesMT <https://github.com/namesmt>
3
+ Copyright (c) 2024 NamesMT <https://github.com/namesmt>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -58,7 +58,6 @@ If you call something like:
58
58
  // // * Case 1, (arrow) function with unchanged/variable-only body
59
59
  debounce(1000, () => console.log(variable))
60
60
 
61
-
62
61
  // // * Case 2, declared function
63
62
  debounce(1000, makeDoSum(1, 2))
64
63
  // For declared function, it's parameter could be changed and still share the same key.
@@ -77,7 +76,7 @@ In you wish them to have the same timer, you can manually set `options.key` like
77
76
 
78
77
  ## License
79
78
 
80
- [MIT](./LICENSE) License © 2023 [NamesMT](https://github.com/NamesMT)
79
+ [MIT](./LICENSE) License © 2024 [NamesMT](https://github.com/NamesMT)
81
80
 
82
81
  <!-- Badges -->
83
82
 
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 { type KontrollBaseOptions, type KontrollClearer, type KontrollCountdownOptions, type KontrollDebounceOptions, type KontrollStore, type KontrollThrottleOptions, clear, countdown, debounce, throttle };
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 { type KontrollBaseOptions, type KontrollClearer, type KontrollCountdownOptions, type KontrollDebounceOptions, type KontrollStore, type KontrollThrottleOptions, clear, countdown, debounce, throttle };
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.2",
5
- "packageManager": "pnpm@9.6.0",
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": "^2.24.0",
62
- "@types/node": "^20.14.13",
63
- "@vitest/coverage-v8": "^2.0.5",
64
- "eslint": "^9.8.0",
65
- "lint-staged": "^15.2.7",
66
- "simple-git-hooks": "^2.11.1",
67
- "tsx": "^4.16.3",
68
- "typescript": "^5.5.4",
69
- "unbuild": "^2.0.0",
70
- "vitest": "^2.0.5"
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
- "hasown": "npm:@nolyfill/hasown@latest"
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"