@t007/utils 0.0.12 → 0.0.14

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
@@ -23,8 +23,11 @@ __export(index_exports, {
23
23
  VIRTUAL_RESOURCE: () => VIRTUAL_RESOURCE,
24
24
  assignEl: () => assignEl,
25
25
  bindAllMethods: () => bindAllMethods,
26
+ bindCleanupToSignal: () => bindCleanupToSignal,
27
+ breath: () => breath,
26
28
  clamp: () => clamp,
27
29
  createEl: () => createEl,
30
+ deepBreath: () => deepBreath,
28
31
  guardAllMethods: () => guardAllMethods,
29
32
  guardMethod: () => guardMethod,
30
33
  inBoolArrOpt: () => inBoolArrOpt,
@@ -37,13 +40,18 @@ __export(index_exports, {
37
40
  isIter: () => isIter,
38
41
  isNum: () => isNum,
39
42
  isObj: () => isObj,
43
+ isPOJO: () => isPOJO,
40
44
  isSameURL: () => isSameURL,
41
45
  isStr: () => isStr,
42
- isStrictObj: () => isStrictObj,
43
46
  isSym: () => isSym,
47
+ limited: () => limited,
44
48
  loadResource: () => loadResource,
49
+ mockAsync: () => mockAsync,
45
50
  onAllMethods: () => onAllMethods,
46
51
  removeScrollAssist: () => removeScrollAssist,
52
+ requestAnimationFrame: () => requestAnimationFrame2,
53
+ setInterval: () => setInterval,
54
+ setTimeout: () => setTimeout2,
47
55
  uid: () => uid
48
56
  });
49
57
  module.exports = __toCommonJS(index_exports);
@@ -70,7 +78,7 @@ function isArr(obj) {
70
78
  function isObj(obj, arraycheck = true) {
71
79
  return "object" === typeof obj && obj !== null && (arraycheck ? !Array.isArray(obj) : true);
72
80
  }
73
- function isStrictObj(obj, crossRealms = false, typecheck = true) {
81
+ function isPOJO(obj, crossRealms = false, typecheck = true) {
74
82
  return (typecheck ? isObj(obj, false) : true) && (crossRealms ? Object.prototype.toString.call(obj) === "[object Object]" : obj.constructor === Object);
75
83
  }
76
84
  function isIter(obj) {
@@ -83,20 +91,6 @@ function inBoolArrOpt(opt, str) {
83
91
  return opt?.includes?.(str) ?? opt;
84
92
  }
85
93
 
86
- // src/core/str.ts
87
- function uid(prefix = "") {
88
- return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
89
- }
90
- function isSameURL(src1, src2) {
91
- if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
92
- try {
93
- const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
94
- return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
95
- } catch {
96
- return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
97
- }
98
- }
99
-
100
94
  // src/core/dom.ts
101
95
  function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
102
96
  return assignEl(el, props, dataset, styles), el;
@@ -147,15 +141,73 @@ function clamp(min = 0, val, max = Infinity) {
147
141
  return Math.min(Math.max(val, min), max);
148
142
  }
149
143
 
144
+ // src/core/str.ts
145
+ function uid(prefix = "") {
146
+ return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
147
+ }
148
+ function isSameURL(src1, src2) {
149
+ if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
150
+ try {
151
+ const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
152
+ return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
153
+ } catch {
154
+ return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
155
+ }
156
+ }
157
+
158
+ // src/core/fn.ts
159
+ function setTimeout2(handler, timeout, ...args) {
160
+ const sig = args[0] instanceof AbortSignal ? args.shift() : void 0;
161
+ if (sig?.aborted) return -1;
162
+ const w = args[0] instanceof Window ? args.shift() : window;
163
+ if (!sig) return w.setTimeout(handler, timeout, ...args);
164
+ const id = w.setTimeout(() => (sig.removeEventListener("abort", kill), isStr(handler) ? new Function(handler) : handler(...args)), timeout), kill = () => w.clearTimeout(id);
165
+ return sig.addEventListener("abort", kill, { once: true }), id;
166
+ }
167
+ function setInterval(handler, timeout, ...args) {
168
+ const sig = args[0] instanceof AbortSignal ? args.shift() : void 0;
169
+ if (sig?.aborted) return -1;
170
+ const w = args[0] instanceof Window ? args.shift() : window, id = w.setInterval(handler, timeout, ...args);
171
+ return sig?.addEventListener("abort", () => w.clearInterval(id), { once: true }), id;
172
+ }
173
+ function requestAnimationFrame2(callback, sig, w = window) {
174
+ if (sig?.aborted) return -1;
175
+ if (!sig) return w.requestAnimationFrame(callback);
176
+ const id = w.requestAnimationFrame((t) => (sig.removeEventListener("abort", kill), callback(t))), kill = () => w.cancelAnimationFrame(id);
177
+ return sig.addEventListener("abort", kill, { once: true }), id;
178
+ }
179
+ function limited(FN_KEY, fn, opts = {}) {
180
+ let count = 0, { key, maxTimes: max = 1 } = isStr(opts) ? { key: opts } : opts;
181
+ const getReg = () => JSON.parse(localStorage.getItem(FN_KEY) || "{}"), setReg = (r) => localStorage.setItem(FN_KEY, JSON.stringify(r));
182
+ const handle = (...args) => {
183
+ if (!key) return count++ < max ? fn(...args) : void 0;
184
+ const r = getReg(), c = r[key] || 0;
185
+ return c < max ? (r[key] = c + 1, setReg(r), fn(...args)) : void 0;
186
+ };
187
+ handle.left = max - (handle.count = count);
188
+ handle.reset = () => (count = 0, key && ((r) => (delete r[key], setReg(r)))(getReg()));
189
+ handle.block = () => (count = max, key && ((r) => (r[key] = max, setReg(r)))(getReg()));
190
+ return handle;
191
+ }
192
+ var mockAsync = (timeout = 250) => new Promise((resolve) => setTimeout2(resolve, timeout));
193
+ var breath = (w = window) => new Promise((res) => w.requestAnimationFrame(res));
194
+ var deepBreath = (w = window) => new Promise((res) => w.requestAnimationFrame(() => w.requestAnimationFrame(res)));
195
+ function bindCleanupToSignal(cleanup, signal) {
196
+ signal?.aborted ? cleanup() : signal?.addEventListener("abort", cleanup, { once: true });
197
+ if (signal && !signal.aborted) cleanup = (() => (signal.removeEventListener("abort", cleanup), cleanup()));
198
+ return cleanup;
199
+ }
200
+
150
201
  // src/mixins/methodist.ts
151
- function onAllMethods(owner, callback) {
202
+ function onAllMethods(owner, callback, skipNestedOwn = true, nested = false) {
152
203
  let proto = owner;
153
204
  while (proto && proto !== Object.prototype) {
154
205
  for (const method of Object.getOwnPropertyNames(proto)) {
155
206
  if (method === "constructor") continue;
207
+ if (nested && skipNestedOwn && Object.prototype.hasOwnProperty.call(owner, method)) continue;
156
208
  if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
157
209
  }
158
- proto = Object.getPrototypeOf(proto);
210
+ proto = Object.getPrototypeOf(proto), nested = true;
159
211
  }
160
212
  }
161
213
  function bindAllMethods(owner) {
@@ -283,8 +335,11 @@ if (isDef(window)) {
283
335
  VIRTUAL_RESOURCE,
284
336
  assignEl,
285
337
  bindAllMethods,
338
+ bindCleanupToSignal,
339
+ breath,
286
340
  clamp,
287
341
  createEl,
342
+ deepBreath,
288
343
  guardAllMethods,
289
344
  guardMethod,
290
345
  inBoolArrOpt,
@@ -297,12 +352,17 @@ if (isDef(window)) {
297
352
  isIter,
298
353
  isNum,
299
354
  isObj,
355
+ isPOJO,
300
356
  isSameURL,
301
357
  isStr,
302
- isStrictObj,
303
358
  isSym,
359
+ limited,
304
360
  loadResource,
361
+ mockAsync,
305
362
  onAllMethods,
306
363
  removeScrollAssist,
364
+ requestAnimationFrame,
365
+ setInterval,
366
+ setTimeout,
307
367
  uid
308
368
  });
package/dist/index.d.cts CHANGED
@@ -57,7 +57,7 @@ declare function isNum<T extends number = number>(val: any): val is T;
57
57
  declare function isStr<T extends string = string>(val: any): val is T;
58
58
  declare function isArr<T = unknown>(obj: any): obj is T[];
59
59
  declare function isObj<T extends object = object>(obj: any, arraycheck?: boolean): obj is T;
60
- declare function isStrictObj<T extends object = object>(obj: any, crossRealms?: boolean, typecheck?: boolean): obj is T;
60
+ declare function isPOJO<T extends object = object>(obj: any, crossRealms?: boolean, typecheck?: boolean): obj is T;
61
61
  declare function isIter<T = unknown>(obj: any): obj is Iterable<T>;
62
62
  declare function isFunc<T extends Function = Function>(val: any): val is T;
63
63
  declare function inBoolArrOpt(opt: any, str: string): boolean;
@@ -67,6 +67,26 @@ declare function clamp(min: number | undefined, val: number, max?: number): numb
67
67
  declare function uid(prefix?: string): string;
68
68
  declare function isSameURL(src1: unknown, src2: unknown): boolean;
69
69
 
70
+ declare function setTimeout(handler: TimerHandler, timeout?: number, ...args: any[]): number;
71
+ declare function setInterval(handler: TimerHandler, timeout?: number, ...args: any[]): number;
72
+ declare function requestAnimationFrame(callback: FrameRequestCallback, sig?: AbortSignal, w?: Window & typeof globalThis): number;
73
+ interface LimitedOptions {
74
+ key?: string /** Key for localStorage persistence (if omitted, uses session-only) */;
75
+ maxTimes?: number /** Max times to call (default: 1) */;
76
+ }
77
+ interface LimitedHandle<T extends (...args: any[]) => any> {
78
+ (...args: Parameters<T>): ReturnType<T> | void;
79
+ count: number;
80
+ left: number;
81
+ reset: () => void;
82
+ block: () => void;
83
+ }
84
+ declare function limited<T extends (...args: any[]) => any>(FN_KEY: string, fn: T, opts?: LimitedOptions | string): LimitedHandle<T>;
85
+ declare const mockAsync: (timeout?: number) => Promise<void>;
86
+ declare const breath: (w?: Window & typeof globalThis) => Promise<unknown>;
87
+ declare const deepBreath: (w?: Window & typeof globalThis) => Promise<unknown>;
88
+ declare function bindCleanupToSignal<Cb extends () => any>(cleanup: Cb, signal?: AbortSignal): Cb;
89
+
70
90
  type Dataset = Record<string, string | number>;
71
91
  type Style = Partial<CSSStyleDeclaration>;
72
92
  type ResourceType = "style" | "script" | string;
@@ -88,9 +108,9 @@ declare function assignEl(el?: HTMLElement | null, props?: Partial<HTMLElement>,
88
108
  declare const VIRTUAL_RESOURCE: unique symbol;
89
109
  declare function loadResource(req: string | symbol, type?: ResourceType, { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts, retryKey }?: LoadResourceOptions, w?: Window & typeof globalThis): Promise<HTMLElement | void>;
90
110
 
91
- declare function onAllMethods(owner: any, callback: (method: string, owner: any) => void): void;
111
+ declare function onAllMethods(owner: any, callback: (method: string, owner: any) => void, skipNestedOwn?: boolean, nested?: boolean): void;
92
112
  declare function bindAllMethods(owner: any): void;
93
113
  declare function guardAllMethods(owner: any, guardFn?: (fn: Function) => Function, bound?: boolean): void;
94
114
  declare function guardMethod<T extends Function>(fn: T, onError?: (e: any) => void): T;
95
115
 
96
- export { type Dataset, type LoadResourceOptions, type ResourceType, type ScrollAssistControl, type Style, VIRTUAL_RESOURCE, assignEl, bindAllMethods, clamp, createEl, guardAllMethods, guardMethod, inBoolArrOpt, initScrollAssist, initVScrollerator, isArr, isBool, isDef, isFunc, isIter, isNum, isObj, isSameURL, isStr, isStrictObj, isSym, loadResource, onAllMethods, removeScrollAssist, uid };
116
+ export { type Dataset, type LoadResourceOptions, type ResourceType, type ScrollAssistControl, type Style, VIRTUAL_RESOURCE, assignEl, bindAllMethods, bindCleanupToSignal, breath, clamp, createEl, deepBreath, guardAllMethods, guardMethod, inBoolArrOpt, initScrollAssist, initVScrollerator, isArr, isBool, isDef, isFunc, isIter, isNum, isObj, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, onAllMethods, removeScrollAssist, requestAnimationFrame, setInterval, setTimeout, uid };
package/dist/index.d.ts CHANGED
@@ -57,7 +57,7 @@ declare function isNum<T extends number = number>(val: any): val is T;
57
57
  declare function isStr<T extends string = string>(val: any): val is T;
58
58
  declare function isArr<T = unknown>(obj: any): obj is T[];
59
59
  declare function isObj<T extends object = object>(obj: any, arraycheck?: boolean): obj is T;
60
- declare function isStrictObj<T extends object = object>(obj: any, crossRealms?: boolean, typecheck?: boolean): obj is T;
60
+ declare function isPOJO<T extends object = object>(obj: any, crossRealms?: boolean, typecheck?: boolean): obj is T;
61
61
  declare function isIter<T = unknown>(obj: any): obj is Iterable<T>;
62
62
  declare function isFunc<T extends Function = Function>(val: any): val is T;
63
63
  declare function inBoolArrOpt(opt: any, str: string): boolean;
@@ -67,6 +67,26 @@ declare function clamp(min: number | undefined, val: number, max?: number): numb
67
67
  declare function uid(prefix?: string): string;
68
68
  declare function isSameURL(src1: unknown, src2: unknown): boolean;
69
69
 
70
+ declare function setTimeout(handler: TimerHandler, timeout?: number, ...args: any[]): number;
71
+ declare function setInterval(handler: TimerHandler, timeout?: number, ...args: any[]): number;
72
+ declare function requestAnimationFrame(callback: FrameRequestCallback, sig?: AbortSignal, w?: Window & typeof globalThis): number;
73
+ interface LimitedOptions {
74
+ key?: string /** Key for localStorage persistence (if omitted, uses session-only) */;
75
+ maxTimes?: number /** Max times to call (default: 1) */;
76
+ }
77
+ interface LimitedHandle<T extends (...args: any[]) => any> {
78
+ (...args: Parameters<T>): ReturnType<T> | void;
79
+ count: number;
80
+ left: number;
81
+ reset: () => void;
82
+ block: () => void;
83
+ }
84
+ declare function limited<T extends (...args: any[]) => any>(FN_KEY: string, fn: T, opts?: LimitedOptions | string): LimitedHandle<T>;
85
+ declare const mockAsync: (timeout?: number) => Promise<void>;
86
+ declare const breath: (w?: Window & typeof globalThis) => Promise<unknown>;
87
+ declare const deepBreath: (w?: Window & typeof globalThis) => Promise<unknown>;
88
+ declare function bindCleanupToSignal<Cb extends () => any>(cleanup: Cb, signal?: AbortSignal): Cb;
89
+
70
90
  type Dataset = Record<string, string | number>;
71
91
  type Style = Partial<CSSStyleDeclaration>;
72
92
  type ResourceType = "style" | "script" | string;
@@ -88,9 +108,9 @@ declare function assignEl(el?: HTMLElement | null, props?: Partial<HTMLElement>,
88
108
  declare const VIRTUAL_RESOURCE: unique symbol;
89
109
  declare function loadResource(req: string | symbol, type?: ResourceType, { module, media, crossOrigin, integrity, referrerPolicy, nonce, fetchPriority, attempts, retryKey }?: LoadResourceOptions, w?: Window & typeof globalThis): Promise<HTMLElement | void>;
90
110
 
91
- declare function onAllMethods(owner: any, callback: (method: string, owner: any) => void): void;
111
+ declare function onAllMethods(owner: any, callback: (method: string, owner: any) => void, skipNestedOwn?: boolean, nested?: boolean): void;
92
112
  declare function bindAllMethods(owner: any): void;
93
113
  declare function guardAllMethods(owner: any, guardFn?: (fn: Function) => Function, bound?: boolean): void;
94
114
  declare function guardMethod<T extends Function>(fn: T, onError?: (e: any) => void): T;
95
115
 
96
- export { type Dataset, type LoadResourceOptions, type ResourceType, type ScrollAssistControl, type Style, VIRTUAL_RESOURCE, assignEl, bindAllMethods, clamp, createEl, guardAllMethods, guardMethod, inBoolArrOpt, initScrollAssist, initVScrollerator, isArr, isBool, isDef, isFunc, isIter, isNum, isObj, isSameURL, isStr, isStrictObj, isSym, loadResource, onAllMethods, removeScrollAssist, uid };
116
+ export { type Dataset, type LoadResourceOptions, type ResourceType, type ScrollAssistControl, type Style, VIRTUAL_RESOURCE, assignEl, bindAllMethods, bindCleanupToSignal, breath, clamp, createEl, deepBreath, guardAllMethods, guardMethod, inBoolArrOpt, initScrollAssist, initVScrollerator, isArr, isBool, isDef, isFunc, isIter, isNum, isObj, isPOJO, isSameURL, isStr, isSym, limited, loadResource, mockAsync, onAllMethods, removeScrollAssist, requestAnimationFrame, setInterval, setTimeout, uid };
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ function isArr(obj) {
20
20
  function isObj(obj, arraycheck = true) {
21
21
  return "object" === typeof obj && obj !== null && (arraycheck ? !Array.isArray(obj) : true);
22
22
  }
23
- function isStrictObj(obj, crossRealms = false, typecheck = true) {
23
+ function isPOJO(obj, crossRealms = false, typecheck = true) {
24
24
  return (typecheck ? isObj(obj, false) : true) && (crossRealms ? Object.prototype.toString.call(obj) === "[object Object]" : obj.constructor === Object);
25
25
  }
26
26
  function isIter(obj) {
@@ -33,20 +33,6 @@ function inBoolArrOpt(opt, str) {
33
33
  return opt?.includes?.(str) ?? opt;
34
34
  }
35
35
 
36
- // src/core/str.ts
37
- function uid(prefix = "") {
38
- return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
39
- }
40
- function isSameURL(src1, src2) {
41
- if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
42
- try {
43
- const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
44
- return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
45
- } catch {
46
- return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
47
- }
48
- }
49
-
50
36
  // src/core/dom.ts
51
37
  function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
52
38
  return assignEl(el, props, dataset, styles), el;
@@ -97,15 +83,73 @@ function clamp(min = 0, val, max = Infinity) {
97
83
  return Math.min(Math.max(val, min), max);
98
84
  }
99
85
 
86
+ // src/core/str.ts
87
+ function uid(prefix = "") {
88
+ return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
89
+ }
90
+ function isSameURL(src1, src2) {
91
+ if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
92
+ try {
93
+ const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
94
+ return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
95
+ } catch {
96
+ return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
97
+ }
98
+ }
99
+
100
+ // src/core/fn.ts
101
+ function setTimeout2(handler, timeout, ...args) {
102
+ const sig = args[0] instanceof AbortSignal ? args.shift() : void 0;
103
+ if (sig?.aborted) return -1;
104
+ const w = args[0] instanceof Window ? args.shift() : window;
105
+ if (!sig) return w.setTimeout(handler, timeout, ...args);
106
+ const id = w.setTimeout(() => (sig.removeEventListener("abort", kill), isStr(handler) ? new Function(handler) : handler(...args)), timeout), kill = () => w.clearTimeout(id);
107
+ return sig.addEventListener("abort", kill, { once: true }), id;
108
+ }
109
+ function setInterval(handler, timeout, ...args) {
110
+ const sig = args[0] instanceof AbortSignal ? args.shift() : void 0;
111
+ if (sig?.aborted) return -1;
112
+ const w = args[0] instanceof Window ? args.shift() : window, id = w.setInterval(handler, timeout, ...args);
113
+ return sig?.addEventListener("abort", () => w.clearInterval(id), { once: true }), id;
114
+ }
115
+ function requestAnimationFrame2(callback, sig, w = window) {
116
+ if (sig?.aborted) return -1;
117
+ if (!sig) return w.requestAnimationFrame(callback);
118
+ const id = w.requestAnimationFrame((t) => (sig.removeEventListener("abort", kill), callback(t))), kill = () => w.cancelAnimationFrame(id);
119
+ return sig.addEventListener("abort", kill, { once: true }), id;
120
+ }
121
+ function limited(FN_KEY, fn, opts = {}) {
122
+ let count = 0, { key, maxTimes: max = 1 } = isStr(opts) ? { key: opts } : opts;
123
+ const getReg = () => JSON.parse(localStorage.getItem(FN_KEY) || "{}"), setReg = (r) => localStorage.setItem(FN_KEY, JSON.stringify(r));
124
+ const handle = (...args) => {
125
+ if (!key) return count++ < max ? fn(...args) : void 0;
126
+ const r = getReg(), c = r[key] || 0;
127
+ return c < max ? (r[key] = c + 1, setReg(r), fn(...args)) : void 0;
128
+ };
129
+ handle.left = max - (handle.count = count);
130
+ handle.reset = () => (count = 0, key && ((r) => (delete r[key], setReg(r)))(getReg()));
131
+ handle.block = () => (count = max, key && ((r) => (r[key] = max, setReg(r)))(getReg()));
132
+ return handle;
133
+ }
134
+ var mockAsync = (timeout = 250) => new Promise((resolve) => setTimeout2(resolve, timeout));
135
+ var breath = (w = window) => new Promise((res) => w.requestAnimationFrame(res));
136
+ var deepBreath = (w = window) => new Promise((res) => w.requestAnimationFrame(() => w.requestAnimationFrame(res)));
137
+ function bindCleanupToSignal(cleanup, signal) {
138
+ signal?.aborted ? cleanup() : signal?.addEventListener("abort", cleanup, { once: true });
139
+ if (signal && !signal.aborted) cleanup = (() => (signal.removeEventListener("abort", cleanup), cleanup()));
140
+ return cleanup;
141
+ }
142
+
100
143
  // src/mixins/methodist.ts
101
- function onAllMethods(owner, callback) {
144
+ function onAllMethods(owner, callback, skipNestedOwn = true, nested = false) {
102
145
  let proto = owner;
103
146
  while (proto && proto !== Object.prototype) {
104
147
  for (const method of Object.getOwnPropertyNames(proto)) {
105
148
  if (method === "constructor") continue;
149
+ if (nested && skipNestedOwn && Object.prototype.hasOwnProperty.call(owner, method)) continue;
106
150
  if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
107
151
  }
108
- proto = Object.getPrototypeOf(proto);
152
+ proto = Object.getPrototypeOf(proto), nested = true;
109
153
  }
110
154
  }
111
155
  function bindAllMethods(owner) {
@@ -232,8 +276,11 @@ export {
232
276
  VIRTUAL_RESOURCE,
233
277
  assignEl,
234
278
  bindAllMethods,
279
+ bindCleanupToSignal,
280
+ breath,
235
281
  clamp,
236
282
  createEl,
283
+ deepBreath,
237
284
  guardAllMethods,
238
285
  guardMethod,
239
286
  inBoolArrOpt,
@@ -246,12 +293,17 @@ export {
246
293
  isIter,
247
294
  isNum,
248
295
  isObj,
296
+ isPOJO,
249
297
  isSameURL,
250
298
  isStr,
251
- isStrictObj,
252
299
  isSym,
300
+ limited,
253
301
  loadResource,
302
+ mockAsync,
254
303
  onAllMethods,
255
304
  removeScrollAssist,
305
+ requestAnimationFrame2 as requestAnimationFrame,
306
+ setInterval,
307
+ setTimeout2 as setTimeout,
256
308
  uid
257
309
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t007/utils",
3
- "version": "0.0.12",
3
+ "version": "0.0.14",
4
4
  "description": "High-performance, zero-dependency utility functions for the t007 ecosystem.",
5
5
  "author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
6
6
  "license": "MIT",