@ntnyq/utils 0.11.1 → 0.11.3
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.d.ts +18 -2
- package/dist/index.js +29 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ declare const NOOP: typeof noop;
|
|
|
25
25
|
* initialize() // Logs: 'Initialized', returns true
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
declare function once<T extends unknown[]>(func: (...args: T) => void): (
|
|
28
|
+
declare function once<T extends unknown[]>(func: (...args: T) => void): (...args: T) => boolean;
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/is/dom.d.ts
|
|
31
31
|
/**
|
|
@@ -89,6 +89,14 @@ type UrlString = string & {
|
|
|
89
89
|
};
|
|
90
90
|
declare function isUrlString(value: unknown): value is UrlString;
|
|
91
91
|
//#endregion
|
|
92
|
+
//#region src/is/isAllEmpty.d.ts
|
|
93
|
+
/**
|
|
94
|
+
* Check if value is empty
|
|
95
|
+
* @param value - The value to check
|
|
96
|
+
* @returns True if the value is `null`, `undefined`, empty string, empty array, empty object, empty set, empty map, false otherwise
|
|
97
|
+
*/
|
|
98
|
+
declare function isAllEmpty(value: unknown): boolean;
|
|
99
|
+
//#endregion
|
|
92
100
|
//#region src/is/isDeepEqual.d.ts
|
|
93
101
|
/**
|
|
94
102
|
* check if two values are deeply equal
|
|
@@ -742,6 +750,14 @@ interface ToIntegerOptions {
|
|
|
742
750
|
*/
|
|
743
751
|
declare function toInteger(value: unknown, options?: ToIntegerOptions): number;
|
|
744
752
|
//#endregion
|
|
753
|
+
//#region src/number/toNumber.d.ts
|
|
754
|
+
/**
|
|
755
|
+
* Converts `value` to a number.
|
|
756
|
+
* @param value The value to process.
|
|
757
|
+
* @returns Returns the number.
|
|
758
|
+
*/
|
|
759
|
+
declare function toNumber(value: string | number): number;
|
|
760
|
+
//#endregion
|
|
745
761
|
//#region src/object/omit.d.ts
|
|
746
762
|
declare function omit<T, K extends keyof T>(object: T, ...keys: K[]): Omit<T, K>;
|
|
747
763
|
//#endregion
|
|
@@ -1001,4 +1017,4 @@ declare const RE_LINE_COMMENT: RegExp;
|
|
|
1001
1017
|
*/
|
|
1002
1018
|
declare const RE_BLOCK_COMMENT: RegExp;
|
|
1003
1019
|
//#endregion
|
|
1004
|
-
export { AnyFn, Arrayable, Awaitable, Callable, CleanObjectOptions, Color, CreatePadStringOptions, DeepRequired, ElementOf, FlatTreeOptions, GetStringSimilarityOptions, InteropModuleDefault, JsonArray, JsonObject, JsonPrimitive, JsonValue, LiteralUnion, MayBe, Merge, NOOP, NonEmptyObject, NonEmptyString, Nullable, OpenExternalURLOptions, Overwrite, Prettify, PrettifyV2, Primitive, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, RamdomNumberOptions, ResolvedOptions, SPECIAL_CHAR, STORAGE_UNITS, SortObjectOptions, StorageUnit, TIME_UNITS, ThrottleDebounceOptions, TimeUnit, ToIntegerOptions, UrlString, ValueOf, Whitespace, at, cAF, chunk, clamp, cleanObject, convertFromBytes, convertFromMilliseconds, convertStorageUnit, convertTimeUnit, convertToBytes, convertToMilliseconds, createPadString, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, escapeStringRegexp, flatTree, flattenArrayable, getFileExtension, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBlob, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFile, isFormData, isFunction, isHTMLElement, isInteger, isIterable, isKeyOf, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isUrlString, isWhitespaceString, isZero, join, last, mergeArrayable, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, remove, removeFileExtension, resolveSubOptions, scrollElementIntoView, shuffle, slash, slugify, sortObject, throttle, toArray, toInteger, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce };
|
|
1020
|
+
export { AnyFn, Arrayable, Awaitable, Callable, CleanObjectOptions, Color, CreatePadStringOptions, DeepRequired, ElementOf, FlatTreeOptions, GetStringSimilarityOptions, InteropModuleDefault, JsonArray, JsonObject, JsonPrimitive, JsonValue, LiteralUnion, MayBe, Merge, NOOP, NonEmptyObject, NonEmptyString, Nullable, OpenExternalURLOptions, Overwrite, Prettify, PrettifyV2, Primitive, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, RamdomNumberOptions, ResolvedOptions, SPECIAL_CHAR, STORAGE_UNITS, SortObjectOptions, StorageUnit, TIME_UNITS, ThrottleDebounceOptions, TimeUnit, ToIntegerOptions, UrlString, ValueOf, Whitespace, at, cAF, chunk, clamp, cleanObject, convertFromBytes, convertFromMilliseconds, convertStorageUnit, convertTimeUnit, convertToBytes, convertToMilliseconds, createPadString, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, escapeStringRegexp, flatTree, flattenArrayable, getFileExtension, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, interopDefault, intersect, isAllEmpty, isArray, isArrayEqual, isBigInt, isBlob, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFile, isFormData, isFunction, isHTMLElement, isInteger, isIterable, isKeyOf, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isUrlString, isWhitespaceString, isZero, join, last, mergeArrayable, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, remove, removeFileExtension, resolveSubOptions, scrollElementIntoView, shuffle, slash, slugify, sortObject, throttle, toArray, toInteger, toNumber, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce };
|
package/dist/index.js
CHANGED
|
@@ -182,6 +182,17 @@ function isUrlString(value) {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
//#endregion
|
|
185
|
+
//#region src/is/isAllEmpty.ts
|
|
186
|
+
/**
|
|
187
|
+
* Check if value is empty
|
|
188
|
+
* @param value - The value to check
|
|
189
|
+
* @returns True if the value is `null`, `undefined`, empty string, empty array, empty object, empty set, empty map, false otherwise
|
|
190
|
+
*/
|
|
191
|
+
function isAllEmpty(value) {
|
|
192
|
+
if (isNull(value) || isUndefined(value) || isEmptyString(value) || isEmptyArray(value) || isEmptySet(value) || isEmptyMap(value) || isEmptyObject(value)) return true;
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
185
196
|
//#region src/is/isDeepEqual.ts
|
|
186
197
|
/**
|
|
187
198
|
* check if two values are deeply equal
|
|
@@ -692,6 +703,23 @@ function toInteger(value, options = {}) {
|
|
|
692
703
|
return result;
|
|
693
704
|
}
|
|
694
705
|
//#endregion
|
|
706
|
+
//#region src/number/toNumber.ts
|
|
707
|
+
/**
|
|
708
|
+
* Converts `value` to a number.
|
|
709
|
+
* @param value The value to process.
|
|
710
|
+
* @returns Returns the number.
|
|
711
|
+
*/
|
|
712
|
+
function toNumber(value) {
|
|
713
|
+
if (!isString(value) && !isNumber(value)) throw new TypeError(`Expected a string or number, got ${typeof value}`);
|
|
714
|
+
if (isNaN(value)) throw new TypeError(`Expected a valid number, got NaN`);
|
|
715
|
+
if (isString(value)) {
|
|
716
|
+
const result = Number.parseFloat(value);
|
|
717
|
+
if (isNaN(result)) throw new TypeError(`Expected a valid number, got NaN`);
|
|
718
|
+
return result;
|
|
719
|
+
}
|
|
720
|
+
return value;
|
|
721
|
+
}
|
|
722
|
+
//#endregion
|
|
695
723
|
//#region src/array/shuffle.ts
|
|
696
724
|
/**
|
|
697
725
|
* Fisher–Yates shuffle
|
|
@@ -1235,4 +1263,4 @@ const RE_LINE_COMMENT = /\/\/.*/;
|
|
|
1235
1263
|
*/
|
|
1236
1264
|
const RE_BLOCK_COMMENT = /\/\*[\s\S]*?\*\//g;
|
|
1237
1265
|
//#endregion
|
|
1238
|
-
export { Color, NOOP, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, SPECIAL_CHAR, STORAGE_UNITS, TIME_UNITS, at, cAF, chunk, clamp, cleanObject, convertFromBytes, convertFromMilliseconds, convertStorageUnit, convertTimeUnit, convertToBytes, convertToMilliseconds, createPadString, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, escapeStringRegexp, flatTree, flattenArrayable, getFileExtension, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBlob, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFile, isFormData, isFunction, isHTMLElement, isInteger, isIterable, isKeyOf, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isUrlString, isWhitespaceString, isZero, join, last, mergeArrayable, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, remove, removeFileExtension, resolveSubOptions, scrollElementIntoView, shuffle, slash, slugify, sortObject, throttle, toArray, toInteger, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce };
|
|
1266
|
+
export { Color, NOOP, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, SPECIAL_CHAR, STORAGE_UNITS, TIME_UNITS, at, cAF, chunk, clamp, cleanObject, convertFromBytes, convertFromMilliseconds, convertStorageUnit, convertTimeUnit, convertToBytes, convertToMilliseconds, createPadString, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, escapeStringRegexp, flatTree, flattenArrayable, getFileExtension, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, interopDefault, intersect, isAllEmpty, isArray, isArrayEqual, isBigInt, isBlob, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFile, isFormData, isFunction, isHTMLElement, isInteger, isIterable, isKeyOf, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isUrlString, isWhitespaceString, isZero, join, last, mergeArrayable, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, remove, removeFileExtension, resolveSubOptions, scrollElementIntoView, shuffle, slash, slugify, sortObject, throttle, toArray, toInteger, toNumber, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntnyq/utils",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "Common used utils.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"utils"
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@ntnyq/tsconfig": "^3.1.0",
|
|
34
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
34
|
+
"@typescript/native-preview": "^7.0.0-dev.20260329.1",
|
|
35
35
|
"bumpp": "^11.0.1",
|
|
36
36
|
"husky": "^9.1.7",
|
|
37
37
|
"nano-staged": "^0.9.0",
|
|
38
38
|
"npm-run-all2": "^8.0.4",
|
|
39
|
-
"oxfmt": "^0.
|
|
40
|
-
"oxlint": "^1.
|
|
41
|
-
"tsdown": "^0.21.
|
|
42
|
-
"vitest": "^4.1.
|
|
39
|
+
"oxfmt": "^0.42.0",
|
|
40
|
+
"oxlint": "^1.57.0",
|
|
41
|
+
"tsdown": "^0.21.7",
|
|
42
|
+
"vitest": "^4.1.2"
|
|
43
43
|
},
|
|
44
44
|
"nano-staged": {
|
|
45
45
|
"*.{js,ts,mjs,tsx}": "oxlint --fix",
|