@twin.org/core 0.0.2-next.18 → 0.0.2-next.20
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/cjs/index.cjs +27 -0
- package/dist/esm/index.mjs +27 -0
- package/dist/types/helpers/objectHelper.d.ts +10 -0
- package/dist/types/utils/is.d.ts +1 -1
- package/docs/changelog.md +34 -0
- package/docs/reference/classes/Is.md +4 -4
- package/docs/reference/classes/ObjectHelper.md +42 -0
- package/package.json +12 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -346,6 +346,7 @@ class Is {
|
|
|
346
346
|
* @param value The value to test.
|
|
347
347
|
* @returns True if the value is a function.
|
|
348
348
|
*/
|
|
349
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
349
350
|
static function(value) {
|
|
350
351
|
return typeof value === "function";
|
|
351
352
|
}
|
|
@@ -2941,6 +2942,32 @@ class ObjectHelper {
|
|
|
2941
2942
|
}
|
|
2942
2943
|
return obj;
|
|
2943
2944
|
}
|
|
2945
|
+
/**
|
|
2946
|
+
* Split an object into two with the specified keys.
|
|
2947
|
+
* @param obj The object to split.
|
|
2948
|
+
* @param keys The property keys to split.
|
|
2949
|
+
* @returns The two partial objects.
|
|
2950
|
+
*/
|
|
2951
|
+
static split(obj, keys) {
|
|
2952
|
+
if (Is.object(obj) && Is.array(keys)) {
|
|
2953
|
+
const picked = {};
|
|
2954
|
+
const omitted = {};
|
|
2955
|
+
const allKeys = Object.keys(obj);
|
|
2956
|
+
for (const key of allKeys) {
|
|
2957
|
+
if (keys.includes(key)) {
|
|
2958
|
+
picked[key] = obj[key];
|
|
2959
|
+
}
|
|
2960
|
+
else {
|
|
2961
|
+
omitted[key] = obj[key];
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
return {
|
|
2965
|
+
picked: Object.keys(picked).length > 0 ? picked : undefined,
|
|
2966
|
+
omitted: Object.keys(omitted).length > 0 ? omitted : undefined
|
|
2967
|
+
};
|
|
2968
|
+
}
|
|
2969
|
+
return { picked: obj, omitted: undefined };
|
|
2970
|
+
}
|
|
2944
2971
|
/**
|
|
2945
2972
|
* Converter the non JSON primitives to extended types.
|
|
2946
2973
|
* @param obj The object to convert.
|
package/dist/esm/index.mjs
CHANGED
|
@@ -344,6 +344,7 @@ class Is {
|
|
|
344
344
|
* @param value The value to test.
|
|
345
345
|
* @returns True if the value is a function.
|
|
346
346
|
*/
|
|
347
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
347
348
|
static function(value) {
|
|
348
349
|
return typeof value === "function";
|
|
349
350
|
}
|
|
@@ -2939,6 +2940,32 @@ class ObjectHelper {
|
|
|
2939
2940
|
}
|
|
2940
2941
|
return obj;
|
|
2941
2942
|
}
|
|
2943
|
+
/**
|
|
2944
|
+
* Split an object into two with the specified keys.
|
|
2945
|
+
* @param obj The object to split.
|
|
2946
|
+
* @param keys The property keys to split.
|
|
2947
|
+
* @returns The two partial objects.
|
|
2948
|
+
*/
|
|
2949
|
+
static split(obj, keys) {
|
|
2950
|
+
if (Is.object(obj) && Is.array(keys)) {
|
|
2951
|
+
const picked = {};
|
|
2952
|
+
const omitted = {};
|
|
2953
|
+
const allKeys = Object.keys(obj);
|
|
2954
|
+
for (const key of allKeys) {
|
|
2955
|
+
if (keys.includes(key)) {
|
|
2956
|
+
picked[key] = obj[key];
|
|
2957
|
+
}
|
|
2958
|
+
else {
|
|
2959
|
+
omitted[key] = obj[key];
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
return {
|
|
2963
|
+
picked: Object.keys(picked).length > 0 ? picked : undefined,
|
|
2964
|
+
omitted: Object.keys(omitted).length > 0 ? omitted : undefined
|
|
2965
|
+
};
|
|
2966
|
+
}
|
|
2967
|
+
return { picked: obj, omitted: undefined };
|
|
2968
|
+
}
|
|
2942
2969
|
/**
|
|
2943
2970
|
* Converter the non JSON primitives to extended types.
|
|
2944
2971
|
* @param obj The object to convert.
|
|
@@ -80,6 +80,16 @@ export declare class ObjectHelper {
|
|
|
80
80
|
* @returns The partial object.
|
|
81
81
|
*/
|
|
82
82
|
static omit<T>(obj: T | undefined, keys?: (keyof T)[]): Partial<T>;
|
|
83
|
+
/**
|
|
84
|
+
* Split an object into two with the specified keys.
|
|
85
|
+
* @param obj The object to split.
|
|
86
|
+
* @param keys The property keys to split.
|
|
87
|
+
* @returns The two partial objects.
|
|
88
|
+
*/
|
|
89
|
+
static split<T>(obj: T | undefined, keys?: (keyof T)[]): {
|
|
90
|
+
picked: Partial<T> | undefined;
|
|
91
|
+
omitted: Partial<T> | undefined;
|
|
92
|
+
};
|
|
83
93
|
/**
|
|
84
94
|
* Converter the non JSON primitives to extended types.
|
|
85
95
|
* @param obj The object to convert.
|
package/dist/types/utils/is.d.ts
CHANGED
|
@@ -195,7 +195,7 @@ export declare class Is {
|
|
|
195
195
|
* @param value The value to test.
|
|
196
196
|
* @returns True if the value is a function.
|
|
197
197
|
*/
|
|
198
|
-
static function<
|
|
198
|
+
static function<T extends (...args: any[]) => any = (...args: any[]) => any>(value: unknown): value is T;
|
|
199
199
|
/**
|
|
200
200
|
* Is the value a string formatted as an email address.
|
|
201
201
|
* @param value The value to test.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @twin.org/core - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.20](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.19...core-v0.0.2-next.20) (2025-10-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* improve Is.function and ModuleHelper.getModuleMethod signatures ([ecf968b](https://github.com/twinfoundation/framework/commit/ecf968b02934b3676be4bf7cd2d1e7f8e7af6ce2))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/nameof bumped from 0.0.2-next.19 to 0.0.2-next.20
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.19 to 0.0.2-next.20
|
|
18
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.19 to 0.0.2-next.20
|
|
19
|
+
|
|
20
|
+
## [0.0.2-next.19](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.18...core-v0.0.2-next.19) (2025-09-30)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* add objectHelper.split ([386830a](https://github.com/twinfoundation/framework/commit/386830a77f8e842a5b119be0983708e042c3b14b))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Dependencies
|
|
29
|
+
|
|
30
|
+
* The following workspace dependencies were updated
|
|
31
|
+
* dependencies
|
|
32
|
+
* @twin.org/nameof bumped from 0.0.2-next.18 to 0.0.2-next.19
|
|
33
|
+
* devDependencies
|
|
34
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.18 to 0.0.2-next.19
|
|
35
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.18 to 0.0.2-next.19
|
|
36
|
+
|
|
3
37
|
## [0.0.2-next.18](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.17...core-v0.0.2-next.18) (2025-09-29)
|
|
4
38
|
|
|
5
39
|
|
|
@@ -730,15 +730,15 @@ True if the value is a TypedArray.
|
|
|
730
730
|
|
|
731
731
|
### function()
|
|
732
732
|
|
|
733
|
-
> `static` **function**\<`
|
|
733
|
+
> `static` **function**\<`T`\>(`value`): `value is T`
|
|
734
734
|
|
|
735
735
|
Is the property a function.
|
|
736
736
|
|
|
737
737
|
#### Type Parameters
|
|
738
738
|
|
|
739
|
-
#####
|
|
739
|
+
##### T
|
|
740
740
|
|
|
741
|
-
`
|
|
741
|
+
`T` *extends* (...`args`) => `any` = (...`args`) => `any`
|
|
742
742
|
|
|
743
743
|
#### Parameters
|
|
744
744
|
|
|
@@ -750,7 +750,7 @@ The value to test.
|
|
|
750
750
|
|
|
751
751
|
#### Returns
|
|
752
752
|
|
|
753
|
-
`value is
|
|
753
|
+
`value is T`
|
|
754
754
|
|
|
755
755
|
True if the value is a function.
|
|
756
756
|
|
|
@@ -390,6 +390,48 @@ The partial object.
|
|
|
390
390
|
|
|
391
391
|
***
|
|
392
392
|
|
|
393
|
+
### split()
|
|
394
|
+
|
|
395
|
+
> `static` **split**\<`T`\>(`obj`, `keys?`): `object`
|
|
396
|
+
|
|
397
|
+
Split an object into two with the specified keys.
|
|
398
|
+
|
|
399
|
+
#### Type Parameters
|
|
400
|
+
|
|
401
|
+
##### T
|
|
402
|
+
|
|
403
|
+
`T`
|
|
404
|
+
|
|
405
|
+
#### Parameters
|
|
406
|
+
|
|
407
|
+
##### obj
|
|
408
|
+
|
|
409
|
+
The object to split.
|
|
410
|
+
|
|
411
|
+
`undefined` | `T`
|
|
412
|
+
|
|
413
|
+
##### keys?
|
|
414
|
+
|
|
415
|
+
keyof `T`[]
|
|
416
|
+
|
|
417
|
+
The property keys to split.
|
|
418
|
+
|
|
419
|
+
#### Returns
|
|
420
|
+
|
|
421
|
+
`object`
|
|
422
|
+
|
|
423
|
+
The two partial objects.
|
|
424
|
+
|
|
425
|
+
##### picked
|
|
426
|
+
|
|
427
|
+
> **picked**: `undefined` \| `Partial`\<`T`\>
|
|
428
|
+
|
|
429
|
+
##### omitted
|
|
430
|
+
|
|
431
|
+
> **omitted**: `undefined` \| `Partial`\<`T`\>
|
|
432
|
+
|
|
433
|
+
***
|
|
434
|
+
|
|
393
435
|
### toExtended()
|
|
394
436
|
|
|
395
437
|
> `static` **toExtended**(`obj`): `any`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/core",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.20",
|
|
4
4
|
"description": "Helper methods/classes for data type checking/validation/guarding/error handling",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/nameof": "0.0.2-next.
|
|
17
|
+
"@twin.org/nameof": "0.0.2-next.20",
|
|
18
18
|
"intl-messageformat": "10.7.16",
|
|
19
19
|
"rfc6902": "5.1.2"
|
|
20
20
|
},
|
|
@@ -35,5 +35,15 @@
|
|
|
35
35
|
"dist/types",
|
|
36
36
|
"locales",
|
|
37
37
|
"docs"
|
|
38
|
+
],
|
|
39
|
+
"keywords": [
|
|
40
|
+
"twin",
|
|
41
|
+
"trade",
|
|
42
|
+
"iota",
|
|
43
|
+
"framework",
|
|
44
|
+
"blockchain",
|
|
45
|
+
"core",
|
|
46
|
+
"foundation",
|
|
47
|
+
"utilities"
|
|
38
48
|
]
|
|
39
49
|
}
|