@zag-js/utils 2.0.0-next.3 → 2.0.0-next.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.
Files changed (46) hide show
  1. package/dist/array.d.mts +24 -26
  2. package/dist/array.d.ts +24 -26
  3. package/dist/array.js +76 -117
  4. package/dist/array.mjs +52 -74
  5. package/dist/equal.d.mts +1 -2
  6. package/dist/equal.d.ts +1 -2
  7. package/dist/equal.js +23 -46
  8. package/dist/equal.mjs +19 -23
  9. package/dist/functions.d.mts +13 -15
  10. package/dist/functions.d.ts +13 -15
  11. package/dist/functions.js +82 -121
  12. package/dist/functions.mjs +68 -88
  13. package/dist/guard.d.mts +12 -13
  14. package/dist/guard.d.ts +12 -13
  15. package/dist/guard.js +37 -70
  16. package/dist/guard.mjs +23 -37
  17. package/dist/index.d.mts +10 -10
  18. package/dist/index.d.ts +10 -10
  19. package/dist/index.js +97 -41
  20. package/dist/index.mjs +9 -11
  21. package/dist/lifecycle.d.mts +2 -4
  22. package/dist/lifecycle.d.ts +2 -4
  23. package/dist/lifecycle.js +4 -18
  24. package/dist/lifecycle.mjs +1 -0
  25. package/dist/number.d.mts +37 -38
  26. package/dist/number.d.ts +37 -38
  27. package/dist/number.js +136 -185
  28. package/dist/number.mjs +104 -134
  29. package/dist/object.d.mts +11 -16
  30. package/dist/object.d.ts +11 -16
  31. package/dist/object.js +52 -91
  32. package/dist/object.mjs +41 -61
  33. package/dist/store.d.mts +10 -12
  34. package/dist/store.d.ts +10 -12
  35. package/dist/store.js +42 -67
  36. package/dist/store.mjs +38 -44
  37. package/dist/warning.d.mts +7 -8
  38. package/dist/warning.d.ts +7 -8
  39. package/dist/warning.js +16 -51
  40. package/dist/warning.mjs +9 -25
  41. package/package.json +2 -2
  42. package/dist/chunk-MXGZDBDQ.mjs +0 -15
  43. package/dist/timers.d.mts +0 -26
  44. package/dist/timers.d.ts +0 -26
  45. package/dist/timers.js +0 -119
  46. package/dist/timers.mjs +0 -90
@@ -1,15 +1,13 @@
1
- type MaybeFunction<T> = T | (() => T);
2
- type Nullable<T> = T | null | undefined;
3
- declare const runIfFn: <T>(v: T | undefined, ...a: T extends (...a: any[]) => void ? Parameters<T> : never) => T extends (...a: any[]) => void ? NonNullable<ReturnType<T>> : NonNullable<T>;
4
- declare const cast: <T>(v: unknown) => T;
5
- declare const identity: (v: VoidFunction) => void;
6
- declare const noop: () => void;
7
- declare const callAll: <T extends (...a: any[]) => void>(...fns: (T | null | undefined)[]) => (...a: Parameters<T>) => void;
8
- declare const uuid: () => string;
9
- declare function match<V extends string | number = string, R = unknown>(key: V, record: Record<V, R | ((...args: any[]) => R)>, ...args: any[]): R;
10
- declare const tryCatch: <R>(fn: () => R, fallback: () => R) => R;
11
- declare function throttle<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
12
- declare function debounce<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
13
- declare const hash: (value: string) => string;
14
-
15
- export { type MaybeFunction, type Nullable, callAll, cast, debounce, hash, identity, match, noop, runIfFn, throttle, tryCatch, uuid };
1
+ export type MaybeFunction<T> = T | (() => T);
2
+ export type Nullable<T> = T | null | undefined;
3
+ export declare const runIfFn: <T>(v: T | undefined, ...a: T extends ((...a: any[]) => void) ? Parameters<T> : never) => T extends ((...a: any[]) => void) ? NonNullable<ReturnType<T>> : NonNullable<T>;
4
+ export declare const cast: <T>(v: unknown) => T;
5
+ export declare const identity: (v: VoidFunction) => void;
6
+ export declare const noop: () => void;
7
+ export declare const callAll: <T extends (...a: any[]) => void>(...fns: (T | null | undefined)[]) => (...a: Parameters<T>) => void;
8
+ export declare const uuid: () => string;
9
+ export declare function match<V extends string | number = string, R = unknown>(key: V, record: Record<V, R | ((...args: any[]) => R)>, ...args: any[]): R;
10
+ export declare const tryCatch: <R>(fn: () => R, fallback: () => R) => R;
11
+ export declare function throttle<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
12
+ export declare function debounce<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
13
+ export declare const hash: (value: string) => string;
package/dist/functions.js CHANGED
@@ -1,136 +1,97 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/functions.ts
21
- var functions_exports = {};
22
- __export(functions_exports, {
23
- callAll: () => callAll,
24
- cast: () => cast,
25
- debounce: () => debounce,
26
- hash: () => hash,
27
- identity: () => identity,
28
- match: () => match,
29
- noop: () => noop,
30
- runIfFn: () => runIfFn,
31
- throttle: () => throttle,
32
- tryCatch: () => tryCatch,
33
- uuid: () => uuid
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
34
4
  });
35
- module.exports = __toCommonJS(functions_exports);
36
- var import_guard = require("./guard.js");
37
- var runIfFn = (v, ...a) => {
38
- const res = typeof v === "function" ? v(...a) : v;
39
- return res ?? void 0;
40
- };
41
- var cast = (v) => v;
42
- var identity = (v) => v();
43
- var noop = () => {
5
+ const require_guard = require("./guard.js");
6
+ // src/functions.ts
7
+ const runIfFn = (v, ...a) => {
8
+ return (typeof v === "function" ? v(...a) : v) ?? void 0;
44
9
  };
45
- var callAll = (...fns) => (...a) => {
46
- fns.forEach(function(fn) {
47
- fn?.(...a);
48
- });
10
+ const cast = (v) => v;
11
+ const identity = (v) => v();
12
+ const noop = () => {};
13
+ const callAll = (...fns) => (...a) => {
14
+ fns.forEach(function(fn) {
15
+ fn?.(...a);
16
+ });
49
17
  };
50
- var uuid = /* @__PURE__ */ (() => {
51
- let id = 0;
52
- return () => {
53
- id++;
54
- return id.toString(36);
55
- };
18
+ const uuid = /*#__PURE__*/ (() => {
19
+ let id = 0;
20
+ return () => {
21
+ id++;
22
+ return id.toString(36);
23
+ };
56
24
  })();
57
25
  function match(key, record, ...args) {
58
- if (key in record) {
59
- const fn = record[key];
60
- return (0, import_guard.isFunction)(fn) ? fn(...args) : fn;
61
- }
62
- const error = new Error(`No matching key: ${JSON.stringify(key)} in ${JSON.stringify(Object.keys(record))}`);
63
- Error.captureStackTrace?.(error, match);
64
- throw error;
26
+ if (key in record) {
27
+ const fn = record[key];
28
+ return require_guard.isFunction(fn) ? fn(...args) : fn;
29
+ }
30
+ const error = /* @__PURE__ */ new Error(`No matching key: ${JSON.stringify(key)} in ${JSON.stringify(Object.keys(record))}`);
31
+ Error.captureStackTrace?.(error, match);
32
+ throw error;
65
33
  }
66
- var tryCatch = (fn, fallback) => {
67
- try {
68
- return fn();
69
- } catch (error) {
70
- if (error instanceof Error) {
71
- Error.captureStackTrace?.(error, tryCatch);
72
- }
73
- return fallback?.();
74
- }
34
+ const tryCatch = (fn, fallback) => {
35
+ try {
36
+ return fn();
37
+ } catch (error) {
38
+ if (error instanceof Error) Error.captureStackTrace?.(error, tryCatch);
39
+ return fallback?.();
40
+ }
75
41
  };
76
42
  function throttle(fn, wait = 0) {
77
- let lastCall = 0;
78
- let timeout = null;
79
- return ((...args) => {
80
- const now = Date.now();
81
- const timeSinceLastCall = now - lastCall;
82
- if (timeSinceLastCall >= wait) {
83
- if (timeout) {
84
- clearTimeout(timeout);
85
- timeout = null;
86
- }
87
- fn(...args);
88
- lastCall = now;
89
- } else if (!timeout) {
90
- timeout = setTimeout(() => {
91
- fn(...args);
92
- lastCall = Date.now();
93
- timeout = null;
94
- }, wait - timeSinceLastCall);
95
- }
96
- });
43
+ let lastCall = 0;
44
+ let timeout = null;
45
+ return ((...args) => {
46
+ const now = Date.now();
47
+ const timeSinceLastCall = now - lastCall;
48
+ if (timeSinceLastCall >= wait) {
49
+ if (timeout) {
50
+ clearTimeout(timeout);
51
+ timeout = null;
52
+ }
53
+ fn(...args);
54
+ lastCall = now;
55
+ } else if (!timeout) timeout = setTimeout(() => {
56
+ fn(...args);
57
+ lastCall = Date.now();
58
+ timeout = null;
59
+ }, wait - timeSinceLastCall);
60
+ });
97
61
  }
98
62
  function debounce(fn, wait = 0) {
99
- let timeout = null;
100
- return ((...args) => {
101
- if (timeout) {
102
- clearTimeout(timeout);
103
- timeout = null;
104
- }
105
- timeout = setTimeout(() => {
106
- fn(...args);
107
- }, wait);
108
- });
63
+ let timeout = null;
64
+ return ((...args) => {
65
+ if (timeout) {
66
+ clearTimeout(timeout);
67
+ timeout = null;
68
+ }
69
+ timeout = setTimeout(() => {
70
+ fn(...args);
71
+ }, wait);
72
+ });
109
73
  }
110
- var toChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
74
+ const toChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
111
75
  function toName(code) {
112
- let name = "";
113
- let x;
114
- for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
115
- return toChar(x % 52) + name;
76
+ let name = "";
77
+ let x;
78
+ for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
79
+ return toChar(x % 52) + name;
116
80
  }
117
81
  function toPhash(h, x) {
118
- let i = x.length;
119
- while (i) h = h * 33 ^ x.charCodeAt(--i);
120
- return h;
82
+ let i = x.length;
83
+ while (i) h = h * 33 ^ x.charCodeAt(--i);
84
+ return h;
121
85
  }
122
- var hash = (value) => toName(toPhash(5381, value) >>> 0);
123
- // Annotate the CommonJS export names for ESM import in node:
124
- 0 && (module.exports = {
125
- callAll,
126
- cast,
127
- debounce,
128
- hash,
129
- identity,
130
- match,
131
- noop,
132
- runIfFn,
133
- throttle,
134
- tryCatch,
135
- uuid
136
- });
86
+ const hash = (value) => toName(toPhash(5381, value) >>> 0);
87
+ exports.callAll = callAll;
88
+ exports.cast = cast;
89
+ exports.debounce = debounce;
90
+ exports.hash = hash;
91
+ exports.identity = identity;
92
+ exports.match = match;
93
+ exports.noop = noop;
94
+ exports.runIfFn = runIfFn;
95
+ exports.throttle = throttle;
96
+ exports.tryCatch = tryCatch;
97
+ exports.uuid = uuid;
@@ -1,103 +1,83 @@
1
- import "./chunk-MXGZDBDQ.mjs";
2
-
3
- // src/functions.ts
4
1
  import { isFunction } from "./guard.mjs";
5
- var runIfFn = (v, ...a) => {
6
- const res = typeof v === "function" ? v(...a) : v;
7
- return res ?? void 0;
8
- };
9
- var cast = (v) => v;
10
- var identity = (v) => v();
11
- var noop = () => {
2
+ // src/functions.ts
3
+ const runIfFn = (v, ...a) => {
4
+ return (typeof v === "function" ? v(...a) : v) ?? void 0;
12
5
  };
13
- var callAll = (...fns) => (...a) => {
14
- fns.forEach(function(fn) {
15
- fn?.(...a);
16
- });
6
+ const cast = (v) => v;
7
+ const identity = (v) => v();
8
+ const noop = () => {};
9
+ const callAll = (...fns) => (...a) => {
10
+ fns.forEach(function(fn) {
11
+ fn?.(...a);
12
+ });
17
13
  };
18
- var uuid = /* @__PURE__ */ (() => {
19
- let id = 0;
20
- return () => {
21
- id++;
22
- return id.toString(36);
23
- };
14
+ const uuid = /*#__PURE__*/ (() => {
15
+ let id = 0;
16
+ return () => {
17
+ id++;
18
+ return id.toString(36);
19
+ };
24
20
  })();
25
21
  function match(key, record, ...args) {
26
- if (key in record) {
27
- const fn = record[key];
28
- return isFunction(fn) ? fn(...args) : fn;
29
- }
30
- const error = new Error(`No matching key: ${JSON.stringify(key)} in ${JSON.stringify(Object.keys(record))}`);
31
- Error.captureStackTrace?.(error, match);
32
- throw error;
22
+ if (key in record) {
23
+ const fn = record[key];
24
+ return isFunction(fn) ? fn(...args) : fn;
25
+ }
26
+ const error = /* @__PURE__ */ new Error(`No matching key: ${JSON.stringify(key)} in ${JSON.stringify(Object.keys(record))}`);
27
+ Error.captureStackTrace?.(error, match);
28
+ throw error;
33
29
  }
34
- var tryCatch = (fn, fallback) => {
35
- try {
36
- return fn();
37
- } catch (error) {
38
- if (error instanceof Error) {
39
- Error.captureStackTrace?.(error, tryCatch);
40
- }
41
- return fallback?.();
42
- }
30
+ const tryCatch = (fn, fallback) => {
31
+ try {
32
+ return fn();
33
+ } catch (error) {
34
+ if (error instanceof Error) Error.captureStackTrace?.(error, tryCatch);
35
+ return fallback?.();
36
+ }
43
37
  };
44
38
  function throttle(fn, wait = 0) {
45
- let lastCall = 0;
46
- let timeout = null;
47
- return ((...args) => {
48
- const now = Date.now();
49
- const timeSinceLastCall = now - lastCall;
50
- if (timeSinceLastCall >= wait) {
51
- if (timeout) {
52
- clearTimeout(timeout);
53
- timeout = null;
54
- }
55
- fn(...args);
56
- lastCall = now;
57
- } else if (!timeout) {
58
- timeout = setTimeout(() => {
59
- fn(...args);
60
- lastCall = Date.now();
61
- timeout = null;
62
- }, wait - timeSinceLastCall);
63
- }
64
- });
39
+ let lastCall = 0;
40
+ let timeout = null;
41
+ return ((...args) => {
42
+ const now = Date.now();
43
+ const timeSinceLastCall = now - lastCall;
44
+ if (timeSinceLastCall >= wait) {
45
+ if (timeout) {
46
+ clearTimeout(timeout);
47
+ timeout = null;
48
+ }
49
+ fn(...args);
50
+ lastCall = now;
51
+ } else if (!timeout) timeout = setTimeout(() => {
52
+ fn(...args);
53
+ lastCall = Date.now();
54
+ timeout = null;
55
+ }, wait - timeSinceLastCall);
56
+ });
65
57
  }
66
58
  function debounce(fn, wait = 0) {
67
- let timeout = null;
68
- return ((...args) => {
69
- if (timeout) {
70
- clearTimeout(timeout);
71
- timeout = null;
72
- }
73
- timeout = setTimeout(() => {
74
- fn(...args);
75
- }, wait);
76
- });
59
+ let timeout = null;
60
+ return ((...args) => {
61
+ if (timeout) {
62
+ clearTimeout(timeout);
63
+ timeout = null;
64
+ }
65
+ timeout = setTimeout(() => {
66
+ fn(...args);
67
+ }, wait);
68
+ });
77
69
  }
78
- var toChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
70
+ const toChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
79
71
  function toName(code) {
80
- let name = "";
81
- let x;
82
- for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
83
- return toChar(x % 52) + name;
72
+ let name = "";
73
+ let x;
74
+ for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
75
+ return toChar(x % 52) + name;
84
76
  }
85
77
  function toPhash(h, x) {
86
- let i = x.length;
87
- while (i) h = h * 33 ^ x.charCodeAt(--i);
88
- return h;
78
+ let i = x.length;
79
+ while (i) h = h * 33 ^ x.charCodeAt(--i);
80
+ return h;
89
81
  }
90
- var hash = (value) => toName(toPhash(5381, value) >>> 0);
91
- export {
92
- callAll,
93
- cast,
94
- debounce,
95
- hash,
96
- identity,
97
- match,
98
- noop,
99
- runIfFn,
100
- throttle,
101
- tryCatch,
102
- uuid
103
- };
82
+ const hash = (value) => toName(toPhash(5381, value) >>> 0);
83
+ export { callAll, cast, debounce, hash, identity, match, noop, runIfFn, throttle, tryCatch, uuid };
package/dist/guard.d.mts CHANGED
@@ -1,14 +1,13 @@
1
1
  type AnyFunction = (...args: any[]) => any;
2
- declare const isDev: () => boolean;
3
- declare const isArray: (v: any) => v is any[];
4
- declare const isBoolean: (v: any) => v is boolean;
5
- declare const isObjectLike: (v: any) => v is Record<string, any>;
6
- declare const isObject: (v: any) => v is Record<string, any>;
7
- declare const isNumber: (v: any) => v is number;
8
- declare const isString: (v: any) => v is string;
9
- declare const isFunction: (v: any) => v is AnyFunction;
10
- declare const isNull: (v: any) => v is null | undefined;
11
- declare const hasProp: <T extends string>(obj: any, prop: T) => obj is Record<T, any>;
12
- declare const isPlainObject: (v: any) => boolean;
13
-
14
- export { hasProp, isArray, isBoolean, isDev, isFunction, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString };
2
+ export declare const isDev: () => boolean;
3
+ export declare const isArray: (v: any) => v is any[];
4
+ export declare const isBoolean: (v: any) => v is boolean;
5
+ export declare const isObjectLike: (v: any) => v is Record<string, any>;
6
+ export declare const isObject: (v: any) => v is Record<string, any>;
7
+ export declare const isNumber: (v: any) => v is number;
8
+ export declare const isString: (v: any) => v is string;
9
+ export declare const isFunction: (v: any) => v is AnyFunction;
10
+ export declare const isNull: (v: any) => v is null | undefined;
11
+ export declare const hasProp: <T extends string>(obj: any, prop: T) => obj is Record<T, any>;
12
+ export declare const isPlainObject: (v: any) => boolean;
13
+ export {};
package/dist/guard.d.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  type AnyFunction = (...args: any[]) => any;
2
- declare const isDev: () => boolean;
3
- declare const isArray: (v: any) => v is any[];
4
- declare const isBoolean: (v: any) => v is boolean;
5
- declare const isObjectLike: (v: any) => v is Record<string, any>;
6
- declare const isObject: (v: any) => v is Record<string, any>;
7
- declare const isNumber: (v: any) => v is number;
8
- declare const isString: (v: any) => v is string;
9
- declare const isFunction: (v: any) => v is AnyFunction;
10
- declare const isNull: (v: any) => v is null | undefined;
11
- declare const hasProp: <T extends string>(obj: any, prop: T) => obj is Record<T, any>;
12
- declare const isPlainObject: (v: any) => boolean;
13
-
14
- export { hasProp, isArray, isBoolean, isDev, isFunction, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString };
2
+ export declare const isDev: () => boolean;
3
+ export declare const isArray: (v: any) => v is any[];
4
+ export declare const isBoolean: (v: any) => v is boolean;
5
+ export declare const isObjectLike: (v: any) => v is Record<string, any>;
6
+ export declare const isObject: (v: any) => v is Record<string, any>;
7
+ export declare const isNumber: (v: any) => v is number;
8
+ export declare const isString: (v: any) => v is string;
9
+ export declare const isFunction: (v: any) => v is AnyFunction;
10
+ export declare const isNull: (v: any) => v is null | undefined;
11
+ export declare const hasProp: <T extends string>(obj: any, prop: T) => obj is Record<T, any>;
12
+ export declare const isPlainObject: (v: any) => boolean;
13
+ export {};
package/dist/guard.js CHANGED
@@ -1,72 +1,39 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/guard.ts
21
- var guard_exports = {};
22
- __export(guard_exports, {
23
- hasProp: () => hasProp,
24
- isArray: () => isArray,
25
- isBoolean: () => isBoolean,
26
- isDev: () => isDev,
27
- isFunction: () => isFunction,
28
- isNull: () => isNull,
29
- isNumber: () => isNumber,
30
- isObject: () => isObject,
31
- isObjectLike: () => isObjectLike,
32
- isPlainObject: () => isPlainObject,
33
- isString: () => isString
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
34
4
  });
35
- module.exports = __toCommonJS(guard_exports);
36
- var isDev = () => process.env.NODE_ENV !== "production";
37
- var isArray = (v) => Array.isArray(v);
38
- var isBoolean = (v) => v === true || v === false;
39
- var isObjectLike = (v) => v != null && typeof v === "object";
40
- var isObject = (v) => isObjectLike(v) && !isArray(v);
41
- var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
42
- var isString = (v) => typeof v === "string";
43
- var isFunction = (v) => typeof v === "function";
44
- var isNull = (v) => v == null;
45
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
46
- var baseGetTag = (v) => Object.prototype.toString.call(v);
47
- var fnToString = Function.prototype.toString;
48
- var objectCtorString = fnToString.call(Object);
49
- var isPlainObject = (v) => {
50
- if (!isObjectLike(v) || baseGetTag(v) != "[object Object]" || isFrameworkElement(v)) return false;
51
- const proto = Object.getPrototypeOf(v);
52
- if (proto === null) return true;
53
- const Ctor = hasProp(proto, "constructor") && proto.constructor;
54
- return typeof Ctor == "function" && Ctor instanceof Ctor && fnToString.call(Ctor) == objectCtorString;
5
+ // src/guard.ts
6
+ const isDev = () => process.env.NODE_ENV !== "production";
7
+ const isArray = (v) => Array.isArray(v);
8
+ const isBoolean = (v) => v === true || v === false;
9
+ const isObjectLike = (v) => v != null && typeof v === "object";
10
+ const isObject = (v) => isObjectLike(v) && !isArray(v);
11
+ const isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
12
+ const isString = (v) => typeof v === "string";
13
+ const isFunction = (v) => typeof v === "function";
14
+ const isNull = (v) => v == null;
15
+ const hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
16
+ const baseGetTag = (v) => Object.prototype.toString.call(v);
17
+ const fnToString = Function.prototype.toString;
18
+ const objectCtorString = fnToString.call(Object);
19
+ const isPlainObject = (v) => {
20
+ if (!isObjectLike(v) || baseGetTag(v) != "[object Object]" || isFrameworkElement(v)) return false;
21
+ const proto = Object.getPrototypeOf(v);
22
+ if (proto === null) return true;
23
+ const Ctor = hasProp(proto, "constructor") && proto.constructor;
24
+ return typeof Ctor == "function" && Ctor instanceof Ctor && fnToString.call(Ctor) == objectCtorString;
55
25
  };
56
- var isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x && "props" in x;
57
- var isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
58
- var isFrameworkElement = (x) => isReactElement(x) || isVueElement(x);
59
- // Annotate the CommonJS export names for ESM import in node:
60
- 0 && (module.exports = {
61
- hasProp,
62
- isArray,
63
- isBoolean,
64
- isDev,
65
- isFunction,
66
- isNull,
67
- isNumber,
68
- isObject,
69
- isObjectLike,
70
- isPlainObject,
71
- isString
72
- });
26
+ const isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x && "props" in x;
27
+ const isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
28
+ const isFrameworkElement = (x) => isReactElement(x) || isVueElement(x);
29
+ exports.hasProp = hasProp;
30
+ exports.isArray = isArray;
31
+ exports.isBoolean = isBoolean;
32
+ exports.isDev = isDev;
33
+ exports.isFunction = isFunction;
34
+ exports.isNull = isNull;
35
+ exports.isNumber = isNumber;
36
+ exports.isObject = isObject;
37
+ exports.isObjectLike = isObjectLike;
38
+ exports.isPlainObject = isPlainObject;
39
+ exports.isString = isString;
package/dist/guard.mjs CHANGED
@@ -1,39 +1,25 @@
1
- import "./chunk-MXGZDBDQ.mjs";
2
-
3
1
  // src/guard.ts
4
- var isDev = () => process.env.NODE_ENV !== "production";
5
- var isArray = (v) => Array.isArray(v);
6
- var isBoolean = (v) => v === true || v === false;
7
- var isObjectLike = (v) => v != null && typeof v === "object";
8
- var isObject = (v) => isObjectLike(v) && !isArray(v);
9
- var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
10
- var isString = (v) => typeof v === "string";
11
- var isFunction = (v) => typeof v === "function";
12
- var isNull = (v) => v == null;
13
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
14
- var baseGetTag = (v) => Object.prototype.toString.call(v);
15
- var fnToString = Function.prototype.toString;
16
- var objectCtorString = fnToString.call(Object);
17
- var isPlainObject = (v) => {
18
- if (!isObjectLike(v) || baseGetTag(v) != "[object Object]" || isFrameworkElement(v)) return false;
19
- const proto = Object.getPrototypeOf(v);
20
- if (proto === null) return true;
21
- const Ctor = hasProp(proto, "constructor") && proto.constructor;
22
- return typeof Ctor == "function" && Ctor instanceof Ctor && fnToString.call(Ctor) == objectCtorString;
23
- };
24
- var isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x && "props" in x;
25
- var isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
26
- var isFrameworkElement = (x) => isReactElement(x) || isVueElement(x);
27
- export {
28
- hasProp,
29
- isArray,
30
- isBoolean,
31
- isDev,
32
- isFunction,
33
- isNull,
34
- isNumber,
35
- isObject,
36
- isObjectLike,
37
- isPlainObject,
38
- isString
2
+ const isDev = () => process.env.NODE_ENV !== "production";
3
+ const isArray = (v) => Array.isArray(v);
4
+ const isBoolean = (v) => v === true || v === false;
5
+ const isObjectLike = (v) => v != null && typeof v === "object";
6
+ const isObject = (v) => isObjectLike(v) && !isArray(v);
7
+ const isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
8
+ const isString = (v) => typeof v === "string";
9
+ const isFunction = (v) => typeof v === "function";
10
+ const isNull = (v) => v == null;
11
+ const hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
12
+ const baseGetTag = (v) => Object.prototype.toString.call(v);
13
+ const fnToString = Function.prototype.toString;
14
+ const objectCtorString = fnToString.call(Object);
15
+ const isPlainObject = (v) => {
16
+ if (!isObjectLike(v) || baseGetTag(v) != "[object Object]" || isFrameworkElement(v)) return false;
17
+ const proto = Object.getPrototypeOf(v);
18
+ if (proto === null) return true;
19
+ const Ctor = hasProp(proto, "constructor") && proto.constructor;
20
+ return typeof Ctor == "function" && Ctor instanceof Ctor && fnToString.call(Ctor) == objectCtorString;
39
21
  };
22
+ const isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x && "props" in x;
23
+ const isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
24
+ const isFrameworkElement = (x) => isReactElement(x) || isVueElement(x);
25
+ export { hasProp, isArray, isBoolean, isDev, isFunction, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString };