@twin.org/core 0.0.2-next.7 → 0.0.2-next.9

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.
@@ -374,6 +374,19 @@ class Is {
374
374
  static regexp(value) {
375
375
  return value instanceof RegExp;
376
376
  }
377
+ /**
378
+ * Is the provided object a class constructor.
379
+ * @param obj The object to check.
380
+ * @returns True if the object is a class, false otherwise.
381
+ */
382
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
383
+ static class(obj) {
384
+ if (typeof obj !== "function") {
385
+ return false;
386
+ }
387
+ const str = Function.prototype.toString.call(obj);
388
+ return /^class\s/.test(str);
389
+ }
377
390
  }
378
391
 
379
392
  // Copyright 2024 IOTA Stiftung.
@@ -372,6 +372,19 @@ class Is {
372
372
  static regexp(value) {
373
373
  return value instanceof RegExp;
374
374
  }
375
+ /**
376
+ * Is the provided object a class constructor.
377
+ * @param obj The object to check.
378
+ * @returns True if the object is a class, false otherwise.
379
+ */
380
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
381
+ static class(obj) {
382
+ if (typeof obj !== "function") {
383
+ return false;
384
+ }
385
+ const str = Function.prototype.toString.call(obj);
386
+ return /^class\s/.test(str);
387
+ }
375
388
  }
376
389
 
377
390
  // Copyright 2024 IOTA Stiftung.
@@ -214,4 +214,10 @@ export declare class Is {
214
214
  * @returns True if the value is a regexp.
215
215
  */
216
216
  static regexp(value: unknown): value is RegExp;
217
+ /**
218
+ * Is the provided object a class constructor.
219
+ * @param obj The object to check.
220
+ * @returns True if the object is a class, false otherwise.
221
+ */
222
+ static class<T = unknown>(obj: unknown): obj is new (...args: any[]) => T;
217
223
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @twin.org/core - Changelog
2
2
 
3
+ ## [0.0.2-next.9](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.8...core-v0.0.2-next.9) (2025-09-08)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **core:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/nameof bumped from 0.0.2-next.8 to 0.0.2-next.9
16
+ * devDependencies
17
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.8 to 0.0.2-next.9
18
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.8 to 0.0.2-next.9
19
+
20
+ ## [0.0.2-next.8](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.7...core-v0.0.2-next.8) (2025-09-05)
21
+
22
+
23
+ ### Features
24
+
25
+ * add Is.class method ([4988205](https://github.com/twinfoundation/framework/commit/498820543e256a130b4888c958fe1d87ca865d7f))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * The following workspace dependencies were updated
31
+ * dependencies
32
+ * @twin.org/nameof bumped from 0.0.2-next.7 to 0.0.2-next.8
33
+ * devDependencies
34
+ * @twin.org/nameof-transformer bumped from 0.0.2-next.7 to 0.0.2-next.8
35
+ * @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.7 to 0.0.2-next.8
36
+
3
37
  ## [0.0.2-next.7](https://github.com/twinfoundation/framework/compare/core-v0.0.2-next.6...core-v0.0.2-next.7) (2025-08-29)
4
38
 
5
39
 
@@ -819,3 +819,31 @@ The value to test.
819
819
  `value is RegExp`
820
820
 
821
821
  True if the value is a regexp.
822
+
823
+ ***
824
+
825
+ ### class()
826
+
827
+ > `static` **class**\<`T`\>(`obj`): `obj is (args: any[]) => T`
828
+
829
+ Is the provided object a class constructor.
830
+
831
+ #### Type Parameters
832
+
833
+ ##### T
834
+
835
+ `T` = `unknown`
836
+
837
+ #### Parameters
838
+
839
+ ##### obj
840
+
841
+ `unknown`
842
+
843
+ The object to check.
844
+
845
+ #### Returns
846
+
847
+ `obj is (args: any[]) => T`
848
+
849
+ True if the object is a class, false otherwise.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/core",
3
- "version": "0.0.2-next.7",
3
+ "version": "0.0.2-next.9",
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.7",
17
+ "@twin.org/nameof": "0.0.2-next.9",
18
18
  "intl-messageformat": "10.7.16",
19
19
  "rfc6902": "5.1.2"
20
20
  },