@ntnyq/utils 0.4.2 → 0.4.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 +25 -0
- package/dist/index.d.cts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +21 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -38,8 +38,10 @@ __export(index_exports, {
|
|
|
38
38
|
getObjectType: () => getObjectType,
|
|
39
39
|
hasOwn: () => hasOwn,
|
|
40
40
|
hours: () => hours,
|
|
41
|
+
interopDefault: () => interopDefault,
|
|
41
42
|
isArray: () => isArray,
|
|
42
43
|
isArrayEqual: () => isArrayEqual,
|
|
44
|
+
isBigInt: () => isBigInt,
|
|
43
45
|
isBoolean: () => isBoolean,
|
|
44
46
|
isBrowser: () => isBrowser,
|
|
45
47
|
isDeepEqual: () => isDeepEqual,
|
|
@@ -47,6 +49,7 @@ __export(index_exports, {
|
|
|
47
49
|
isEmptyObject: () => isEmptyObject,
|
|
48
50
|
isEmptyString: () => isEmptyString,
|
|
49
51
|
isEmptyStringOrWhitespace: () => isEmptyStringOrWhitespace,
|
|
52
|
+
isError: () => isError,
|
|
50
53
|
isFunction: () => isFunction,
|
|
51
54
|
isInteger: () => isInteger,
|
|
52
55
|
isNaN: () => isNaN,
|
|
@@ -77,6 +80,7 @@ __export(index_exports, {
|
|
|
77
80
|
pascalCase: () => pascalCase,
|
|
78
81
|
pick: () => pick,
|
|
79
82
|
rAF: () => rAF,
|
|
83
|
+
resolveSubOptions: () => resolveSubOptions,
|
|
80
84
|
seconds: () => seconds,
|
|
81
85
|
slash: () => slash,
|
|
82
86
|
snakeCase: () => snakeCase,
|
|
@@ -162,6 +166,9 @@ function isNumbericString(value) {
|
|
|
162
166
|
function isInteger(value) {
|
|
163
167
|
return Number.isInteger(value);
|
|
164
168
|
}
|
|
169
|
+
function isBigInt(value) {
|
|
170
|
+
return typeof value === "bigint";
|
|
171
|
+
}
|
|
165
172
|
function isBoolean(value) {
|
|
166
173
|
return typeof value === "boolean";
|
|
167
174
|
}
|
|
@@ -183,6 +190,9 @@ function isEmptyObject(value) {
|
|
|
183
190
|
function isRegExp(value) {
|
|
184
191
|
return getObjectType(value) === "RegExp";
|
|
185
192
|
}
|
|
193
|
+
function isError(value) {
|
|
194
|
+
return getObjectType(value) === "Error";
|
|
195
|
+
}
|
|
186
196
|
function isSet(value) {
|
|
187
197
|
return getObjectType(value) === "Set";
|
|
188
198
|
}
|
|
@@ -614,6 +624,17 @@ function titleCase(str, opts) {
|
|
|
614
624
|
|
|
615
625
|
// src/vendor/scule.ts
|
|
616
626
|
var capitalize = upperFirst;
|
|
627
|
+
|
|
628
|
+
// src/module/interopDefault.ts
|
|
629
|
+
async function interopDefault(mod) {
|
|
630
|
+
const resolved = await mod;
|
|
631
|
+
return resolved.default || resolved;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// src/module/resolveSubOptions.ts
|
|
635
|
+
function resolveSubOptions(options, key) {
|
|
636
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
637
|
+
}
|
|
617
638
|
// Annotate the CommonJS export names for ESM import in node:
|
|
618
639
|
0 && (module.exports = {
|
|
619
640
|
NOOP,
|
|
@@ -634,8 +655,10 @@ var capitalize = upperFirst;
|
|
|
634
655
|
getObjectType,
|
|
635
656
|
hasOwn,
|
|
636
657
|
hours,
|
|
658
|
+
interopDefault,
|
|
637
659
|
isArray,
|
|
638
660
|
isArrayEqual,
|
|
661
|
+
isBigInt,
|
|
639
662
|
isBoolean,
|
|
640
663
|
isBrowser,
|
|
641
664
|
isDeepEqual,
|
|
@@ -643,6 +666,7 @@ var capitalize = upperFirst;
|
|
|
643
666
|
isEmptyObject,
|
|
644
667
|
isEmptyString,
|
|
645
668
|
isEmptyStringOrWhitespace,
|
|
669
|
+
isError,
|
|
646
670
|
isFunction,
|
|
647
671
|
isInteger,
|
|
648
672
|
isNaN,
|
|
@@ -673,6 +697,7 @@ var capitalize = upperFirst;
|
|
|
673
697
|
pascalCase,
|
|
674
698
|
pick,
|
|
675
699
|
rAF,
|
|
700
|
+
resolveSubOptions,
|
|
676
701
|
seconds,
|
|
677
702
|
slash,
|
|
678
703
|
snakeCase,
|
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,7 @@ declare function isWhitespaceString(value: unknown): value is Whitespace;
|
|
|
29
29
|
declare function isEmptyStringOrWhitespace(value: unknown): value is '' | Whitespace;
|
|
30
30
|
declare function isNumbericString(value: unknown): value is `${number}`;
|
|
31
31
|
declare function isInteger(value: unknown): value is number;
|
|
32
|
+
declare function isBigInt(value: unknown): value is bigint;
|
|
32
33
|
declare function isBoolean(value: unknown): value is boolean;
|
|
33
34
|
declare function isFunction(value: unknown): value is Function;
|
|
34
35
|
declare function isArray(value: unknown): value is unknown[];
|
|
@@ -36,6 +37,7 @@ declare function isEmptyArray(value: unknown): value is [];
|
|
|
36
37
|
declare function isObject(value: unknown): value is object;
|
|
37
38
|
declare function isEmptyObject(value: unknown): value is {};
|
|
38
39
|
declare function isRegExp(value: unknown): value is RegExp;
|
|
40
|
+
declare function isError(value: unknown): value is Error;
|
|
39
41
|
declare function isSet<Value = unknown>(value: unknown): value is Set<Value>;
|
|
40
42
|
declare function isNativePromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
41
43
|
declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
@@ -375,4 +377,49 @@ declare function sortObject<T extends Record<string, any>>(obj: T, options?: Sor
|
|
|
375
377
|
*/
|
|
376
378
|
declare const capitalize: typeof upperFirst;
|
|
377
379
|
|
|
378
|
-
|
|
380
|
+
/**
|
|
381
|
+
* Interop default export from a module
|
|
382
|
+
*
|
|
383
|
+
* @param mod - The module
|
|
384
|
+
* @returns The default export
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
*
|
|
388
|
+
* ```ts
|
|
389
|
+
* import { interopDefault } from '@ntnyq/utils'
|
|
390
|
+
*
|
|
391
|
+
* const { unindent } = await interopDefault(import('@ntnyq/utils'))
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
declare function interopDefault<T>(mod: Awaitable<T>): Promise<InteropModuleDefault<T>>;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Resolve sub options `boolean | Options` to `Options`
|
|
398
|
+
* @param options - core options
|
|
399
|
+
* @param key - sub options key
|
|
400
|
+
* @returns resolved sub options
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
*
|
|
404
|
+
* ```ts
|
|
405
|
+
* import { resolveSubOptions } from '@ntnyq/utils'
|
|
406
|
+
*
|
|
407
|
+
* interface Options {
|
|
408
|
+
* compile?: boolean | {
|
|
409
|
+
* include?: string[]
|
|
410
|
+
* exclude?: string[]
|
|
411
|
+
* }
|
|
412
|
+
* }
|
|
413
|
+
*
|
|
414
|
+
* const options: Options = {
|
|
415
|
+
* compile: true
|
|
416
|
+
* }
|
|
417
|
+
*
|
|
418
|
+
* console.log(resolveSubOptions(options, 'compile'))
|
|
419
|
+
*
|
|
420
|
+
* // => {}
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
declare function resolveSubOptions<T extends Record<string, any>, K extends keyof T>(options: T, key: K): Partial<ResolvedOptions<T[K]>>;
|
|
424
|
+
|
|
425
|
+
export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type MayBe, NOOP, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, cleanObject, days, debounce, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyObject, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isInteger, isNaN, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, resolveSubOptions, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare function isWhitespaceString(value: unknown): value is Whitespace;
|
|
|
29
29
|
declare function isEmptyStringOrWhitespace(value: unknown): value is '' | Whitespace;
|
|
30
30
|
declare function isNumbericString(value: unknown): value is `${number}`;
|
|
31
31
|
declare function isInteger(value: unknown): value is number;
|
|
32
|
+
declare function isBigInt(value: unknown): value is bigint;
|
|
32
33
|
declare function isBoolean(value: unknown): value is boolean;
|
|
33
34
|
declare function isFunction(value: unknown): value is Function;
|
|
34
35
|
declare function isArray(value: unknown): value is unknown[];
|
|
@@ -36,6 +37,7 @@ declare function isEmptyArray(value: unknown): value is [];
|
|
|
36
37
|
declare function isObject(value: unknown): value is object;
|
|
37
38
|
declare function isEmptyObject(value: unknown): value is {};
|
|
38
39
|
declare function isRegExp(value: unknown): value is RegExp;
|
|
40
|
+
declare function isError(value: unknown): value is Error;
|
|
39
41
|
declare function isSet<Value = unknown>(value: unknown): value is Set<Value>;
|
|
40
42
|
declare function isNativePromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
41
43
|
declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
@@ -375,4 +377,49 @@ declare function sortObject<T extends Record<string, any>>(obj: T, options?: Sor
|
|
|
375
377
|
*/
|
|
376
378
|
declare const capitalize: typeof upperFirst;
|
|
377
379
|
|
|
378
|
-
|
|
380
|
+
/**
|
|
381
|
+
* Interop default export from a module
|
|
382
|
+
*
|
|
383
|
+
* @param mod - The module
|
|
384
|
+
* @returns The default export
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
*
|
|
388
|
+
* ```ts
|
|
389
|
+
* import { interopDefault } from '@ntnyq/utils'
|
|
390
|
+
*
|
|
391
|
+
* const { unindent } = await interopDefault(import('@ntnyq/utils'))
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
declare function interopDefault<T>(mod: Awaitable<T>): Promise<InteropModuleDefault<T>>;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Resolve sub options `boolean | Options` to `Options`
|
|
398
|
+
* @param options - core options
|
|
399
|
+
* @param key - sub options key
|
|
400
|
+
* @returns resolved sub options
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
*
|
|
404
|
+
* ```ts
|
|
405
|
+
* import { resolveSubOptions } from '@ntnyq/utils'
|
|
406
|
+
*
|
|
407
|
+
* interface Options {
|
|
408
|
+
* compile?: boolean | {
|
|
409
|
+
* include?: string[]
|
|
410
|
+
* exclude?: string[]
|
|
411
|
+
* }
|
|
412
|
+
* }
|
|
413
|
+
*
|
|
414
|
+
* const options: Options = {
|
|
415
|
+
* compile: true
|
|
416
|
+
* }
|
|
417
|
+
*
|
|
418
|
+
* console.log(resolveSubOptions(options, 'compile'))
|
|
419
|
+
*
|
|
420
|
+
* // => {}
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
declare function resolveSubOptions<T extends Record<string, any>, K extends keyof T>(options: T, key: K): Partial<ResolvedOptions<T[K]>>;
|
|
424
|
+
|
|
425
|
+
export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type MayBe, NOOP, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, cleanObject, days, debounce, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyObject, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isInteger, isNaN, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, resolveSubOptions, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,9 @@ function isNumbericString(value) {
|
|
|
64
64
|
function isInteger(value) {
|
|
65
65
|
return Number.isInteger(value);
|
|
66
66
|
}
|
|
67
|
+
function isBigInt(value) {
|
|
68
|
+
return typeof value === "bigint";
|
|
69
|
+
}
|
|
67
70
|
function isBoolean(value) {
|
|
68
71
|
return typeof value === "boolean";
|
|
69
72
|
}
|
|
@@ -85,6 +88,9 @@ function isEmptyObject(value) {
|
|
|
85
88
|
function isRegExp(value) {
|
|
86
89
|
return getObjectType(value) === "RegExp";
|
|
87
90
|
}
|
|
91
|
+
function isError(value) {
|
|
92
|
+
return getObjectType(value) === "Error";
|
|
93
|
+
}
|
|
88
94
|
function isSet(value) {
|
|
89
95
|
return getObjectType(value) === "Set";
|
|
90
96
|
}
|
|
@@ -516,6 +522,17 @@ function titleCase(str, opts) {
|
|
|
516
522
|
|
|
517
523
|
// src/vendor/scule.ts
|
|
518
524
|
var capitalize = upperFirst;
|
|
525
|
+
|
|
526
|
+
// src/module/interopDefault.ts
|
|
527
|
+
async function interopDefault(mod) {
|
|
528
|
+
const resolved = await mod;
|
|
529
|
+
return resolved.default || resolved;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// src/module/resolveSubOptions.ts
|
|
533
|
+
function resolveSubOptions(options, key) {
|
|
534
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
535
|
+
}
|
|
519
536
|
export {
|
|
520
537
|
NOOP,
|
|
521
538
|
at,
|
|
@@ -535,8 +552,10 @@ export {
|
|
|
535
552
|
getObjectType,
|
|
536
553
|
hasOwn,
|
|
537
554
|
hours,
|
|
555
|
+
interopDefault,
|
|
538
556
|
isArray,
|
|
539
557
|
isArrayEqual,
|
|
558
|
+
isBigInt,
|
|
540
559
|
isBoolean,
|
|
541
560
|
isBrowser,
|
|
542
561
|
isDeepEqual,
|
|
@@ -544,6 +563,7 @@ export {
|
|
|
544
563
|
isEmptyObject,
|
|
545
564
|
isEmptyString,
|
|
546
565
|
isEmptyStringOrWhitespace,
|
|
566
|
+
isError,
|
|
547
567
|
isFunction,
|
|
548
568
|
isInteger,
|
|
549
569
|
isNaN,
|
|
@@ -574,6 +594,7 @@ export {
|
|
|
574
594
|
pascalCase,
|
|
575
595
|
pick,
|
|
576
596
|
rAF,
|
|
597
|
+
resolveSubOptions,
|
|
577
598
|
seconds,
|
|
578
599
|
slash,
|
|
579
600
|
snakeCase,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntnyq/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"description": "Common used utils.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"utils"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"scule": "^1.3.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@ntnyq/eslint-config": "^3.10.
|
|
43
|
+
"@ntnyq/eslint-config": "^3.10.4",
|
|
44
44
|
"@ntnyq/prettier-config": "^1.22.0",
|
|
45
45
|
"@vitest/coverage-v8": "^3.0.0-beta.3",
|
|
46
46
|
"bumpp": "^9.9.2",
|