@ntnyq/utils 0.1.1 → 0.1.2
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 +60 -0
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +49 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,8 +26,19 @@ __export(src_exports, {
|
|
|
26
26
|
capitalize: () => capitalize,
|
|
27
27
|
days: () => days,
|
|
28
28
|
flatCase: () => flatCase,
|
|
29
|
+
getObjectType: () => getObjectType,
|
|
29
30
|
hours: () => hours,
|
|
31
|
+
isArray: () => isArray,
|
|
32
|
+
isBoolean: () => isBoolean,
|
|
30
33
|
isBrowser: () => isBrowser,
|
|
34
|
+
isFunction: () => isFunction,
|
|
35
|
+
isInteger: () => isInteger,
|
|
36
|
+
isNativePromise: () => isNativePromise,
|
|
37
|
+
isNull: () => isNull,
|
|
38
|
+
isNumber: () => isNumber,
|
|
39
|
+
isPromise: () => isPromise,
|
|
40
|
+
isString: () => isString,
|
|
41
|
+
isUndefined: () => isUndefined,
|
|
31
42
|
isUppercase: () => isUppercase,
|
|
32
43
|
join: () => join,
|
|
33
44
|
kebabCase: () => kebabCase,
|
|
@@ -51,6 +62,44 @@ __export(src_exports, {
|
|
|
51
62
|
});
|
|
52
63
|
module.exports = __toCommonJS(src_exports);
|
|
53
64
|
|
|
65
|
+
// src/is/index.ts
|
|
66
|
+
function getObjectType(value) {
|
|
67
|
+
return Object.prototype.toString.call(value).slice(8, -1);
|
|
68
|
+
}
|
|
69
|
+
function isString(value) {
|
|
70
|
+
return typeof value === "string";
|
|
71
|
+
}
|
|
72
|
+
function isNumber(value) {
|
|
73
|
+
return typeof value === "number";
|
|
74
|
+
}
|
|
75
|
+
function isInteger(value) {
|
|
76
|
+
return Number.isInteger(value);
|
|
77
|
+
}
|
|
78
|
+
function isBoolean(value) {
|
|
79
|
+
return typeof value === "boolean";
|
|
80
|
+
}
|
|
81
|
+
function isFunction(value) {
|
|
82
|
+
return typeof value === "function";
|
|
83
|
+
}
|
|
84
|
+
function isArray(value) {
|
|
85
|
+
return Array.isArray(value);
|
|
86
|
+
}
|
|
87
|
+
function isUndefined(value) {
|
|
88
|
+
return value === void 0;
|
|
89
|
+
}
|
|
90
|
+
function isNull(value) {
|
|
91
|
+
return value === null;
|
|
92
|
+
}
|
|
93
|
+
function isNativePromise(value) {
|
|
94
|
+
return getObjectType(value) === "Promise";
|
|
95
|
+
}
|
|
96
|
+
function hasPromiseApi(value) {
|
|
97
|
+
return isFunction(value?.then) && isFunction(value?.catch);
|
|
98
|
+
}
|
|
99
|
+
function isPromise(value) {
|
|
100
|
+
return isNativePromise(value) || hasPromiseApi(value);
|
|
101
|
+
}
|
|
102
|
+
|
|
54
103
|
// src/fn/noop.ts
|
|
55
104
|
var noop = () => {
|
|
56
105
|
};
|
|
@@ -232,8 +281,19 @@ function join(array, options = {}) {
|
|
|
232
281
|
capitalize,
|
|
233
282
|
days,
|
|
234
283
|
flatCase,
|
|
284
|
+
getObjectType,
|
|
235
285
|
hours,
|
|
286
|
+
isArray,
|
|
287
|
+
isBoolean,
|
|
236
288
|
isBrowser,
|
|
289
|
+
isFunction,
|
|
290
|
+
isInteger,
|
|
291
|
+
isNativePromise,
|
|
292
|
+
isNull,
|
|
293
|
+
isNumber,
|
|
294
|
+
isPromise,
|
|
295
|
+
isString,
|
|
296
|
+
isUndefined,
|
|
237
297
|
isUppercase,
|
|
238
298
|
join,
|
|
239
299
|
kebabCase,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { upperFirst } from 'scule';
|
|
2
2
|
export * from 'scule';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @file is utils
|
|
6
|
+
* @category is
|
|
7
|
+
* @copyright {@link https://github.com/sindresorhus/is}
|
|
8
|
+
*/
|
|
9
|
+
declare function getObjectType(value: unknown): string;
|
|
10
|
+
declare function isString(value: unknown): value is string;
|
|
11
|
+
declare function isNumber(value: unknown): value is number;
|
|
12
|
+
declare function isInteger(value: unknown): value is number;
|
|
13
|
+
declare function isBoolean(value: unknown): value is boolean;
|
|
14
|
+
declare function isFunction(value: unknown): value is Function;
|
|
15
|
+
declare function isArray(value: unknown): value is unknown[];
|
|
16
|
+
declare function isUndefined(value: unknown): value is undefined;
|
|
17
|
+
declare function isNull(value: unknown): value is null;
|
|
18
|
+
declare function isNativePromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
19
|
+
declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
20
|
+
|
|
4
21
|
/**
|
|
5
22
|
* A function that does nothing.
|
|
6
23
|
*/
|
|
@@ -117,4 +134,4 @@ interface JoinOptions {
|
|
|
117
134
|
*/
|
|
118
135
|
declare function join(array: JoinableValue[], options?: JoinOptions): string;
|
|
119
136
|
|
|
120
|
-
export { type AnyFn, type Arrayable, type Awaitable, type MayBe, NOOP, type Nullable, type Prettify, cAF, capitalize, days, hours, isBrowser, join, minutes, noop, rAF, seconds, toArray, unique, uniqueBy, waitFor, warnOnce, weeks };
|
|
137
|
+
export { type AnyFn, type Arrayable, type Awaitable, type MayBe, NOOP, type Nullable, type Prettify, cAF, capitalize, days, getObjectType, hours, isArray, isBoolean, isBrowser, isFunction, isInteger, isNativePromise, isNull, isNumber, isPromise, isString, isUndefined, join, minutes, noop, rAF, seconds, toArray, unique, uniqueBy, waitFor, warnOnce, weeks };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { upperFirst } from 'scule';
|
|
2
2
|
export * from 'scule';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @file is utils
|
|
6
|
+
* @category is
|
|
7
|
+
* @copyright {@link https://github.com/sindresorhus/is}
|
|
8
|
+
*/
|
|
9
|
+
declare function getObjectType(value: unknown): string;
|
|
10
|
+
declare function isString(value: unknown): value is string;
|
|
11
|
+
declare function isNumber(value: unknown): value is number;
|
|
12
|
+
declare function isInteger(value: unknown): value is number;
|
|
13
|
+
declare function isBoolean(value: unknown): value is boolean;
|
|
14
|
+
declare function isFunction(value: unknown): value is Function;
|
|
15
|
+
declare function isArray(value: unknown): value is unknown[];
|
|
16
|
+
declare function isUndefined(value: unknown): value is undefined;
|
|
17
|
+
declare function isNull(value: unknown): value is null;
|
|
18
|
+
declare function isNativePromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
19
|
+
declare function isPromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
20
|
+
|
|
4
21
|
/**
|
|
5
22
|
* A function that does nothing.
|
|
6
23
|
*/
|
|
@@ -117,4 +134,4 @@ interface JoinOptions {
|
|
|
117
134
|
*/
|
|
118
135
|
declare function join(array: JoinableValue[], options?: JoinOptions): string;
|
|
119
136
|
|
|
120
|
-
export { type AnyFn, type Arrayable, type Awaitable, type MayBe, NOOP, type Nullable, type Prettify, cAF, capitalize, days, hours, isBrowser, join, minutes, noop, rAF, seconds, toArray, unique, uniqueBy, waitFor, warnOnce, weeks };
|
|
137
|
+
export { type AnyFn, type Arrayable, type Awaitable, type MayBe, NOOP, type Nullable, type Prettify, cAF, capitalize, days, getObjectType, hours, isArray, isBoolean, isBrowser, isFunction, isInteger, isNativePromise, isNull, isNumber, isPromise, isString, isUndefined, join, minutes, noop, rAF, seconds, toArray, unique, uniqueBy, waitFor, warnOnce, weeks };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
// src/is/index.ts
|
|
2
|
+
function getObjectType(value) {
|
|
3
|
+
return Object.prototype.toString.call(value).slice(8, -1);
|
|
4
|
+
}
|
|
5
|
+
function isString(value) {
|
|
6
|
+
return typeof value === "string";
|
|
7
|
+
}
|
|
8
|
+
function isNumber(value) {
|
|
9
|
+
return typeof value === "number";
|
|
10
|
+
}
|
|
11
|
+
function isInteger(value) {
|
|
12
|
+
return Number.isInteger(value);
|
|
13
|
+
}
|
|
14
|
+
function isBoolean(value) {
|
|
15
|
+
return typeof value === "boolean";
|
|
16
|
+
}
|
|
17
|
+
function isFunction(value) {
|
|
18
|
+
return typeof value === "function";
|
|
19
|
+
}
|
|
20
|
+
function isArray(value) {
|
|
21
|
+
return Array.isArray(value);
|
|
22
|
+
}
|
|
23
|
+
function isUndefined(value) {
|
|
24
|
+
return value === void 0;
|
|
25
|
+
}
|
|
26
|
+
function isNull(value) {
|
|
27
|
+
return value === null;
|
|
28
|
+
}
|
|
29
|
+
function isNativePromise(value) {
|
|
30
|
+
return getObjectType(value) === "Promise";
|
|
31
|
+
}
|
|
32
|
+
function hasPromiseApi(value) {
|
|
33
|
+
return isFunction(value?.then) && isFunction(value?.catch);
|
|
34
|
+
}
|
|
35
|
+
function isPromise(value) {
|
|
36
|
+
return isNativePromise(value) || hasPromiseApi(value);
|
|
37
|
+
}
|
|
38
|
+
|
|
1
39
|
// src/fn/noop.ts
|
|
2
40
|
var noop = () => {
|
|
3
41
|
};
|
|
@@ -178,8 +216,19 @@ export {
|
|
|
178
216
|
capitalize,
|
|
179
217
|
days,
|
|
180
218
|
flatCase,
|
|
219
|
+
getObjectType,
|
|
181
220
|
hours,
|
|
221
|
+
isArray,
|
|
222
|
+
isBoolean,
|
|
182
223
|
isBrowser,
|
|
224
|
+
isFunction,
|
|
225
|
+
isInteger,
|
|
226
|
+
isNativePromise,
|
|
227
|
+
isNull,
|
|
228
|
+
isNumber,
|
|
229
|
+
isPromise,
|
|
230
|
+
isString,
|
|
231
|
+
isUndefined,
|
|
183
232
|
isUppercase,
|
|
184
233
|
join,
|
|
185
234
|
kebabCase,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntnyq/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"description": "Common used utils.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"utils"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@ntnyq/eslint-config": "^3.0.0-beta.17",
|
|
44
44
|
"@ntnyq/prettier-config": "^1.21.3",
|
|
45
45
|
"@vitest/coverage-v8": "^2.1.1",
|
|
46
|
-
"bumpp": "^9.
|
|
46
|
+
"bumpp": "^9.6.1",
|
|
47
47
|
"eslint": "^9.11.1",
|
|
48
48
|
"husky": "^9.1.6",
|
|
49
49
|
"nano-staged": "^0.8.0",
|