sales-frontend-utils 0.0.0 → 0.0.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.
package/dist/index.cjs CHANGED
@@ -3,6 +3,42 @@
3
3
  // src/sample/index.ts
4
4
  var hello = () => console.log("hello");
5
5
 
6
+ // src/timing/index.ts
7
+ function throttle(func, delay) {
8
+ let lastCall = 0;
9
+ let timeout = null;
10
+ return (...args) => {
11
+ const now = Date.now();
12
+ if (now - lastCall >= delay) {
13
+ lastCall = now;
14
+ func(...args);
15
+ } else if (!timeout) {
16
+ timeout = setTimeout(
17
+ () => {
18
+ lastCall = Date.now();
19
+ func(...args);
20
+ timeout = null;
21
+ },
22
+ delay - (now - lastCall)
23
+ );
24
+ }
25
+ };
26
+ }
27
+ function debounce(func, delay) {
28
+ let timeout = null;
29
+ return (...args) => {
30
+ if (timeout) {
31
+ clearTimeout(timeout);
32
+ }
33
+ timeout = setTimeout(() => {
34
+ func(...args);
35
+ timeout = null;
36
+ }, delay);
37
+ };
38
+ }
39
+
40
+ exports.debounce = debounce;
6
41
  exports.hello = hello;
42
+ exports.throttle = throttle;
7
43
  //# sourceMappingURL=index.cjs.map
8
44
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sample/index.ts"],"names":[],"mappings":";;;AAAO,IAAM,KAAQ,GAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,OAAO","file":"index.cjs","sourcesContent":["export const hello = () => console.log('hello');\n"]}
1
+ {"version":3,"sources":["../src/sample/index.ts","../src/timing/index.ts"],"names":[],"mappings":";;;AAAO,IAAM,KAAQ,GAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,OAAO;;;ACAvC,SAAS,QAAA,CAA6C,MAAS,KAAiD,EAAA;AACrH,EAAA,IAAI,QAAW,GAAA,CAAA;AACf,EAAA,IAAI,OAAiC,GAAA,IAAA;AAErC,EAAA,OAAO,IAAI,IAAwB,KAAA;AACjC,IAAM,MAAA,GAAA,GAAM,KAAK,GAAI,EAAA;AAErB,IAAI,IAAA,GAAA,GAAM,YAAY,KAAO,EAAA;AAE3B,MAAW,QAAA,GAAA,GAAA;AACX,MAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,KACd,MAAA,IAAW,CAAC,OAAS,EAAA;AAEnB,MAAU,OAAA,GAAA,UAAA;AAAA,QACR,MAAM;AACJ,UAAA,QAAA,GAAW,KAAK,GAAI,EAAA;AACpB,UAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AACZ,UAAU,OAAA,GAAA,IAAA;AAAA,SACZ;AAAA,QACA,SAAS,GAAM,GAAA,QAAA;AAAA,OACjB;AAAA;AACF,GACF;AACF;AAEO,SAAS,QAAA,CAA6C,MAAS,KAAiD,EAAA;AACrH,EAAA,IAAI,OAAiC,GAAA,IAAA;AAErC,EAAA,OAAO,IAAI,IAAwB,KAAA;AACjC,IAAA,IAAI,OAAS,EAAA;AACX,MAAA,YAAA,CAAa,OAAO,CAAA;AAAA;AAEtB,IAAA,OAAA,GAAU,WAAW,MAAM;AACzB,MAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AACZ,MAAU,OAAA,GAAA,IAAA;AAAA,OACT,KAAK,CAAA;AAAA,GACV;AACF","file":"index.cjs","sourcesContent":["export const hello = () => console.log('hello');\n","export function throttle<T extends (...args: any[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void {\n let lastCall = 0;\n let timeout: NodeJS.Timeout | null = null;\n\n return (...args: Parameters<T>) => {\n const now = Date.now();\n\n if (now - lastCall >= delay) {\n // 마지막 호출로부터 delay 시간이 지났으면 즉시 실행\n lastCall = now;\n func(...args);\n } else if (!timeout) {\n // 대기 중인 타이머가 없으면 새로운 타이머 설정\n timeout = setTimeout(\n () => {\n lastCall = Date.now();\n func(...args);\n timeout = null;\n },\n delay - (now - lastCall)\n );\n }\n };\n}\n\nexport function debounce<T extends (...args: any[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void {\n let timeout: NodeJS.Timeout | null = null;\n\n return (...args: Parameters<T>) => {\n if (timeout) {\n clearTimeout(timeout);\n }\n timeout = setTimeout(() => {\n func(...args);\n timeout = null;\n }, delay);\n };\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,3 +1,6 @@
1
1
  declare const hello: () => void;
2
2
 
3
- export { hello };
3
+ declare function throttle<T extends (...args: any[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void;
4
+ declare function debounce<T extends (...args: any[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void;
5
+
6
+ export { debounce, hello, throttle };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  declare const hello: () => void;
2
2
 
3
- export { hello };
3
+ declare function throttle<T extends (...args: any[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void;
4
+ declare function debounce<T extends (...args: any[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void;
5
+
6
+ export { debounce, hello, throttle };
package/dist/index.js CHANGED
@@ -1,6 +1,40 @@
1
1
  // src/sample/index.ts
2
2
  var hello = () => console.log("hello");
3
3
 
4
- export { hello };
4
+ // src/timing/index.ts
5
+ function throttle(func, delay) {
6
+ let lastCall = 0;
7
+ let timeout = null;
8
+ return (...args) => {
9
+ const now = Date.now();
10
+ if (now - lastCall >= delay) {
11
+ lastCall = now;
12
+ func(...args);
13
+ } else if (!timeout) {
14
+ timeout = setTimeout(
15
+ () => {
16
+ lastCall = Date.now();
17
+ func(...args);
18
+ timeout = null;
19
+ },
20
+ delay - (now - lastCall)
21
+ );
22
+ }
23
+ };
24
+ }
25
+ function debounce(func, delay) {
26
+ let timeout = null;
27
+ return (...args) => {
28
+ if (timeout) {
29
+ clearTimeout(timeout);
30
+ }
31
+ timeout = setTimeout(() => {
32
+ func(...args);
33
+ timeout = null;
34
+ }, delay);
35
+ };
36
+ }
37
+
38
+ export { debounce, hello, throttle };
5
39
  //# sourceMappingURL=index.js.map
6
40
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/sample/index.ts"],"names":[],"mappings":";AAAO,IAAM,KAAQ,GAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,OAAO","file":"index.js","sourcesContent":["export const hello = () => console.log('hello');\n"]}
1
+ {"version":3,"sources":["../src/sample/index.ts","../src/timing/index.ts"],"names":[],"mappings":";AAAO,IAAM,KAAQ,GAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,OAAO;;;ACAvC,SAAS,QAAA,CAA6C,MAAS,KAAiD,EAAA;AACrH,EAAA,IAAI,QAAW,GAAA,CAAA;AACf,EAAA,IAAI,OAAiC,GAAA,IAAA;AAErC,EAAA,OAAO,IAAI,IAAwB,KAAA;AACjC,IAAM,MAAA,GAAA,GAAM,KAAK,GAAI,EAAA;AAErB,IAAI,IAAA,GAAA,GAAM,YAAY,KAAO,EAAA;AAE3B,MAAW,QAAA,GAAA,GAAA;AACX,MAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,KACd,MAAA,IAAW,CAAC,OAAS,EAAA;AAEnB,MAAU,OAAA,GAAA,UAAA;AAAA,QACR,MAAM;AACJ,UAAA,QAAA,GAAW,KAAK,GAAI,EAAA;AACpB,UAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AACZ,UAAU,OAAA,GAAA,IAAA;AAAA,SACZ;AAAA,QACA,SAAS,GAAM,GAAA,QAAA;AAAA,OACjB;AAAA;AACF,GACF;AACF;AAEO,SAAS,QAAA,CAA6C,MAAS,KAAiD,EAAA;AACrH,EAAA,IAAI,OAAiC,GAAA,IAAA;AAErC,EAAA,OAAO,IAAI,IAAwB,KAAA;AACjC,IAAA,IAAI,OAAS,EAAA;AACX,MAAA,YAAA,CAAa,OAAO,CAAA;AAAA;AAEtB,IAAA,OAAA,GAAU,WAAW,MAAM;AACzB,MAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AACZ,MAAU,OAAA,GAAA,IAAA;AAAA,OACT,KAAK,CAAA;AAAA,GACV;AACF","file":"index.js","sourcesContent":["export const hello = () => console.log('hello');\n","export function throttle<T extends (...args: any[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void {\n let lastCall = 0;\n let timeout: NodeJS.Timeout | null = null;\n\n return (...args: Parameters<T>) => {\n const now = Date.now();\n\n if (now - lastCall >= delay) {\n // 마지막 호출로부터 delay 시간이 지났으면 즉시 실행\n lastCall = now;\n func(...args);\n } else if (!timeout) {\n // 대기 중인 타이머가 없으면 새로운 타이머 설정\n timeout = setTimeout(\n () => {\n lastCall = Date.now();\n func(...args);\n timeout = null;\n },\n delay - (now - lastCall)\n );\n }\n };\n}\n\nexport function debounce<T extends (...args: any[]) => void>(func: T, delay: number): (...args: Parameters<T>) => void {\n let timeout: NodeJS.Timeout | null = null;\n\n return (...args: Parameters<T>) => {\n if (timeout) {\n clearTimeout(timeout);\n }\n timeout = setTimeout(() => {\n func(...args);\n timeout = null;\n }, delay);\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sales-frontend-utils",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "@types/node": "^22.14.0",
25
25
  "tsup": "^8.4.0",
26
26
  "typescript": "5.8.2",
27
- "sales-frontend-eslint-config-v8": "^0.0.0",
28
- "sales-frontend-typescript-config": "0.0.0"
27
+ "sales-frontend-typescript-config": "0.0.1",
28
+ "eslint-config-sales-frontend-eslint-config-v8": "^0.0.4"
29
29
  },
30
30
  "scripts": {
31
31
  "lint": "eslint . --max-warnings 0",