@hybridly/utils 0.7.8 → 0.7.10

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
@@ -2,6 +2,7 @@
2
2
 
3
3
  const baseMerge = require('deepmerge');
4
4
  const isPlainObject = require('is-plain-object');
5
+ const throttleDebounce = require('throttle-debounce');
5
6
  const lodash_clonedeep = require('lodash.clonedeep');
6
7
  const makeDebugger = require('debug');
7
8
 
@@ -307,13 +308,6 @@ function match(value2, lookup, ...args) {
307
308
  const error = new Error(`Tried to handle "${value2}" but there is no handler defined. Only defined handlers are: ${handlers}.`);
308
309
  throw error;
309
310
  }
310
- function debounce(fn, delay) {
311
- let timeoutID;
312
- return function(...args) {
313
- clearTimeout(timeoutID);
314
- timeoutID = setTimeout(() => fn(args), delay);
315
- };
316
- }
317
311
  function value(value2) {
318
312
  if (typeof value2 === "function") {
319
313
  return value2?.();
@@ -379,8 +373,9 @@ const debug = {
379
373
  adapter: (name, ...args) => makeDebugger__default("hybridly:adapter").extend(name)(args.shift(), ...args)
380
374
  };
381
375
 
376
+ exports.debounce = throttleDebounce.debounce;
377
+ exports.throttle = throttleDebounce.throttle;
382
378
  exports.clone = lodash_clonedeep__default;
383
- exports.debounce = debounce;
384
379
  exports.debug = debug;
385
380
  exports.hasFiles = hasFiles;
386
381
  exports.match = match;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import makeDebugger from 'debug';
2
+ export { debounce, throttle } from 'throttle-debounce';
2
3
  export { default as clone } from 'lodash.clonedeep';
3
4
 
4
5
  type RequestData = Record<string, FormDataConvertible> | FormDataConvertible | FormData;
@@ -36,7 +37,6 @@ declare function showViewComponentErrorModal(response: string): Modal;
36
37
  declare function random(length?: number): string;
37
38
  /** Simple pattern matching util. */
38
39
  declare function match<TValue extends string | number = string, TReturnValue = unknown>(value: TValue, lookup: Record<TValue | 'default', TReturnValue | ((...args: any[]) => TReturnValue)>, ...args: any[]): TReturnValue | Promise<TReturnValue>;
39
- declare function debounce<F extends (...params: any[]) => ReturnType<F>>(fn: F, delay: number): F;
40
40
  declare function value<T>(value: T | (() => T)): T;
41
41
  declare function when<T, D>(condition: any, data: T, _default?: D): T | D | undefined;
42
42
  interface MergeOptions {
@@ -80,4 +80,4 @@ declare const debug: {
80
80
  adapter: (name: string, ...args: any[]) => void;
81
81
  };
82
82
 
83
- export { type FormDataConvertible, type RequestData, debounce, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showResponseErrorModal, showViewComponentErrorModal, unsetPropertyAtPath, value, when };
83
+ export { type FormDataConvertible, type RequestData, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showResponseErrorModal, showViewComponentErrorModal, unsetPropertyAtPath, value, when };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import makeDebugger from 'debug';
2
+ export { debounce, throttle } from 'throttle-debounce';
2
3
  export { default as clone } from 'lodash.clonedeep';
3
4
 
4
5
  type RequestData = Record<string, FormDataConvertible> | FormDataConvertible | FormData;
@@ -36,7 +37,6 @@ declare function showViewComponentErrorModal(response: string): Modal;
36
37
  declare function random(length?: number): string;
37
38
  /** Simple pattern matching util. */
38
39
  declare function match<TValue extends string | number = string, TReturnValue = unknown>(value: TValue, lookup: Record<TValue | 'default', TReturnValue | ((...args: any[]) => TReturnValue)>, ...args: any[]): TReturnValue | Promise<TReturnValue>;
39
- declare function debounce<F extends (...params: any[]) => ReturnType<F>>(fn: F, delay: number): F;
40
40
  declare function value<T>(value: T | (() => T)): T;
41
41
  declare function when<T, D>(condition: any, data: T, _default?: D): T | D | undefined;
42
42
  interface MergeOptions {
@@ -80,4 +80,4 @@ declare const debug: {
80
80
  adapter: (name: string, ...args: any[]) => void;
81
81
  };
82
82
 
83
- export { type FormDataConvertible, type RequestData, debounce, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showResponseErrorModal, showViewComponentErrorModal, unsetPropertyAtPath, value, when };
83
+ export { type FormDataConvertible, type RequestData, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showResponseErrorModal, showViewComponentErrorModal, unsetPropertyAtPath, value, when };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import makeDebugger from 'debug';
2
+ export { debounce, throttle } from 'throttle-debounce';
2
3
  export { default as clone } from 'lodash.clonedeep';
3
4
 
4
5
  type RequestData = Record<string, FormDataConvertible> | FormDataConvertible | FormData;
@@ -36,7 +37,6 @@ declare function showViewComponentErrorModal(response: string): Modal;
36
37
  declare function random(length?: number): string;
37
38
  /** Simple pattern matching util. */
38
39
  declare function match<TValue extends string | number = string, TReturnValue = unknown>(value: TValue, lookup: Record<TValue | 'default', TReturnValue | ((...args: any[]) => TReturnValue)>, ...args: any[]): TReturnValue | Promise<TReturnValue>;
39
- declare function debounce<F extends (...params: any[]) => ReturnType<F>>(fn: F, delay: number): F;
40
40
  declare function value<T>(value: T | (() => T)): T;
41
41
  declare function when<T, D>(condition: any, data: T, _default?: D): T | D | undefined;
42
42
  interface MergeOptions {
@@ -80,4 +80,4 @@ declare const debug: {
80
80
  adapter: (name: string, ...args: any[]) => void;
81
81
  };
82
82
 
83
- export { type FormDataConvertible, type RequestData, debounce, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showResponseErrorModal, showViewComponentErrorModal, unsetPropertyAtPath, value, when };
83
+ export { type FormDataConvertible, type RequestData, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showResponseErrorModal, showViewComponentErrorModal, unsetPropertyAtPath, value, when };
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import baseMerge from 'deepmerge';
2
2
  import { isPlainObject } from 'is-plain-object';
3
+ export { debounce, throttle } from 'throttle-debounce';
3
4
  export { default as clone } from 'lodash.clonedeep';
4
5
  import makeDebugger from 'debug';
5
6
 
@@ -299,13 +300,6 @@ function match(value2, lookup, ...args) {
299
300
  const error = new Error(`Tried to handle "${value2}" but there is no handler defined. Only defined handlers are: ${handlers}.`);
300
301
  throw error;
301
302
  }
302
- function debounce(fn, delay) {
303
- let timeoutID;
304
- return function(...args) {
305
- clearTimeout(timeoutID);
306
- timeoutID = setTimeout(() => fn(args), delay);
307
- };
308
- }
309
303
  function value(value2) {
310
304
  if (typeof value2 === "function") {
311
305
  return value2?.();
@@ -371,4 +365,4 @@ const debug = {
371
365
  adapter: (name, ...args) => makeDebugger("hybridly:adapter").extend(name)(args.shift(), ...args)
372
366
  };
373
367
 
374
- export { debounce, debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showResponseErrorModal, showViewComponentErrorModal, unsetPropertyAtPath, value, when };
368
+ export { debug, hasFiles, match, merge, objectToFormData, random, removeTrailingSlash, setValueAtPath, showResponseErrorModal, showViewComponentErrorModal, unsetPropertyAtPath, value, when };
package/package.json CHANGED
@@ -1,47 +1,48 @@
1
1
  {
2
2
  "name": "@hybridly/utils",
3
- "version": "0.7.8",
3
+ "type": "module",
4
+ "version": "0.7.10",
4
5
  "description": "Utils used in Hybridly packages",
5
- "keywords": [
6
- "hybridly"
7
- ],
6
+ "author": "Enzo Innocenzi <enzo@innocenzi.dev>",
8
7
  "license": "MIT",
8
+ "funding": "https://github.com/sponsors/innocenzi",
9
+ "homepage": "https://github.com/hybridly/hybridly/tree/main/packages/config#readme",
9
10
  "repository": {
10
11
  "type": "git",
11
12
  "url": "git+https://github.com/hybridly/hybridly.git",
12
13
  "directory": "packages/utils"
13
14
  },
14
- "funding": "https://github.com/sponsors/innocenzi",
15
- "author": "Enzo Innocenzi <enzo@innocenzi.dev>",
16
- "type": "module",
17
- "homepage": "https://github.com/hybridly/hybridly/tree/main/packages/config#readme",
18
15
  "bugs": {
19
16
  "url": "https://github.com/hybridly/hybridly/issues"
20
17
  },
18
+ "keywords": [
19
+ "hybridly"
20
+ ],
21
21
  "publishConfig": {
22
22
  "provenance": true,
23
23
  "access": "public"
24
24
  },
25
25
  "sideEffects": false,
26
- "files": [
27
- "dist",
28
- "*.d.ts"
29
- ],
30
26
  "exports": {
31
27
  ".": {
32
- "require": "./dist/index.cjs",
28
+ "types": "./dist/index.d.ts",
33
29
  "import": "./dist/index.mjs",
34
- "types": "./dist/index.d.ts"
30
+ "require": "./dist/index.cjs"
35
31
  }
36
32
  },
37
33
  "main": "dist/index.cjs",
38
34
  "module": "dist/index.mjs",
39
35
  "types": "dist/index.d.ts",
36
+ "files": [
37
+ "*.d.ts",
38
+ "dist"
39
+ ],
40
40
  "dependencies": {
41
- "debug": "^4.3.4",
41
+ "debug": "^4.3.5",
42
42
  "deepmerge": "^4.3.1",
43
43
  "is-plain-object": "^5.0.0",
44
- "lodash.clonedeep": "^4.5.0"
44
+ "lodash.clonedeep": "^4.5.0",
45
+ "throttle-debounce": "^5.0.2"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@types/lodash.clonedeep": "^4.5.9"