umaki 0.2.6 → 0.3.1

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.
Files changed (107) hide show
  1. package/README.md +41 -1
  2. package/dist/_virtual/_commonjsHelpers.cjs.js +1 -1
  3. package/dist/_virtual/_commonjsHelpers.es.js +1 -1
  4. package/dist/_virtual/isBetween.cjs.js +1 -1
  5. package/dist/_virtual/isBetween.es.js +1 -1
  6. package/dist/index.cjs.js +5 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.es.js +5 -1
  9. package/dist/libs/control/bgScrollStop.cjs.js +1 -1
  10. package/dist/libs/control/bgScrollStop.es.js +1 -1
  11. package/dist/libs/control/pd.cjs.js +1 -1
  12. package/dist/libs/control/pd.es.js +1 -1
  13. package/dist/libs/control/scrollToHash.cjs.js +1 -1
  14. package/dist/libs/control/scrollToHash.es.js +1 -1
  15. package/dist/libs/control/videoPlayControl.cjs.js +3 -3
  16. package/dist/libs/control/videoPlayControl.d.ts +1 -1
  17. package/dist/libs/control/videoPlayControl.es.js +3 -3
  18. package/dist/libs/convert/changeDateStringToSpecificFormat.cjs.js +1 -1
  19. package/dist/libs/convert/changeDateStringToSpecificFormat.es.js +1 -1
  20. package/dist/libs/convert/jsonStringToJsonObject.cjs.js +1 -1
  21. package/dist/libs/convert/jsonStringToJsonObject.es.js +1 -1
  22. package/dist/libs/eventControl/debounce.cjs.js +24 -0
  23. package/dist/libs/eventControl/debounce.d.ts +11 -0
  24. package/dist/libs/eventControl/debounce.es.js +24 -0
  25. package/dist/libs/eventControl/debounce.test.d.ts +1 -0
  26. package/dist/libs/eventControl/index.d.ts +5 -0
  27. package/dist/libs/eventControl/throttle.cjs.js +24 -0
  28. package/dist/libs/eventControl/throttle.d.ts +12 -0
  29. package/dist/libs/eventControl/throttle.es.js +24 -0
  30. package/dist/libs/eventControl/throttle.test.d.ts +1 -0
  31. package/dist/libs/get/getAspectRatio.cjs.js +1 -1
  32. package/dist/libs/get/getAspectRatio.es.js +1 -1
  33. package/dist/libs/get/getClassNames.cjs.js +1 -1
  34. package/dist/libs/get/getClassNames.es.js +1 -1
  35. package/dist/libs/get/getDocumentHeight.cjs.js +1 -1
  36. package/dist/libs/get/getDocumentHeight.es.js +1 -1
  37. package/dist/libs/get/getEventPaths.cjs.js +1 -1
  38. package/dist/libs/get/getEventPaths.es.js +1 -1
  39. package/dist/libs/get/getGcd.cjs.js +1 -1
  40. package/dist/libs/get/getGcd.es.js +1 -1
  41. package/dist/libs/get/getOrientation.cjs.js +1 -1
  42. package/dist/libs/get/getOrientation.es.js +1 -1
  43. package/dist/libs/get/getParentList.cjs.js +1 -1
  44. package/dist/libs/get/getParentList.es.js +1 -1
  45. package/dist/libs/get/getQueryParams.cjs.js +1 -1
  46. package/dist/libs/get/getQueryParams.es.js +1 -1
  47. package/dist/libs/get/getRem.cjs.js +1 -1
  48. package/dist/libs/get/getRem.es.js +1 -1
  49. package/dist/libs/get/getScrollbarWidth.cjs.js +1 -1
  50. package/dist/libs/get/getScrollbarWidth.es.js +1 -1
  51. package/dist/libs/get/getSessionStorage.cjs.js +1 -1
  52. package/dist/libs/get/getSessionStorage.es.js +1 -1
  53. package/dist/libs/get/getStringLength.cjs.js +1 -1
  54. package/dist/libs/get/getStringLength.es.js +1 -1
  55. package/dist/libs/get/getStylePropertyValue.cjs.js +1 -1
  56. package/dist/libs/get/getStylePropertyValue.es.js +1 -1
  57. package/dist/libs/get/getStylePropertyValueToNumber.cjs.js +1 -1
  58. package/dist/libs/get/getStylePropertyValueToNumber.es.js +1 -1
  59. package/dist/libs/get/getUaData.cjs.js +1 -1
  60. package/dist/libs/get/getUaData.es.js +1 -1
  61. package/dist/libs/is/isBetweenDateTime.cjs.js +1 -1
  62. package/dist/libs/is/isBetweenDateTime.es.js +1 -1
  63. package/dist/libs/is/isExistAllElements.cjs.js +1 -1
  64. package/dist/libs/is/isExistAllElements.es.js +1 -1
  65. package/dist/libs/is/isIpad.cjs.js +1 -1
  66. package/dist/libs/is/isIpad.es.js +1 -1
  67. package/dist/libs/is/isKeyExists.cjs.js +1 -1
  68. package/dist/libs/is/isKeyExists.es.js +1 -1
  69. package/dist/libs/is/isSafari.cjs.js +1 -1
  70. package/dist/libs/is/isSafari.es.js +1 -1
  71. package/dist/libs/is/isScrollable.cjs.js +1 -1
  72. package/dist/libs/is/isScrollable.es.js +1 -1
  73. package/dist/libs/is/isTouchSupport.cjs.js +1 -1
  74. package/dist/libs/is/isTouchSupport.es.js +1 -1
  75. package/dist/libs/remove/removeAllHtmlTags.cjs.js +1 -1
  76. package/dist/libs/remove/removeAllHtmlTags.es.js +1 -1
  77. package/dist/libs/remove/removeAttribute.cjs.js +1 -1
  78. package/dist/libs/remove/removeAttribute.es.js +1 -1
  79. package/dist/libs/remove/removeSessionStorage.cjs.js +1 -1
  80. package/dist/libs/remove/removeSessionStorage.es.js +1 -1
  81. package/dist/libs/remove/removeStylePropertyValue.cjs.js +1 -1
  82. package/dist/libs/remove/removeStylePropertyValue.es.js +1 -1
  83. package/dist/libs/set/set100vh.cjs.js +1 -1
  84. package/dist/libs/set/set100vh.es.js +1 -1
  85. package/dist/libs/set/set100vw.cjs.js +1 -1
  86. package/dist/libs/set/set100vw.es.js +1 -1
  87. package/dist/libs/set/setAttribute.cjs.js +1 -1
  88. package/dist/libs/set/setAttribute.es.js +1 -1
  89. package/dist/libs/set/setScrollPositionToCenter.cjs.js +1 -1
  90. package/dist/libs/set/setScrollPositionToCenter.es.js +1 -1
  91. package/dist/libs/set/setSessionStorage.cjs.js +1 -1
  92. package/dist/libs/set/setSessionStorage.es.js +1 -1
  93. package/dist/libs/set/setStylePropertyValue.cjs.js +1 -1
  94. package/dist/libs/set/setStylePropertyValue.es.js +1 -1
  95. package/dist/libs/to/toBoolean.cjs.js +1 -1
  96. package/dist/libs/to/toBoolean.es.js +1 -1
  97. package/dist/libs/to/toPositiveNumber.cjs.js +1 -1
  98. package/dist/libs/to/toPositiveNumber.es.js +1 -1
  99. package/dist/libs/transform/wrapTextWithSpans.cjs.js +1 -1
  100. package/dist/libs/transform/wrapTextWithSpans.es.js +1 -1
  101. package/dist/libs/wait/sleep.cjs.js +1 -1
  102. package/dist/libs/wait/sleep.es.js +1 -1
  103. package/dist/libs/wait/waitForAllMediaLoaded.cjs.js +1 -1
  104. package/dist/libs/wait/waitForAllMediaLoaded.es.js +1 -1
  105. package/dist/node_modules/dayjs/plugin/isBetween.cjs.js +1 -1
  106. package/dist/node_modules/dayjs/plugin/isBetween.es.js +1 -1
  107. package/package.json +1 -1
package/README.md CHANGED
@@ -26,6 +26,9 @@ import { foo } from 'umaki'
26
26
  - [Convert](#convert)
27
27
  - [changeDateStringToSpecificFormat](#changedatestringtospecificformat)
28
28
  - [jsonStringToJsonObject](#jsonstringtojsonobject)
29
+ - [EventControl](#eventcontrol)
30
+ - [debounce](#debounce)
31
+ - [throttle](#throttle)
29
32
  - [Get](#get)
30
33
  - [getAspectRatio](#getaspectratio)
31
34
  - [getClassNames](#getclassnames)
@@ -129,6 +132,9 @@ import { videoPlayControl } from 'umaki'
129
132
  const videoElement = document.getElementById('myVideo')
130
133
  videoPlayControl(videoElement, true) // play
131
134
  videoPlayControl(videoElement, false) // pause
135
+
136
+ // set currentTime
137
+ videoPlayControl(videoElement, true, 10) // play and set currentTime to 10
132
138
  ```
133
139
 
134
140
  [View file →](src/libs/control/videoPlayControl.ts)
@@ -163,6 +169,40 @@ console.log(jsonObject) // { name: 'John', age: 30 }
163
169
 
164
170
  [View file →](src/libs/convert/jsonStringToJsonObject.ts)
165
171
 
172
+ ## EventControl
173
+
174
+ ### debounce
175
+
176
+ A function that limits the number of times a function is called to at most one time over a specified time period.
177
+
178
+ ```ts
179
+ import { debounce } from 'umaki'
180
+
181
+ const debouncedFunction = debounce(() => {
182
+ console.log('Debounced!')
183
+ }, 300)
184
+
185
+ window.addEventListener('resize', debouncedFunction)
186
+ ```
187
+
188
+ [View file →](src/libs/eventControl/debounce.ts)
189
+
190
+ ### throttle
191
+
192
+ A function that limits the number of times a function is called to a maximum of once in a specified period.
193
+
194
+ ```ts
195
+ import { throttle } from 'umaki'
196
+
197
+ const throttledFunction = throttle(() => {
198
+ console.log('Throttled!')
199
+ }, 300)
200
+
201
+ window.addEventListener('scroll', throttledFunction)
202
+ ```
203
+
204
+ [View file →](src/libs/eventControl/throttle.ts)
205
+
166
206
  ## Get
167
207
 
168
208
  ### getAspectRatio
@@ -681,7 +721,7 @@ import { sleep } from 'umaki'
681
721
 
682
722
  ;(async () => {
683
723
  console.log('Start')
684
- await sleep(1) // 1ms wait
724
+ await sleep(1) // 1s wait
685
725
  console.log('End')
686
726
  })()
687
727
  ```
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
package/dist/index.cjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -17,6 +17,8 @@ const scrollToHash = require("./libs/control/scrollToHash.cjs.js");
17
17
  const videoPlayControl = require("./libs/control/videoPlayControl.cjs.js");
18
18
  const changeDateStringToSpecificFormat = require("./libs/convert/changeDateStringToSpecificFormat.cjs.js");
19
19
  const jsonStringToJsonObject = require("./libs/convert/jsonStringToJsonObject.cjs.js");
20
+ const debounce = require("./libs/eventControl/debounce.cjs.js");
21
+ const throttle = require("./libs/eventControl/throttle.cjs.js");
20
22
  const getAspectRatio = require("./libs/get/getAspectRatio.cjs.js");
21
23
  const getClassNames = require("./libs/get/getClassNames.cjs.js");
22
24
  const getDocumentHeight = require("./libs/get/getDocumentHeight.cjs.js");
@@ -60,6 +62,8 @@ exports.scrollToHash = scrollToHash.scrollToHash;
60
62
  exports.videoPlayControl = videoPlayControl.videoPlayControl;
61
63
  exports.changeDateStringToSpecificFormat = changeDateStringToSpecificFormat.changeDateStringToSpecificFormat;
62
64
  exports.jsonStringToJsonObject = jsonStringToJsonObject.jsonStringToJsonObject;
65
+ exports.debounce = debounce.debounce;
66
+ exports.throttle = throttle.throttle;
63
67
  exports.getAspectRatio = getAspectRatio.getAspectRatio;
64
68
  exports.getClassNames = getClassNames.getClassNames;
65
69
  exports.getDocumentHeight = getDocumentHeight.getDocumentHeight;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './libs/control';
2
2
  export * from './libs/convert';
3
+ export * from './libs/eventControl';
3
4
  export * from './libs/get';
4
5
  export * from './libs/is';
5
6
  export * from './libs/remove';
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -15,6 +15,8 @@ import { scrollToHash } from "./libs/control/scrollToHash.es.js";
15
15
  import { videoPlayControl } from "./libs/control/videoPlayControl.es.js";
16
16
  import { changeDateStringToSpecificFormat } from "./libs/convert/changeDateStringToSpecificFormat.es.js";
17
17
  import { jsonStringToJsonObject } from "./libs/convert/jsonStringToJsonObject.es.js";
18
+ import { debounce } from "./libs/eventControl/debounce.es.js";
19
+ import { throttle } from "./libs/eventControl/throttle.es.js";
18
20
  import { getAspectRatio } from "./libs/get/getAspectRatio.es.js";
19
21
  import { getClassNames } from "./libs/get/getClassNames.es.js";
20
22
  import { getDocumentHeight } from "./libs/get/getDocumentHeight.es.js";
@@ -55,6 +57,7 @@ import { waitForAllMediaLoaded } from "./libs/wait/waitForAllMediaLoaded.es.js";
55
57
  export {
56
58
  bgScrollStop,
57
59
  changeDateStringToSpecificFormat,
60
+ debounce,
58
61
  getAspectRatio,
59
62
  getClassNames,
60
63
  getDocumentHeight,
@@ -91,6 +94,7 @@ export {
91
94
  setSessionStorage,
92
95
  setStylePropertyValue,
93
96
  sleep,
97
+ throttle,
94
98
  toBoolean,
95
99
  toPositiveNumber,
96
100
  videoPlayControl,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -12,7 +12,7 @@
12
12
  */
13
13
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
14
14
  const toBoolean = require("../to/toBoolean.cjs.js");
15
- const videoPlayControl = async (videoElement, state) => {
15
+ const videoPlayControl = async (videoElement, state, currentTime) => {
16
16
  if (state && videoElement.paused) {
17
17
  const isPlaying = toBoolean.toBoolean(videoElement.dataset.playing);
18
18
  if (isPlaying) return;
@@ -20,7 +20,7 @@ const videoPlayControl = async (videoElement, state) => {
20
20
  if (playPromise === void 0) return;
21
21
  try {
22
22
  await playPromise;
23
- videoElement.currentTime = 0;
23
+ videoElement.currentTime = currentTime || 0;
24
24
  videoElement.dataset.playing = "true";
25
25
  } catch (error) {
26
26
  }
@@ -11,4 +11,4 @@
11
11
  * the video. The function also manages a custom `data-playing` attribute on the video element
12
12
  * to track the playback state.
13
13
  */
14
- export declare const videoPlayControl: (videoElement: HTMLVideoElement, state: boolean) => Promise<void>;
14
+ export declare const videoPlayControl: (videoElement: HTMLVideoElement, state: boolean, currentTime?: number) => Promise<void>;
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -10,7 +10,7 @@
10
10
  * For license information, please see LICENSE.txt
11
11
  */
12
12
  import { toBoolean } from "../to/toBoolean.es.js";
13
- const videoPlayControl = async (videoElement, state) => {
13
+ const videoPlayControl = async (videoElement, state, currentTime) => {
14
14
  if (state && videoElement.paused) {
15
15
  const isPlaying = toBoolean(videoElement.dataset.playing);
16
16
  if (isPlaying) return;
@@ -18,7 +18,7 @@ const videoPlayControl = async (videoElement, state) => {
18
18
  if (playPromise === void 0) return;
19
19
  try {
20
20
  await playPromise;
21
- videoElement.currentTime = 0;
21
+ videoElement.currentTime = currentTime || 0;
22
22
  videoElement.dataset.playing = "true";
23
23
  } catch (error) {
24
24
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /*!
3
+ * name: umaki
4
+ * version: v0.3.1
5
+ * description: A utility that is often used in web production.
6
+ * author: TsubasaHiga
7
+ * homepage: https://github.com/TsubasaHiga/umaki
8
+ * Released under the MIT License
9
+ *
10
+ * This software includes dependencies licensed under MIT, ISC, BSD-3-Clause, and Apache-2.0.
11
+ * For license information, please see LICENSE.txt
12
+ */
13
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
14
+ const debounce = (fn, delay) => {
15
+ let timeoutId = null;
16
+ return (...args) => {
17
+ timeoutId && clearTimeout(timeoutId);
18
+ timeoutId = setTimeout(() => {
19
+ fn(...args);
20
+ timeoutId = null;
21
+ }, delay);
22
+ };
23
+ };
24
+ exports.debounce = debounce;
@@ -0,0 +1,11 @@
1
+ type DebounceProcedure = (...args: unknown[]) => void;
2
+ /**
3
+ * Creates a debounced function that delays invoking the provided function until after the specified delay.
4
+ *
5
+ * @template F - The type of the function to debounce.
6
+ * @param {F} fn - The function to debounce.
7
+ * @param {number} delay - The number of milliseconds to delay.
8
+ * @returns {(...args: Parameters<F>) => void} - A debounced version of the provided function.
9
+ */
10
+ export declare const debounce: <F extends DebounceProcedure>(fn: F, delay: number) => ((...args: Parameters<F>) => void);
11
+ export {};
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * name: umaki
3
+ * version: v0.3.1
4
+ * description: A utility that is often used in web production.
5
+ * author: TsubasaHiga
6
+ * homepage: https://github.com/TsubasaHiga/umaki
7
+ * Released under the MIT License
8
+ *
9
+ * This software includes dependencies licensed under MIT, ISC, BSD-3-Clause, and Apache-2.0.
10
+ * For license information, please see LICENSE.txt
11
+ */
12
+ const debounce = (fn, delay) => {
13
+ let timeoutId = null;
14
+ return (...args) => {
15
+ timeoutId && clearTimeout(timeoutId);
16
+ timeoutId = setTimeout(() => {
17
+ fn(...args);
18
+ timeoutId = null;
19
+ }, delay);
20
+ };
21
+ };
22
+ export {
23
+ debounce
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * eventControl functions
3
+ */
4
+ export { debounce } from './debounce';
5
+ export { throttle } from './throttle';
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /*!
3
+ * name: umaki
4
+ * version: v0.3.1
5
+ * description: A utility that is often used in web production.
6
+ * author: TsubasaHiga
7
+ * homepage: https://github.com/TsubasaHiga/umaki
8
+ * Released under the MIT License
9
+ *
10
+ * This software includes dependencies licensed under MIT, ISC, BSD-3-Clause, and Apache-2.0.
11
+ * For license information, please see LICENSE.txt
12
+ */
13
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
14
+ const throttle = (fn, wait) => {
15
+ let lastCallTime = 0;
16
+ return (...args) => {
17
+ const currentTime = Date.now();
18
+ if (currentTime - lastCallTime >= wait) {
19
+ fn(...args);
20
+ lastCallTime = currentTime;
21
+ }
22
+ };
23
+ };
24
+ exports.throttle = throttle;
@@ -0,0 +1,12 @@
1
+ type ThrottleFunction = (...args: unknown[]) => void;
2
+ /**
3
+ * Creates a throttled version of the provided function that will only execute
4
+ * at most once in the specified wait period.
5
+ *
6
+ * @template F - The type of the function to be throttled.
7
+ * @param fn - The function to throttle.
8
+ * @param wait - The number of milliseconds to wait before allowing the next execution.
9
+ * @returns A throttled version of the provided function.
10
+ */
11
+ export declare const throttle: <F extends ThrottleFunction>(fn: F, wait: number) => ((...args: Parameters<F>) => void);
12
+ export {};
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * name: umaki
3
+ * version: v0.3.1
4
+ * description: A utility that is often used in web production.
5
+ * author: TsubasaHiga
6
+ * homepage: https://github.com/TsubasaHiga/umaki
7
+ * Released under the MIT License
8
+ *
9
+ * This software includes dependencies licensed under MIT, ISC, BSD-3-Clause, and Apache-2.0.
10
+ * For license information, please see LICENSE.txt
11
+ */
12
+ const throttle = (fn, wait) => {
13
+ let lastCallTime = 0;
14
+ return (...args) => {
15
+ const currentTime = Date.now();
16
+ if (currentTime - lastCallTime >= wait) {
17
+ fn(...args);
18
+ lastCallTime = currentTime;
19
+ }
20
+ };
21
+ };
22
+ export {
23
+ throttle
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /*!
3
3
  * name: umaki
4
- * version: v0.2.6
4
+ * version: v0.3.1
5
5
  * description: A utility that is often used in web production.
6
6
  * author: TsubasaHiga
7
7
  * homepage: https://github.com/TsubasaHiga/umaki
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * name: umaki
3
- * version: v0.2.6
3
+ * version: v0.3.1
4
4
  * description: A utility that is often used in web production.
5
5
  * author: TsubasaHiga
6
6
  * homepage: https://github.com/TsubasaHiga/umaki