@t007/utils 0.0.10 → 0.0.12
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 +14 -8
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +10 -4
- package/package.json +2 -5
package/dist/index.cjs
CHANGED
|
@@ -32,14 +32,14 @@ __export(index_exports, {
|
|
|
32
32
|
initVScrollerator: () => initVScrollerator,
|
|
33
33
|
isArr: () => isArr,
|
|
34
34
|
isBool: () => isBool,
|
|
35
|
-
isDef: () =>
|
|
35
|
+
isDef: () => isDef,
|
|
36
36
|
isFunc: () => isFunc,
|
|
37
37
|
isIter: () => isIter,
|
|
38
38
|
isNum: () => isNum,
|
|
39
|
-
isObj: () =>
|
|
39
|
+
isObj: () => isObj,
|
|
40
40
|
isSameURL: () => isSameURL,
|
|
41
41
|
isStr: () => isStr,
|
|
42
|
-
isStrictObj: () =>
|
|
42
|
+
isStrictObj: () => isStrictObj,
|
|
43
43
|
isSym: () => isSym,
|
|
44
44
|
loadResource: () => loadResource,
|
|
45
45
|
onAllMethods: () => onAllMethods,
|
|
@@ -49,8 +49,9 @@ __export(index_exports, {
|
|
|
49
49
|
module.exports = __toCommonJS(index_exports);
|
|
50
50
|
|
|
51
51
|
// src/core/obj.ts
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
function isDef(val) {
|
|
53
|
+
return "undefined" !== typeof val;
|
|
54
|
+
}
|
|
54
55
|
function isSym(val) {
|
|
55
56
|
return "symbol" === typeof val;
|
|
56
57
|
}
|
|
@@ -66,6 +67,12 @@ function isStr(val) {
|
|
|
66
67
|
function isArr(obj) {
|
|
67
68
|
return Array.isArray(obj);
|
|
68
69
|
}
|
|
70
|
+
function isObj(obj, arraycheck = true) {
|
|
71
|
+
return "object" === typeof obj && obj !== null && (arraycheck ? !Array.isArray(obj) : true);
|
|
72
|
+
}
|
|
73
|
+
function isStrictObj(obj, crossRealms = false, typecheck = true) {
|
|
74
|
+
return (typecheck ? isObj(obj, false) : true) && (crossRealms ? Object.prototype.toString.call(obj) === "[object Object]" : obj.constructor === Object);
|
|
75
|
+
}
|
|
69
76
|
function isIter(obj) {
|
|
70
77
|
return obj != null && "function" === typeof obj[Symbol.iterator];
|
|
71
78
|
}
|
|
@@ -146,8 +153,7 @@ function onAllMethods(owner, callback) {
|
|
|
146
153
|
while (proto && proto !== Object.prototype) {
|
|
147
154
|
for (const method of Object.getOwnPropertyNames(proto)) {
|
|
148
155
|
if (method === "constructor") continue;
|
|
149
|
-
if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value))
|
|
150
|
-
callback(method, owner);
|
|
156
|
+
if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
|
|
151
157
|
}
|
|
152
158
|
proto = Object.getPrototypeOf(proto);
|
|
153
159
|
}
|
|
@@ -262,7 +268,7 @@ function initScrollAssist(el, { pxPerSecond = 80, assistClassName = "tmg-video-c
|
|
|
262
268
|
var removeScrollAssist = (el) => t007._scrollers.get(el)?.destroy();
|
|
263
269
|
|
|
264
270
|
// src/index.ts
|
|
265
|
-
if (
|
|
271
|
+
if (isDef(window)) {
|
|
266
272
|
window.t007 ??= {};
|
|
267
273
|
t007.VIRTUAL_RESOURCE = VIRTUAL_RESOURCE;
|
|
268
274
|
window.T007_TOAST_JS_SRC ??= `https://cdn.jsdelivr.net/npm/@t007/toast@latest`;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export { isDef, isObj, isStrictObj } from 'sia-reactor/utils';
|
|
2
|
-
|
|
3
1
|
interface ScrolleratorOptions {
|
|
4
2
|
baseSpeed?: number;
|
|
5
3
|
maxSpeed?: number;
|
|
@@ -52,12 +50,14 @@ declare global {
|
|
|
52
50
|
var t007: T007Namespace;
|
|
53
51
|
}
|
|
54
52
|
|
|
53
|
+
declare function isDef(val: any): boolean;
|
|
55
54
|
declare function isSym<T extends symbol = symbol>(val: any): val is T;
|
|
56
55
|
declare function isBool<T extends boolean = boolean>(val: any): val is T;
|
|
57
56
|
declare function isNum<T extends number = number>(val: any): val is T;
|
|
58
57
|
declare function isStr<T extends string = string>(val: any): val is T;
|
|
59
58
|
declare function isArr<T = unknown>(obj: any): obj is T[];
|
|
60
|
-
|
|
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;
|
|
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;
|
|
@@ -93,4 +93,4 @@ declare function bindAllMethods(owner: any): void;
|
|
|
93
93
|
declare function guardAllMethods(owner: any, guardFn?: (fn: Function) => Function, bound?: boolean): void;
|
|
94
94
|
declare function guardMethod<T extends Function>(fn: T, onError?: (e: any) => void): T;
|
|
95
95
|
|
|
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, isFunc, isIter, isNum, isSameURL, isStr, isSym, loadResource, onAllMethods, removeScrollAssist, uid };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export { isDef, isObj, isStrictObj } from 'sia-reactor/utils';
|
|
2
|
-
|
|
3
1
|
interface ScrolleratorOptions {
|
|
4
2
|
baseSpeed?: number;
|
|
5
3
|
maxSpeed?: number;
|
|
@@ -52,12 +50,14 @@ declare global {
|
|
|
52
50
|
var t007: T007Namespace;
|
|
53
51
|
}
|
|
54
52
|
|
|
53
|
+
declare function isDef(val: any): boolean;
|
|
55
54
|
declare function isSym<T extends symbol = symbol>(val: any): val is T;
|
|
56
55
|
declare function isBool<T extends boolean = boolean>(val: any): val is T;
|
|
57
56
|
declare function isNum<T extends number = number>(val: any): val is T;
|
|
58
57
|
declare function isStr<T extends string = string>(val: any): val is T;
|
|
59
58
|
declare function isArr<T = unknown>(obj: any): obj is T[];
|
|
60
|
-
|
|
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;
|
|
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;
|
|
@@ -93,4 +93,4 @@ declare function bindAllMethods(owner: any): void;
|
|
|
93
93
|
declare function guardAllMethods(owner: any, guardFn?: (fn: Function) => Function, bound?: boolean): void;
|
|
94
94
|
declare function guardMethod<T extends Function>(fn: T, onError?: (e: any) => void): T;
|
|
95
95
|
|
|
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, isFunc, isIter, isNum, isSameURL, isStr, isSym, loadResource, onAllMethods, removeScrollAssist, uid };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/core/obj.ts
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
function isDef(val) {
|
|
3
|
+
return "undefined" !== typeof val;
|
|
4
|
+
}
|
|
4
5
|
function isSym(val) {
|
|
5
6
|
return "symbol" === typeof val;
|
|
6
7
|
}
|
|
@@ -16,6 +17,12 @@ function isStr(val) {
|
|
|
16
17
|
function isArr(obj) {
|
|
17
18
|
return Array.isArray(obj);
|
|
18
19
|
}
|
|
20
|
+
function isObj(obj, arraycheck = true) {
|
|
21
|
+
return "object" === typeof obj && obj !== null && (arraycheck ? !Array.isArray(obj) : true);
|
|
22
|
+
}
|
|
23
|
+
function isStrictObj(obj, crossRealms = false, typecheck = true) {
|
|
24
|
+
return (typecheck ? isObj(obj, false) : true) && (crossRealms ? Object.prototype.toString.call(obj) === "[object Object]" : obj.constructor === Object);
|
|
25
|
+
}
|
|
19
26
|
function isIter(obj) {
|
|
20
27
|
return obj != null && "function" === typeof obj[Symbol.iterator];
|
|
21
28
|
}
|
|
@@ -96,8 +103,7 @@ function onAllMethods(owner, callback) {
|
|
|
96
103
|
while (proto && proto !== Object.prototype) {
|
|
97
104
|
for (const method of Object.getOwnPropertyNames(proto)) {
|
|
98
105
|
if (method === "constructor") continue;
|
|
99
|
-
if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value))
|
|
100
|
-
callback(method, owner);
|
|
106
|
+
if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
|
|
101
107
|
}
|
|
102
108
|
proto = Object.getPrototypeOf(proto);
|
|
103
109
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t007/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
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",
|
|
@@ -43,8 +43,5 @@
|
|
|
43
43
|
"dom-manipulation",
|
|
44
44
|
"shared-logic",
|
|
45
45
|
"performance"
|
|
46
|
-
]
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"sia-reactor": "^0.0.12"
|
|
49
|
-
}
|
|
46
|
+
]
|
|
50
47
|
}
|