@ntnyq/utils 0.6.3 → 0.6.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.
- package/dist/index.cjs +34 -27
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +33 -27
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,7 @@ __export(index_exports, {
|
|
|
59
59
|
isEmptyStringOrWhitespace: () => isEmptyStringOrWhitespace,
|
|
60
60
|
isError: () => isError,
|
|
61
61
|
isFunction: () => isFunction,
|
|
62
|
+
isHTMLElement: () => isHTMLElement,
|
|
62
63
|
isInteger: () => isInteger,
|
|
63
64
|
isIterable: () => isIterable,
|
|
64
65
|
isMap: () => isMap,
|
|
@@ -131,35 +132,12 @@ function once(func) {
|
|
|
131
132
|
};
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
// src/is/
|
|
135
|
-
function
|
|
136
|
-
|
|
137
|
-
const type2 = getObjectType(value2);
|
|
138
|
-
if (type1 !== type2) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
if (isArray(value1) && isArray(value2)) {
|
|
142
|
-
if (value1.length !== value2.length) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
return value1.every((item, index) => isDeepEqual(item, value2[index]));
|
|
146
|
-
}
|
|
147
|
-
if (isObject(value1) && isObject(value2)) {
|
|
148
|
-
const keys = Object.keys(value1);
|
|
149
|
-
if (keys.length !== Object.keys(value2).length) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
return keys.every(
|
|
153
|
-
(key) => isDeepEqual(
|
|
154
|
-
value1[key],
|
|
155
|
-
value2[key]
|
|
156
|
-
)
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
return Object.is(value1, value2);
|
|
135
|
+
// src/is/dom.ts
|
|
136
|
+
function isHTMLElement(value) {
|
|
137
|
+
return typeof value === "object" && value !== null && "nodeType" in value && value.nodeType === Node.ELEMENT_NODE && value instanceof HTMLElement;
|
|
160
138
|
}
|
|
161
139
|
|
|
162
|
-
// src/is/
|
|
140
|
+
// src/is/core.ts
|
|
163
141
|
function getObjectType(value) {
|
|
164
142
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
165
143
|
}
|
|
@@ -264,6 +242,34 @@ function isIterable(value) {
|
|
|
264
242
|
return isFunction(value?.[Symbol.iterator]);
|
|
265
243
|
}
|
|
266
244
|
|
|
245
|
+
// src/is/isDeepEqual.ts
|
|
246
|
+
function isDeepEqual(value1, value2) {
|
|
247
|
+
const type1 = getObjectType(value1);
|
|
248
|
+
const type2 = getObjectType(value2);
|
|
249
|
+
if (type1 !== type2) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
if (isArray(value1) && isArray(value2)) {
|
|
253
|
+
if (value1.length !== value2.length) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
return value1.every((item, index) => isDeepEqual(item, value2[index]));
|
|
257
|
+
}
|
|
258
|
+
if (isObject(value1) && isObject(value2)) {
|
|
259
|
+
const keys = Object.keys(value1);
|
|
260
|
+
if (keys.length !== Object.keys(value2).length) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
return keys.every(
|
|
264
|
+
(key) => isDeepEqual(
|
|
265
|
+
value1[key],
|
|
266
|
+
value2[key]
|
|
267
|
+
)
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
return Object.is(value1, value2);
|
|
271
|
+
}
|
|
272
|
+
|
|
267
273
|
// src/dom/scrollIntoView.ts
|
|
268
274
|
function scrollElementIntoView(element, options = {}) {
|
|
269
275
|
const body = document.body;
|
|
@@ -867,6 +873,7 @@ var RE_BLOCK_COMMENT = /\/\*[\s\S]*?\*\//g;
|
|
|
867
873
|
isEmptyStringOrWhitespace,
|
|
868
874
|
isError,
|
|
869
875
|
isFunction,
|
|
876
|
+
isHTMLElement,
|
|
870
877
|
isInteger,
|
|
871
878
|
isIterable,
|
|
872
879
|
isMap,
|
package/dist/index.d.cts
CHANGED
|
@@ -10,9 +10,14 @@ declare const NOOP: typeof noop;
|
|
|
10
10
|
declare function once<T extends unknown[]>(func: (...args: T) => void): (this: unknown, ...args: T) => boolean;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* @file is/dom.ts
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Check if given value is an HTMLElement
|
|
17
|
+
* @param value - The value to check
|
|
18
|
+
* @returns True if the value is an HTMLElement, false otherwise
|
|
19
|
+
*/
|
|
20
|
+
declare function isHTMLElement(value: unknown): value is HTMLElement;
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
* @file is utils
|
|
@@ -57,6 +62,11 @@ declare function isNativePromise<T = unknown>(value: unknown): value is Promise<
|
|
|
57
62
|
declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
58
63
|
declare function isIterable<T = unknown>(value: unknown): value is Iterable<T>;
|
|
59
64
|
|
|
65
|
+
/**
|
|
66
|
+
* check if two values are deeply equal
|
|
67
|
+
*/
|
|
68
|
+
declare function isDeepEqual(value1: any, value2: any): boolean;
|
|
69
|
+
|
|
60
70
|
interface Options extends ScrollIntoViewOptions {
|
|
61
71
|
/**
|
|
62
72
|
* @default `document.body`
|
|
@@ -608,4 +618,4 @@ declare const RE_LINE_COMMENT: RegExp;
|
|
|
608
618
|
*/
|
|
609
619
|
declare const RE_BLOCK_COMMENT: RegExp;
|
|
610
620
|
|
|
611
|
-
export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, Color, type CreatePadStringOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type LiteralUnion, type MayBe, NOOP, type NonEmptyObject, type NonEmptyString, type Nullable, type OpenExternalURLOptions, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, type RamdomNumberOptions, type ResolvedOptions, SPECIAL_CHAR, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, scrollElementIntoView, seconds, slash, slugify, sortObject, throttle, toArray, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
|
|
621
|
+
export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, Color, type CreatePadStringOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type LiteralUnion, type MayBe, NOOP, type NonEmptyObject, type NonEmptyString, type Nullable, type OpenExternalURLOptions, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, type RamdomNumberOptions, type ResolvedOptions, SPECIAL_CHAR, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isHTMLElement, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, scrollElementIntoView, seconds, slash, slugify, sortObject, throttle, toArray, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,9 +10,14 @@ declare const NOOP: typeof noop;
|
|
|
10
10
|
declare function once<T extends unknown[]>(func: (...args: T) => void): (this: unknown, ...args: T) => boolean;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* @file is/dom.ts
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Check if given value is an HTMLElement
|
|
17
|
+
* @param value - The value to check
|
|
18
|
+
* @returns True if the value is an HTMLElement, false otherwise
|
|
19
|
+
*/
|
|
20
|
+
declare function isHTMLElement(value: unknown): value is HTMLElement;
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
* @file is utils
|
|
@@ -57,6 +62,11 @@ declare function isNativePromise<T = unknown>(value: unknown): value is Promise<
|
|
|
57
62
|
declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
58
63
|
declare function isIterable<T = unknown>(value: unknown): value is Iterable<T>;
|
|
59
64
|
|
|
65
|
+
/**
|
|
66
|
+
* check if two values are deeply equal
|
|
67
|
+
*/
|
|
68
|
+
declare function isDeepEqual(value1: any, value2: any): boolean;
|
|
69
|
+
|
|
60
70
|
interface Options extends ScrollIntoViewOptions {
|
|
61
71
|
/**
|
|
62
72
|
* @default `document.body`
|
|
@@ -608,4 +618,4 @@ declare const RE_LINE_COMMENT: RegExp;
|
|
|
608
618
|
*/
|
|
609
619
|
declare const RE_BLOCK_COMMENT: RegExp;
|
|
610
620
|
|
|
611
|
-
export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, Color, type CreatePadStringOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type LiteralUnion, type MayBe, NOOP, type NonEmptyObject, type NonEmptyString, type Nullable, type OpenExternalURLOptions, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, type RamdomNumberOptions, type ResolvedOptions, SPECIAL_CHAR, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, scrollElementIntoView, seconds, slash, slugify, sortObject, throttle, toArray, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
|
|
621
|
+
export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, Color, type CreatePadStringOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type LiteralUnion, type MayBe, NOOP, type NonEmptyObject, type NonEmptyString, type Nullable, type OpenExternalURLOptions, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, type RamdomNumberOptions, type ResolvedOptions, SPECIAL_CHAR, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isHTMLElement, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, scrollElementIntoView, seconds, slash, slugify, sortObject, throttle, toArray, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
|
package/dist/index.js
CHANGED
|
@@ -16,35 +16,12 @@ function once(func) {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// src/is/
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
const type2 = getObjectType(value2);
|
|
23
|
-
if (type1 !== type2) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
if (isArray(value1) && isArray(value2)) {
|
|
27
|
-
if (value1.length !== value2.length) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return value1.every((item, index) => isDeepEqual(item, value2[index]));
|
|
31
|
-
}
|
|
32
|
-
if (isObject(value1) && isObject(value2)) {
|
|
33
|
-
const keys = Object.keys(value1);
|
|
34
|
-
if (keys.length !== Object.keys(value2).length) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
return keys.every(
|
|
38
|
-
(key) => isDeepEqual(
|
|
39
|
-
value1[key],
|
|
40
|
-
value2[key]
|
|
41
|
-
)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
return Object.is(value1, value2);
|
|
19
|
+
// src/is/dom.ts
|
|
20
|
+
function isHTMLElement(value) {
|
|
21
|
+
return typeof value === "object" && value !== null && "nodeType" in value && value.nodeType === Node.ELEMENT_NODE && value instanceof HTMLElement;
|
|
45
22
|
}
|
|
46
23
|
|
|
47
|
-
// src/is/
|
|
24
|
+
// src/is/core.ts
|
|
48
25
|
function getObjectType(value) {
|
|
49
26
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
50
27
|
}
|
|
@@ -149,6 +126,34 @@ function isIterable(value) {
|
|
|
149
126
|
return isFunction(value?.[Symbol.iterator]);
|
|
150
127
|
}
|
|
151
128
|
|
|
129
|
+
// src/is/isDeepEqual.ts
|
|
130
|
+
function isDeepEqual(value1, value2) {
|
|
131
|
+
const type1 = getObjectType(value1);
|
|
132
|
+
const type2 = getObjectType(value2);
|
|
133
|
+
if (type1 !== type2) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (isArray(value1) && isArray(value2)) {
|
|
137
|
+
if (value1.length !== value2.length) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return value1.every((item, index) => isDeepEqual(item, value2[index]));
|
|
141
|
+
}
|
|
142
|
+
if (isObject(value1) && isObject(value2)) {
|
|
143
|
+
const keys = Object.keys(value1);
|
|
144
|
+
if (keys.length !== Object.keys(value2).length) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
return keys.every(
|
|
148
|
+
(key) => isDeepEqual(
|
|
149
|
+
value1[key],
|
|
150
|
+
value2[key]
|
|
151
|
+
)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
return Object.is(value1, value2);
|
|
155
|
+
}
|
|
156
|
+
|
|
152
157
|
// src/dom/scrollIntoView.ts
|
|
153
158
|
function scrollElementIntoView(element, options = {}) {
|
|
154
159
|
const body = document.body;
|
|
@@ -751,6 +756,7 @@ export {
|
|
|
751
756
|
isEmptyStringOrWhitespace,
|
|
752
757
|
isError,
|
|
753
758
|
isFunction,
|
|
759
|
+
isHTMLElement,
|
|
754
760
|
isInteger,
|
|
755
761
|
isIterable,
|
|
756
762
|
isMap,
|