@forklaunch/common 0.2.4 → 0.2.6

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/lib/index.d.mts CHANGED
@@ -8,6 +8,25 @@ declare function isNever(value: never): value is never;
8
8
  */
9
9
  declare function isRecord(obj: unknown): obj is Record<string, unknown>;
10
10
 
11
+ declare function isTrue(value: true): true;
12
+
13
+ type IdDto = {
14
+ id: string;
15
+ };
16
+ type IdsDto = {
17
+ ids: string[];
18
+ };
19
+ type RecordTimingDto = {
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ };
23
+ type ReturnTypeRecord<T extends Record<string, (...args: never[]) => unknown>> = {
24
+ [K in keyof T]: ReturnType<T[K]>;
25
+ };
26
+ type InstanceTypeRecord<T extends Record<string, new (...args: never[]) => unknown>> = {
27
+ [K in keyof T]: InstanceType<T[K]>;
28
+ };
29
+
11
30
  /**
12
31
  * A type that represents the values of an object type `T`.
13
32
  *
@@ -61,6 +80,8 @@ declare function extractArgumentNames(func: {
61
80
  toString(): string;
62
81
  }): string[];
63
82
 
83
+ declare function sortObjectKeys<T extends Record<string, unknown>>(obj: T): T;
84
+
64
85
  /**
65
86
  * Removes all properties with undefined values from an object. Note: this does NOT strip null values.
66
87
  * @param obj The object to strip undefined properties from
@@ -68,4 +89,4 @@ declare function extractArgumentNames(func: {
68
89
  */
69
90
  declare function stripUndefinedProperties<T extends Record<string, unknown>>(obj: T): Partial<T>;
70
91
 
71
- export { type Flatten, type FlattenKeys, type FlattenValues, type MakePropertyOptionalIfChildrenOptional, type Prettify, type RemoveTrailingSlash, extractArgumentNames, isNever, isRecord, stripUndefinedProperties };
92
+ export { type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type Prettify, type RecordTimingDto, type RemoveTrailingSlash, type ReturnTypeRecord, extractArgumentNames, isNever, isRecord, isTrue, sortObjectKeys, stripUndefinedProperties };
package/lib/index.d.ts CHANGED
@@ -8,6 +8,25 @@ declare function isNever(value: never): value is never;
8
8
  */
9
9
  declare function isRecord(obj: unknown): obj is Record<string, unknown>;
10
10
 
11
+ declare function isTrue(value: true): true;
12
+
13
+ type IdDto = {
14
+ id: string;
15
+ };
16
+ type IdsDto = {
17
+ ids: string[];
18
+ };
19
+ type RecordTimingDto = {
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ };
23
+ type ReturnTypeRecord<T extends Record<string, (...args: never[]) => unknown>> = {
24
+ [K in keyof T]: ReturnType<T[K]>;
25
+ };
26
+ type InstanceTypeRecord<T extends Record<string, new (...args: never[]) => unknown>> = {
27
+ [K in keyof T]: InstanceType<T[K]>;
28
+ };
29
+
11
30
  /**
12
31
  * A type that represents the values of an object type `T`.
13
32
  *
@@ -61,6 +80,8 @@ declare function extractArgumentNames(func: {
61
80
  toString(): string;
62
81
  }): string[];
63
82
 
83
+ declare function sortObjectKeys<T extends Record<string, unknown>>(obj: T): T;
84
+
64
85
  /**
65
86
  * Removes all properties with undefined values from an object. Note: this does NOT strip null values.
66
87
  * @param obj The object to strip undefined properties from
@@ -68,4 +89,4 @@ declare function extractArgumentNames(func: {
68
89
  */
69
90
  declare function stripUndefinedProperties<T extends Record<string, unknown>>(obj: T): Partial<T>;
70
91
 
71
- export { type Flatten, type FlattenKeys, type FlattenValues, type MakePropertyOptionalIfChildrenOptional, type Prettify, type RemoveTrailingSlash, extractArgumentNames, isNever, isRecord, stripUndefinedProperties };
92
+ export { type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type Prettify, type RecordTimingDto, type RemoveTrailingSlash, type ReturnTypeRecord, extractArgumentNames, isNever, isRecord, isTrue, sortObjectKeys, stripUndefinedProperties };
package/lib/index.js CHANGED
@@ -23,6 +23,8 @@ __export(index_exports, {
23
23
  extractArgumentNames: () => extractArgumentNames,
24
24
  isNever: () => isNever,
25
25
  isRecord: () => isRecord,
26
+ isTrue: () => isTrue,
27
+ sortObjectKeys: () => sortObjectKeys,
26
28
  stripUndefinedProperties: () => stripUndefinedProperties
27
29
  });
28
30
  module.exports = __toCommonJS(index_exports);
@@ -37,6 +39,11 @@ function isRecord(obj) {
37
39
  return obj !== null && typeof obj === "object" && !Array.isArray(obj);
38
40
  }
39
41
 
42
+ // src/guards/isTrue.ts
43
+ function isTrue(value) {
44
+ return value;
45
+ }
46
+
40
47
  // src/utils/extractArgumentNames.ts
41
48
  function extractArgumentNames(func) {
42
49
  const fnStr = func.toString();
@@ -65,6 +72,21 @@ function extractArgumentNames(func) {
65
72
  return result;
66
73
  }
67
74
 
75
+ // src/utils/sortObjectKeys.ts
76
+ function sortObjectKeys(obj) {
77
+ if (typeof obj !== "object" || obj === null) {
78
+ return obj;
79
+ }
80
+ return Object.keys(obj).sort().reduce(
81
+ (result, key) => {
82
+ const value = obj[key];
83
+ result[key] = sortObjectKeys(value);
84
+ return result;
85
+ },
86
+ {}
87
+ );
88
+ }
89
+
68
90
  // src/utils/stripUndefinedProperties.ts
69
91
  function stripUndefinedProperties(obj) {
70
92
  return Object.fromEntries(
@@ -76,5 +98,7 @@ function stripUndefinedProperties(obj) {
76
98
  extractArgumentNames,
77
99
  isNever,
78
100
  isRecord,
101
+ isTrue,
102
+ sortObjectKeys,
79
103
  stripUndefinedProperties
80
104
  });
package/lib/index.mjs CHANGED
@@ -8,6 +8,11 @@ function isRecord(obj) {
8
8
  return obj !== null && typeof obj === "object" && !Array.isArray(obj);
9
9
  }
10
10
 
11
+ // src/guards/isTrue.ts
12
+ function isTrue(value) {
13
+ return value;
14
+ }
15
+
11
16
  // src/utils/extractArgumentNames.ts
12
17
  function extractArgumentNames(func) {
13
18
  const fnStr = func.toString();
@@ -36,6 +41,21 @@ function extractArgumentNames(func) {
36
41
  return result;
37
42
  }
38
43
 
44
+ // src/utils/sortObjectKeys.ts
45
+ function sortObjectKeys(obj) {
46
+ if (typeof obj !== "object" || obj === null) {
47
+ return obj;
48
+ }
49
+ return Object.keys(obj).sort().reduce(
50
+ (result, key) => {
51
+ const value = obj[key];
52
+ result[key] = sortObjectKeys(value);
53
+ return result;
54
+ },
55
+ {}
56
+ );
57
+ }
58
+
39
59
  // src/utils/stripUndefinedProperties.ts
40
60
  function stripUndefinedProperties(obj) {
41
61
  return Object.fromEntries(
@@ -46,5 +66,7 @@ export {
46
66
  extractArgumentNames,
47
67
  isNever,
48
68
  isRecord,
69
+ isTrue,
70
+ sortObjectKeys,
49
71
  stripUndefinedProperties
50
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/common",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Common package for base types, interfaces, implementations.",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -22,21 +22,21 @@
22
22
  },
23
23
  "types": "lib/index.d.ts",
24
24
  "directories": {
25
- "test": "tests"
25
+ "test": "__test__"
26
26
  },
27
27
  "files": [
28
28
  "lib/**"
29
29
  ],
30
30
  "devDependencies": {
31
- "@eslint/js": "^9.22.0",
31
+ "@eslint/js": "^9.24.0",
32
32
  "depcheck": "^1.4.7",
33
- "eslint": "^9.22.0",
33
+ "eslint": "^9.24.0",
34
34
  "globals": "^16.0.0",
35
35
  "tsup": "^8.4.0",
36
- "typedoc": "^0.27.9",
37
- "typescript": "^5.8.2",
38
- "typescript-eslint": "^8.26.1",
39
- "vitest": "^3.0.8"
36
+ "typedoc": "^0.28.2",
37
+ "typescript": "^5.8.3",
38
+ "typescript-eslint": "^8.29.1",
39
+ "vitest": "^3.1.1"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsc --noEmit && tsup index.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --outDir lib --dts --clean",