jz-toolkit 1.0.0

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.
Files changed (86) hide show
  1. package/README.md +194 -0
  2. package/dist/array/chunk.d.ts +11 -0
  3. package/dist/array/chunk.d.ts.map +1 -0
  4. package/dist/array/chunk.js +23 -0
  5. package/dist/array/compact.d.ts +11 -0
  6. package/dist/array/compact.d.ts.map +1 -0
  7. package/dist/array/compact.js +15 -0
  8. package/dist/array/index.d.ts +3 -0
  9. package/dist/array/index.d.ts.map +1 -0
  10. package/dist/array/index.js +18 -0
  11. package/dist/esm/array/chunk.d.ts +11 -0
  12. package/dist/esm/array/chunk.d.ts.map +1 -0
  13. package/dist/esm/array/chunk.js +20 -0
  14. package/dist/esm/array/compact.d.ts +11 -0
  15. package/dist/esm/array/compact.d.ts.map +1 -0
  16. package/dist/esm/array/compact.js +12 -0
  17. package/dist/esm/array/index.d.ts +3 -0
  18. package/dist/esm/array/index.d.ts.map +1 -0
  19. package/dist/esm/array/index.js +2 -0
  20. package/dist/esm/index.d.ts +14 -0
  21. package/dist/esm/index.d.ts.map +1 -0
  22. package/dist/esm/index.js +24 -0
  23. package/dist/esm/object/index.d.ts +3 -0
  24. package/dist/esm/object/index.d.ts.map +1 -0
  25. package/dist/esm/object/index.js +2 -0
  26. package/dist/esm/object/omit.d.ts +13 -0
  27. package/dist/esm/object/omit.d.ts.map +1 -0
  28. package/dist/esm/object/omit.js +21 -0
  29. package/dist/esm/object/pick.d.ts +13 -0
  30. package/dist/esm/object/pick.d.ts.map +1 -0
  31. package/dist/esm/object/pick.js +19 -0
  32. package/dist/esm/string/camelCase.d.ts +11 -0
  33. package/dist/esm/string/camelCase.d.ts.map +1 -0
  34. package/dist/esm/string/camelCase.js +17 -0
  35. package/dist/esm/string/capitalize.d.ts +10 -0
  36. package/dist/esm/string/capitalize.d.ts.map +1 -0
  37. package/dist/esm/string/capitalize.js +14 -0
  38. package/dist/esm/string/index.d.ts +3 -0
  39. package/dist/esm/string/index.d.ts.map +1 -0
  40. package/dist/esm/string/index.js +2 -0
  41. package/dist/esm/types/index.d.ts +19 -0
  42. package/dist/esm/types/index.d.ts.map +1 -0
  43. package/dist/esm/types/index.js +4 -0
  44. package/dist/esm/utility/index.d.ts +3 -0
  45. package/dist/esm/utility/index.d.ts.map +1 -0
  46. package/dist/esm/utility/index.js +2 -0
  47. package/dist/esm/utility/isEmpty.d.ts +13 -0
  48. package/dist/esm/utility/isEmpty.d.ts.map +1 -0
  49. package/dist/esm/utility/isEmpty.js +26 -0
  50. package/dist/esm/utility/isType.d.ts +17 -0
  51. package/dist/esm/utility/isType.d.ts.map +1 -0
  52. package/dist/esm/utility/isType.js +42 -0
  53. package/dist/index.d.ts +14 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +79 -0
  56. package/dist/object/index.d.ts +3 -0
  57. package/dist/object/index.d.ts.map +1 -0
  58. package/dist/object/index.js +18 -0
  59. package/dist/object/omit.d.ts +13 -0
  60. package/dist/object/omit.d.ts.map +1 -0
  61. package/dist/object/omit.js +24 -0
  62. package/dist/object/pick.d.ts +13 -0
  63. package/dist/object/pick.d.ts.map +1 -0
  64. package/dist/object/pick.js +22 -0
  65. package/dist/string/camelCase.d.ts +11 -0
  66. package/dist/string/camelCase.d.ts.map +1 -0
  67. package/dist/string/camelCase.js +20 -0
  68. package/dist/string/capitalize.d.ts +10 -0
  69. package/dist/string/capitalize.d.ts.map +1 -0
  70. package/dist/string/capitalize.js +17 -0
  71. package/dist/string/index.d.ts +3 -0
  72. package/dist/string/index.d.ts.map +1 -0
  73. package/dist/string/index.js +18 -0
  74. package/dist/types/index.d.ts +19 -0
  75. package/dist/types/index.d.ts.map +1 -0
  76. package/dist/types/index.js +5 -0
  77. package/dist/utility/index.d.ts +3 -0
  78. package/dist/utility/index.d.ts.map +1 -0
  79. package/dist/utility/index.js +18 -0
  80. package/dist/utility/isEmpty.d.ts +13 -0
  81. package/dist/utility/isEmpty.d.ts.map +1 -0
  82. package/dist/utility/isEmpty.js +29 -0
  83. package/dist/utility/isType.d.ts +17 -0
  84. package/dist/utility/isType.d.ts.map +1 -0
  85. package/dist/utility/isType.js +57 -0
  86. package/package.json +77 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 检查值是否为空
3
+ * @param value 要检查的值
4
+ * @returns 如果值为空则返回 true
5
+ *
6
+ * @example
7
+ * isEmpty([]) // => true
8
+ * isEmpty({}) // => true
9
+ * isEmpty('') // => true
10
+ * isEmpty(null) // => true
11
+ */
12
+ export function isEmpty(value) {
13
+ if (value === null || value === undefined) {
14
+ return true;
15
+ }
16
+ if (typeof value === 'string' || Array.isArray(value)) {
17
+ return value.length === 0;
18
+ }
19
+ if (value instanceof Map || value instanceof Set) {
20
+ return value.size === 0;
21
+ }
22
+ if (typeof value === 'object') {
23
+ return Object.keys(value).length === 0;
24
+ }
25
+ return false;
26
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 检查值是否为指定类型
3
+ */
4
+ export declare function isString(value: unknown): value is string;
5
+ export declare function isNumber(value: unknown): value is number;
6
+ export declare function isBoolean(value: unknown): value is boolean;
7
+ export declare function isNull(value: unknown): value is null;
8
+ export declare function isUndefined(value: unknown): value is undefined;
9
+ export declare function isNullOrUndefined(value: unknown): value is null | undefined;
10
+ export declare function isArray(value: unknown): value is any[];
11
+ export declare function isObject(value: unknown): value is Record<string, any>;
12
+ export declare function isFunction(value: unknown): value is Function;
13
+ export declare function isDate(value: unknown): value is Date;
14
+ export declare function isRegExp(value: unknown): value is RegExp;
15
+ export declare function isMap(value: unknown): value is Map<any, any>;
16
+ export declare function isSet(value: unknown): value is Set<any>;
17
+ //# sourceMappingURL=isType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isType.d.ts","sourceRoot":"","sources":["../../../src/utility/isType.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,SAAS,CAE3E;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,EAAE,CAEtD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAErE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAE5D;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,CAEvD"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * 检查值是否为指定类型
3
+ */
4
+ export function isString(value) {
5
+ return typeof value === 'string';
6
+ }
7
+ export function isNumber(value) {
8
+ return typeof value === 'number' && !Number.isNaN(value);
9
+ }
10
+ export function isBoolean(value) {
11
+ return typeof value === 'boolean';
12
+ }
13
+ export function isNull(value) {
14
+ return value === null;
15
+ }
16
+ export function isUndefined(value) {
17
+ return value === undefined;
18
+ }
19
+ export function isNullOrUndefined(value) {
20
+ return value === null || value === undefined;
21
+ }
22
+ export function isArray(value) {
23
+ return Array.isArray(value);
24
+ }
25
+ export function isObject(value) {
26
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
27
+ }
28
+ export function isFunction(value) {
29
+ return typeof value === 'function';
30
+ }
31
+ export function isDate(value) {
32
+ return value instanceof Date;
33
+ }
34
+ export function isRegExp(value) {
35
+ return value instanceof RegExp;
36
+ }
37
+ export function isMap(value) {
38
+ return value instanceof Map;
39
+ }
40
+ export function isSet(value) {
41
+ return value instanceof Set;
42
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * jzlib - 轻量级工具库
3
+ * 类似 Lodash 的 JavaScript/TypeScript 工具函数集合
4
+ */
5
+ export * from './types';
6
+ export * as array from './array';
7
+ export * as object from './object';
8
+ export * as string from './string';
9
+ export * as utility from './utility';
10
+ export { chunk, compact, } from './array';
11
+ export { pick, omit, } from './object';
12
+ export { capitalize, camelCase, } from './string';
13
+ export { isString, isNumber, isBoolean, isNull, isUndefined, isNullOrUndefined, isArray, isObject, isFunction, isDate, isRegExp, isMap, isSet, isEmpty, } from './utility';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAGrC,OAAO,EAEL,KAAK,EACL,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EAEL,IAAI,EACJ,IAAI,GACL,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,UAAU,EACV,SAAS,GACV,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,KAAK,EACL,OAAO,GACR,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * jzlib - 轻量级工具库
4
+ * 类似 Lodash 的 JavaScript/TypeScript 工具函数集合
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
+ };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ exports.isEmpty = exports.isSet = exports.isMap = exports.isRegExp = exports.isDate = exports.isFunction = exports.isObject = exports.isArray = exports.isNullOrUndefined = exports.isUndefined = exports.isNull = exports.isBoolean = exports.isNumber = exports.isString = exports.camelCase = exports.capitalize = exports.omit = exports.pick = exports.compact = exports.chunk = exports.utility = exports.string = exports.object = exports.array = void 0;
44
+ // 类型导出
45
+ __exportStar(require("./types"), exports);
46
+ // 功能模块导出
47
+ exports.array = __importStar(require("./array"));
48
+ exports.object = __importStar(require("./object"));
49
+ exports.string = __importStar(require("./string"));
50
+ exports.utility = __importStar(require("./utility"));
51
+ // 直接导出常用函数
52
+ var array_1 = require("./array");
53
+ // 数组
54
+ Object.defineProperty(exports, "chunk", { enumerable: true, get: function () { return array_1.chunk; } });
55
+ Object.defineProperty(exports, "compact", { enumerable: true, get: function () { return array_1.compact; } });
56
+ var object_1 = require("./object");
57
+ // 对象
58
+ Object.defineProperty(exports, "pick", { enumerable: true, get: function () { return object_1.pick; } });
59
+ Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return object_1.omit; } });
60
+ var string_1 = require("./string");
61
+ // 字符串
62
+ Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return string_1.capitalize; } });
63
+ Object.defineProperty(exports, "camelCase", { enumerable: true, get: function () { return string_1.camelCase; } });
64
+ var utility_1 = require("./utility");
65
+ // 工具类
66
+ Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return utility_1.isString; } });
67
+ Object.defineProperty(exports, "isNumber", { enumerable: true, get: function () { return utility_1.isNumber; } });
68
+ Object.defineProperty(exports, "isBoolean", { enumerable: true, get: function () { return utility_1.isBoolean; } });
69
+ Object.defineProperty(exports, "isNull", { enumerable: true, get: function () { return utility_1.isNull; } });
70
+ Object.defineProperty(exports, "isUndefined", { enumerable: true, get: function () { return utility_1.isUndefined; } });
71
+ Object.defineProperty(exports, "isNullOrUndefined", { enumerable: true, get: function () { return utility_1.isNullOrUndefined; } });
72
+ Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return utility_1.isArray; } });
73
+ Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return utility_1.isObject; } });
74
+ Object.defineProperty(exports, "isFunction", { enumerable: true, get: function () { return utility_1.isFunction; } });
75
+ Object.defineProperty(exports, "isDate", { enumerable: true, get: function () { return utility_1.isDate; } });
76
+ Object.defineProperty(exports, "isRegExp", { enumerable: true, get: function () { return utility_1.isRegExp; } });
77
+ Object.defineProperty(exports, "isMap", { enumerable: true, get: function () { return utility_1.isMap; } });
78
+ Object.defineProperty(exports, "isSet", { enumerable: true, get: function () { return utility_1.isSet; } });
79
+ Object.defineProperty(exports, "isEmpty", { enumerable: true, get: function () { return utility_1.isEmpty; } });
@@ -0,0 +1,3 @@
1
+ export * from './pick';
2
+ export * from './omit';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./pick"), exports);
18
+ __exportStar(require("./omit"), exports);
@@ -0,0 +1,13 @@
1
+ import { AnyObject } from '../types';
2
+ /**
3
+ * 从对象中排除指定的属性
4
+ * @param obj 源对象
5
+ * @param keys 要排除的属性名
6
+ * @returns 不包含排除属性的新对象
7
+ *
8
+ * @example
9
+ * omit({ a: 1, b: 2, c: 3 }, ['b'])
10
+ * // => { a: 1, c: 3 }
11
+ */
12
+ export declare function omit<T extends AnyObject, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
13
+ //# sourceMappingURL=omit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omit.d.ts","sourceRoot":"","sources":["../../src/object/omit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,MAAM,CAAC,EACzD,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,CAAC,EAAE,GACR,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAYZ"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.omit = omit;
4
+ /**
5
+ * 从对象中排除指定的属性
6
+ * @param obj 源对象
7
+ * @param keys 要排除的属性名
8
+ * @returns 不包含排除属性的新对象
9
+ *
10
+ * @example
11
+ * omit({ a: 1, b: 2, c: 3 }, ['b'])
12
+ * // => { a: 1, c: 3 }
13
+ */
14
+ function omit(obj, keys) {
15
+ const result = { ...obj };
16
+ const keysSet = new Set(keys);
17
+ for (const key of Object.keys(result)) {
18
+ if (keysSet.has(key)) {
19
+ //@ts-ignore
20
+ delete result[key];
21
+ }
22
+ }
23
+ return result;
24
+ }
@@ -0,0 +1,13 @@
1
+ import { AnyObject } from '../types';
2
+ /**
3
+ * 从对象中选择指定的属性
4
+ * @param obj 源对象
5
+ * @param keys 要选择的属性名
6
+ * @returns 只包含选定属性的新对象
7
+ *
8
+ * @example
9
+ * pick({ a: 1, b: 2, c: 3 }, ['a', 'c'])
10
+ * // => { a: 1, c: 3 }
11
+ */
12
+ export declare function pick<T extends AnyObject, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
13
+ //# sourceMappingURL=pick.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/object/pick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,MAAM,CAAC,EACzD,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,CAAC,EAAE,GACR,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAUZ"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pick = pick;
4
+ /**
5
+ * 从对象中选择指定的属性
6
+ * @param obj 源对象
7
+ * @param keys 要选择的属性名
8
+ * @returns 只包含选定属性的新对象
9
+ *
10
+ * @example
11
+ * pick({ a: 1, b: 2, c: 3 }, ['a', 'c'])
12
+ * // => { a: 1, c: 3 }
13
+ */
14
+ function pick(obj, keys) {
15
+ const result = {};
16
+ for (const key of keys) {
17
+ if (key in obj) {
18
+ result[key] = obj[key];
19
+ }
20
+ }
21
+ return result;
22
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 将字符串转换为驼峰式命名法
3
+ * @param str 输入字符串
4
+ * @returns 驼峰式命名的字符串
5
+ *
6
+ * @example
7
+ * camelCase('hello-world') // => 'helloWorld'
8
+ * camelCase('hello_world') // => 'helloWorld'
9
+ */
10
+ export declare function camelCase(str: string): string;
11
+ //# sourceMappingURL=camelCase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"camelCase.d.ts","sourceRoot":"","sources":["../../src/string/camelCase.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ7C"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.camelCase = camelCase;
4
+ /**
5
+ * 将字符串转换为驼峰式命名法
6
+ * @param str 输入字符串
7
+ * @returns 驼峰式命名的字符串
8
+ *
9
+ * @example
10
+ * camelCase('hello-world') // => 'helloWorld'
11
+ * camelCase('hello_world') // => 'helloWorld'
12
+ */
13
+ function camelCase(str) {
14
+ if (typeof str !== 'string') {
15
+ return '';
16
+ }
17
+ return str
18
+ .replace(/[-_\s]+(.)?/g, (_, char) => (char ? char.toUpperCase() : ''))
19
+ .replace(/^(.)/, (char) => char.toLowerCase());
20
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 将字符串首字母转为大写
3
+ * @param str 输入字符串
4
+ * @returns 首字母大写的字符串
5
+ *
6
+ * @example
7
+ * capitalize('hello') // => 'Hello'
8
+ */
9
+ export declare function capitalize(str: string): string;
10
+ //# sourceMappingURL=capitalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capitalize.d.ts","sourceRoot":"","sources":["../../src/string/capitalize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK9C"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.capitalize = capitalize;
4
+ /**
5
+ * 将字符串首字母转为大写
6
+ * @param str 输入字符串
7
+ * @returns 首字母大写的字符串
8
+ *
9
+ * @example
10
+ * capitalize('hello') // => 'Hello'
11
+ */
12
+ function capitalize(str) {
13
+ if (typeof str !== 'string' || str.length === 0) {
14
+ return '';
15
+ }
16
+ return str.charAt(0).toUpperCase() + str.slice(1);
17
+ }
@@ -0,0 +1,3 @@
1
+ export * from './capitalize';
2
+ export * from './camelCase';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./capitalize"), exports);
18
+ __exportStar(require("./camelCase"), exports);
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 基础类型定义
3
+ */
4
+ export type Primitive = string | number | boolean | null | undefined;
5
+ export type AnyObject = Record<string, any>;
6
+ export type AnyArray = any[];
7
+ export type Func = (...args: any[]) => any;
8
+ export type DeepPartial<T> = T extends object ? {
9
+ [P in keyof T]?: DeepPartial<T[P]>;
10
+ } : T;
11
+ export type DeepReadonly<T> = T extends object ? {
12
+ readonly [P in keyof T]: DeepReadonly<T[P]>;
13
+ } : T;
14
+ export type Flatten<T> = T extends (infer R)[] ? Flatten<R> | R : T;
15
+ export type Predicate<T> = (value: T, index?: number, array?: T[]) => boolean;
16
+ export type Comparator<T> = (a: T, b: T) => number;
17
+ export type Transform<T, R> = (value: T, index?: number, array?: T[]) => R;
18
+ export type Reducer<T, U> = (accumulator: U, value: T, index?: number, array?: T[]) => U;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAErE,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5C,MAAM,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC;AAE7B,MAAM,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAE3C,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACzC;KACG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACnC,GACD,CAAC,CAAC;AAEN,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC1C;IACE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5C,GACD,CAAC,CAAC;AAEN,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC1C,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GACd,CAAC,CAAC;AAEN,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC;AAE9E,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;AAEnD,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAE3E,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * 基础类型定义
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from './isType';
2
+ export * from './isEmpty';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utility/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./isType"), exports);
18
+ __exportStar(require("./isEmpty"), exports);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 检查值是否为空
3
+ * @param value 要检查的值
4
+ * @returns 如果值为空则返回 true
5
+ *
6
+ * @example
7
+ * isEmpty([]) // => true
8
+ * isEmpty({}) // => true
9
+ * isEmpty('') // => true
10
+ * isEmpty(null) // => true
11
+ */
12
+ export declare function isEmpty(value: unknown): boolean;
13
+ //# sourceMappingURL=isEmpty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEmpty.d.ts","sourceRoot":"","sources":["../../src/utility/isEmpty.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkB/C"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmpty = isEmpty;
4
+ /**
5
+ * 检查值是否为空
6
+ * @param value 要检查的值
7
+ * @returns 如果值为空则返回 true
8
+ *
9
+ * @example
10
+ * isEmpty([]) // => true
11
+ * isEmpty({}) // => true
12
+ * isEmpty('') // => true
13
+ * isEmpty(null) // => true
14
+ */
15
+ function isEmpty(value) {
16
+ if (value === null || value === undefined) {
17
+ return true;
18
+ }
19
+ if (typeof value === 'string' || Array.isArray(value)) {
20
+ return value.length === 0;
21
+ }
22
+ if (value instanceof Map || value instanceof Set) {
23
+ return value.size === 0;
24
+ }
25
+ if (typeof value === 'object') {
26
+ return Object.keys(value).length === 0;
27
+ }
28
+ return false;
29
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 检查值是否为指定类型
3
+ */
4
+ export declare function isString(value: unknown): value is string;
5
+ export declare function isNumber(value: unknown): value is number;
6
+ export declare function isBoolean(value: unknown): value is boolean;
7
+ export declare function isNull(value: unknown): value is null;
8
+ export declare function isUndefined(value: unknown): value is undefined;
9
+ export declare function isNullOrUndefined(value: unknown): value is null | undefined;
10
+ export declare function isArray(value: unknown): value is any[];
11
+ export declare function isObject(value: unknown): value is Record<string, any>;
12
+ export declare function isFunction(value: unknown): value is Function;
13
+ export declare function isDate(value: unknown): value is Date;
14
+ export declare function isRegExp(value: unknown): value is RegExp;
15
+ export declare function isMap(value: unknown): value is Map<any, any>;
16
+ export declare function isSet(value: unknown): value is Set<any>;
17
+ //# sourceMappingURL=isType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isType.d.ts","sourceRoot":"","sources":["../../src/utility/isType.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,SAAS,CAE3E;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,EAAE,CAEtD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAErE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,IAAI,CAEpD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAE5D;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,CAEvD"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * 检查值是否为指定类型
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isString = isString;
7
+ exports.isNumber = isNumber;
8
+ exports.isBoolean = isBoolean;
9
+ exports.isNull = isNull;
10
+ exports.isUndefined = isUndefined;
11
+ exports.isNullOrUndefined = isNullOrUndefined;
12
+ exports.isArray = isArray;
13
+ exports.isObject = isObject;
14
+ exports.isFunction = isFunction;
15
+ exports.isDate = isDate;
16
+ exports.isRegExp = isRegExp;
17
+ exports.isMap = isMap;
18
+ exports.isSet = isSet;
19
+ function isString(value) {
20
+ return typeof value === 'string';
21
+ }
22
+ function isNumber(value) {
23
+ return typeof value === 'number' && !Number.isNaN(value);
24
+ }
25
+ function isBoolean(value) {
26
+ return typeof value === 'boolean';
27
+ }
28
+ function isNull(value) {
29
+ return value === null;
30
+ }
31
+ function isUndefined(value) {
32
+ return value === undefined;
33
+ }
34
+ function isNullOrUndefined(value) {
35
+ return value === null || value === undefined;
36
+ }
37
+ function isArray(value) {
38
+ return Array.isArray(value);
39
+ }
40
+ function isObject(value) {
41
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
42
+ }
43
+ function isFunction(value) {
44
+ return typeof value === 'function';
45
+ }
46
+ function isDate(value) {
47
+ return value instanceof Date;
48
+ }
49
+ function isRegExp(value) {
50
+ return value instanceof RegExp;
51
+ }
52
+ function isMap(value) {
53
+ return value instanceof Map;
54
+ }
55
+ function isSet(value) {
56
+ return value instanceof Set;
57
+ }