@vicin/sigil 1.2.7 → 1.3.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.3.0] - 2026-02-18
6
+
7
+ ### Added
8
+
9
+ - `isOfType()` & `isOfTypeStrict()` now can be called from instances.
10
+
5
11
  ## [1.2.7] - 2026-02-13
6
12
 
7
13
  ### Added
package/README.md CHANGED
@@ -434,6 +434,8 @@ Instances of sigilified classes expose instance helpers:
434
434
  - `getSigilType()` — runtime symbol.
435
435
  - `getSigilTypeLineage()` — returns lineage array.
436
436
  - `getSigilTypeSet()` — returns readonly Set.
437
+ - `isOfType(other)` — O(1) membership test using `other`'s `__TYPE_SET__`.
438
+ - `isOfTypeStrict(other)` — strict lineage comparison element-by-element.
437
439
 
438
440
  ---
439
441
 
package/dist/index.d.mts CHANGED
@@ -417,12 +417,13 @@ type ISigil<L extends string = string, P extends Function = never> = Constructor
417
417
  type TypedSigil<S extends Function, L extends string = string> = S & AppendLabel<L> & ConstructorAbstract<AppendLabel<L>>;
418
418
  /**
419
419
  * Generic helper extract instance of the class even in protected and private constructors.
420
+ * @remark Return same type is passed type has no 'prototype'
420
421
  */
421
422
  type GetInstance<T> = T extends {
422
423
  prototype: infer R;
423
424
  } ? PrettifyBrand<R & {
424
425
  __SIGIL_BRAND__: SigilBrandOf<T>;
425
- }> : never;
426
+ }> : T;
426
427
  /** Helper to append label into a class. */
427
428
  type AppendLabel<L extends string> = {
428
429
  readonly __SIGIL_BRAND__: Prettify<{
@@ -496,6 +497,8 @@ declare const Sigil: {
496
497
  readonly __SIGIL_BRAND__: {
497
498
  Sigil: true;
498
499
  };
500
+ isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
501
+ isOfTypeStrict<T>(this: T, other: unknown): other is /*elided*/ any;
499
502
  getSigilLabel(): string;
500
503
  getSigilType(): symbol;
501
504
  getSigilTypeLineage(): readonly symbol[];
@@ -528,6 +531,8 @@ declare const SigilError: {
528
531
  Sigil: true;
529
532
  SigilError: true;
530
533
  };
534
+ isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
535
+ isOfTypeStrict<T>(this: T, other: unknown): other is /*elided*/ any;
531
536
  getSigilLabel(): string;
532
537
  getSigilType(): symbol;
533
538
  getSigilTypeLineage(): readonly symbol[];
@@ -716,6 +721,28 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
716
721
  readonly __SIGIL_BRAND__: {
717
722
  Sigil: true;
718
723
  } & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
724
+ /**
725
+ * Check whether `other` is (or inherits from) the type instance.
726
+ *
727
+ * Allows 'instanceof' like checks but in instances.
728
+ *
729
+ * @typeParam T - The instance type.
730
+ * @param this - The instance performing the check.
731
+ * @param other - The object to test.
732
+ * @returns `true` if `other` is the same instance of this type or a subtype.
733
+ */
734
+ isOfType<T_1>(this: T_1, other: unknown): other is GetInstance<T_1>;
735
+ /**
736
+ * Strict lineage check: compares the type symbol lineage arrays element-by-element.
737
+ *
738
+ * Allows 'instanceof' like checks but in instances.
739
+ *
740
+ * @typeParam T - The instance type.
741
+ * @param this - The instance performing the check.
742
+ * @param other - The object to test.
743
+ * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
744
+ */
745
+ isOfTypeStrict<T_1>(this: T_1, other: unknown): other is /*elided*/ any;
719
746
  /**
720
747
  * Returns the human-readable sigil label of this instance's constructor.
721
748
  *
@@ -788,10 +815,6 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
788
815
  /**
789
816
  * Check whether `other` is (or inherits from) the type represented by the calling constructor.
790
817
  *
791
- * Implementation detail:
792
- * - Uses the other instance's `__TYPE_SET__` for O(1) membership test.
793
- * - O(1) and reliable as long as `OPTIONS.skipLabelInheritanceCheck` is `false`.
794
- *
795
818
  * This replaces `instanceof` so that checks remain valid across bundles/realms
796
819
  * and when subclassing.
797
820
  *
@@ -804,10 +827,6 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
804
827
  /**
805
828
  * Strict lineage check: compares the type symbol lineage arrays element-by-element.
806
829
  *
807
- * Implementation detail:
808
- * - Works in O(n) time where n is the depth of the lineage.
809
- * - Reliable when `OPTIONS.skipLabelInheritanceCheck` is `false`.
810
- *
811
830
  * @typeParam T - The calling constructor type.
812
831
  * @param this - The constructor performing the check.
813
832
  * @param other - The object to test.
@@ -842,6 +861,28 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
842
861
  readonly __SIGIL_BRAND__: {
843
862
  Sigil: true;
844
863
  } & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
864
+ /**
865
+ * Check whether `other` is (or inherits from) the type instance.
866
+ *
867
+ * Allows 'instanceof' like checks but in instances.
868
+ *
869
+ * @typeParam T - The instance type.
870
+ * @param this - The instance performing the check.
871
+ * @param other - The object to test.
872
+ * @returns `true` if `other` is the same instance of this type or a subtype.
873
+ */
874
+ isOfType<T_1>(this: T_1, other: unknown): other is GetInstance<T_1>;
875
+ /**
876
+ * Strict lineage check: compares the type symbol lineage arrays element-by-element.
877
+ *
878
+ * Allows 'instanceof' like checks but in instances.
879
+ *
880
+ * @typeParam T - The instance type.
881
+ * @param this - The instance performing the check.
882
+ * @param other - The object to test.
883
+ * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
884
+ */
885
+ isOfTypeStrict<T_1>(this: T_1, other: unknown): other is /*elided*/ any;
845
886
  /**
846
887
  * Returns the human-readable sigil label of this instance's constructor.
847
888
  *
package/dist/index.d.ts CHANGED
@@ -417,12 +417,13 @@ type ISigil<L extends string = string, P extends Function = never> = Constructor
417
417
  type TypedSigil<S extends Function, L extends string = string> = S & AppendLabel<L> & ConstructorAbstract<AppendLabel<L>>;
418
418
  /**
419
419
  * Generic helper extract instance of the class even in protected and private constructors.
420
+ * @remark Return same type is passed type has no 'prototype'
420
421
  */
421
422
  type GetInstance<T> = T extends {
422
423
  prototype: infer R;
423
424
  } ? PrettifyBrand<R & {
424
425
  __SIGIL_BRAND__: SigilBrandOf<T>;
425
- }> : never;
426
+ }> : T;
426
427
  /** Helper to append label into a class. */
427
428
  type AppendLabel<L extends string> = {
428
429
  readonly __SIGIL_BRAND__: Prettify<{
@@ -496,6 +497,8 @@ declare const Sigil: {
496
497
  readonly __SIGIL_BRAND__: {
497
498
  Sigil: true;
498
499
  };
500
+ isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
501
+ isOfTypeStrict<T>(this: T, other: unknown): other is /*elided*/ any;
499
502
  getSigilLabel(): string;
500
503
  getSigilType(): symbol;
501
504
  getSigilTypeLineage(): readonly symbol[];
@@ -528,6 +531,8 @@ declare const SigilError: {
528
531
  Sigil: true;
529
532
  SigilError: true;
530
533
  };
534
+ isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
535
+ isOfTypeStrict<T>(this: T, other: unknown): other is /*elided*/ any;
531
536
  getSigilLabel(): string;
532
537
  getSigilType(): symbol;
533
538
  getSigilTypeLineage(): readonly symbol[];
@@ -716,6 +721,28 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
716
721
  readonly __SIGIL_BRAND__: {
717
722
  Sigil: true;
718
723
  } & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
724
+ /**
725
+ * Check whether `other` is (or inherits from) the type instance.
726
+ *
727
+ * Allows 'instanceof' like checks but in instances.
728
+ *
729
+ * @typeParam T - The instance type.
730
+ * @param this - The instance performing the check.
731
+ * @param other - The object to test.
732
+ * @returns `true` if `other` is the same instance of this type or a subtype.
733
+ */
734
+ isOfType<T_1>(this: T_1, other: unknown): other is GetInstance<T_1>;
735
+ /**
736
+ * Strict lineage check: compares the type symbol lineage arrays element-by-element.
737
+ *
738
+ * Allows 'instanceof' like checks but in instances.
739
+ *
740
+ * @typeParam T - The instance type.
741
+ * @param this - The instance performing the check.
742
+ * @param other - The object to test.
743
+ * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
744
+ */
745
+ isOfTypeStrict<T_1>(this: T_1, other: unknown): other is /*elided*/ any;
719
746
  /**
720
747
  * Returns the human-readable sigil label of this instance's constructor.
721
748
  *
@@ -788,10 +815,6 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
788
815
  /**
789
816
  * Check whether `other` is (or inherits from) the type represented by the calling constructor.
790
817
  *
791
- * Implementation detail:
792
- * - Uses the other instance's `__TYPE_SET__` for O(1) membership test.
793
- * - O(1) and reliable as long as `OPTIONS.skipLabelInheritanceCheck` is `false`.
794
- *
795
818
  * This replaces `instanceof` so that checks remain valid across bundles/realms
796
819
  * and when subclassing.
797
820
  *
@@ -804,10 +827,6 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
804
827
  /**
805
828
  * Strict lineage check: compares the type symbol lineage arrays element-by-element.
806
829
  *
807
- * Implementation detail:
808
- * - Works in O(n) time where n is the depth of the lineage.
809
- * - Reliable when `OPTIONS.skipLabelInheritanceCheck` is `false`.
810
- *
811
830
  * @typeParam T - The calling constructor type.
812
831
  * @param this - The constructor performing the check.
813
832
  * @param other - The object to test.
@@ -842,6 +861,28 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
842
861
  readonly __SIGIL_BRAND__: {
843
862
  Sigil: true;
844
863
  } & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
864
+ /**
865
+ * Check whether `other` is (or inherits from) the type instance.
866
+ *
867
+ * Allows 'instanceof' like checks but in instances.
868
+ *
869
+ * @typeParam T - The instance type.
870
+ * @param this - The instance performing the check.
871
+ * @param other - The object to test.
872
+ * @returns `true` if `other` is the same instance of this type or a subtype.
873
+ */
874
+ isOfType<T_1>(this: T_1, other: unknown): other is GetInstance<T_1>;
875
+ /**
876
+ * Strict lineage check: compares the type symbol lineage arrays element-by-element.
877
+ *
878
+ * Allows 'instanceof' like checks but in instances.
879
+ *
880
+ * @typeParam T - The instance type.
881
+ * @param this - The instance performing the check.
882
+ * @param other - The object to test.
883
+ * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
884
+ */
885
+ isOfTypeStrict<T_1>(this: T_1, other: unknown): other is /*elided*/ any;
845
886
  /**
846
887
  * Returns the human-readable sigil label of this instance's constructor.
847
888
  *
@@ -133,8 +133,7 @@
133
133
  * @param newRegistry - New Set<string> instance to use as the active registry, or `null` to disable checks.
134
134
  */
135
135
  replaceRegistry(newRegistry) {
136
- if (newRegistry)
137
- updateOptions({ registry: new _SigilRegistry(newRegistry) });
136
+ if (newRegistry) updateOptions({ registry: new _SigilRegistry(newRegistry) });
138
137
  else updateOptions({ registry: newRegistry });
139
138
  }
140
139
  /**
@@ -191,9 +190,7 @@
191
190
  * @param thisArg - Optional `this` context for the callback.
192
191
  */
193
192
  forEach(callback, thisArg) {
194
- this._registry.forEach(
195
- (ctor, label) => callback.call(thisArg, ctor, label)
196
- );
193
+ this._registry.forEach((ctor, label) => callback.call(thisArg, ctor, label));
197
194
  }
198
195
  /**
199
196
  * Get the size (number of entries) of the active registry.
@@ -254,9 +251,7 @@
254
251
  var __SIGIL__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL__");
255
252
  var __SIGIL_BASE__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL_BASE__");
256
253
  var __DECORATED__ = /* @__PURE__ */ Symbol.for("@Sigil.__DECORATED__");
257
- var __INHERITANCE_CHECKED__ = /* @__PURE__ */ Symbol.for(
258
- "@Sigil.__INHERITANCE_CHECKED__"
259
- );
254
+ var __INHERITANCE_CHECKED__ = /* @__PURE__ */ Symbol.for("@Sigil.__INHERITANCE_CHECKED__");
260
255
  var __LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL__");
261
256
  var __TYPE__ = /* @__PURE__ */ Symbol.for("@Sigil.__TYPE__");
262
257
  var __TYPE_LINEAGE__ = /* @__PURE__ */ Symbol.for("@Sigil.__TYPE_LINEAGE__");
@@ -422,8 +417,7 @@
422
417
 
423
418
  // src/core/mixin.ts
424
419
  function Sigilify(Base, label, opts) {
425
- if (isSigilCtor(Base))
426
- throw new Error(`[Sigil Error] 'Sigilify(${label})' already siglified.`);
420
+ if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already siglified.`);
427
421
  let l;
428
422
  if (label) {
429
423
  verifyLabel(label, opts);
@@ -476,9 +470,7 @@
476
470
  const ctor = getConstructor(this);
477
471
  if (!ctor) {
478
472
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
479
- throw new Error(
480
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
481
- );
473
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
482
474
  return;
483
475
  }
484
476
  checkInheritance(ctor);
@@ -495,10 +487,6 @@
495
487
  /**
496
488
  * Check whether `other` is (or inherits from) the type represented by the calling constructor.
497
489
  *
498
- * Implementation detail:
499
- * - Uses the other instance's `__TYPE_SET__` for O(1) membership test.
500
- * - O(1) and reliable as long as `OPTIONS.skipLabelInheritanceCheck` is `false`.
501
- *
502
490
  * This replaces `instanceof` so that checks remain valid across bundles/realms
503
491
  * and when subclassing.
504
492
  *
@@ -508,32 +496,61 @@
508
496
  * @returns `true` if `other` is an instance of this type or a subtype.
509
497
  */
510
498
  static isOfType(other) {
499
+ var _a;
511
500
  if (!isSigilInstance(other)) return false;
512
- const otherCtor = getConstructor(other);
513
- if (!otherCtor) return false;
514
- const otherSet = otherCtor[__TYPE_SET__];
515
- return !!otherSet && otherSet.has(this.SigilType);
501
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_SET__];
502
+ const thisType = this[__TYPE__];
503
+ return !!otherSet && otherSet.has(thisType);
516
504
  }
517
505
  /**
518
506
  * Strict lineage check: compares the type symbol lineage arrays element-by-element.
519
507
  *
520
- * Implementation detail:
521
- * - Works in O(n) time where n is the depth of the lineage.
522
- * - Reliable when `OPTIONS.skipLabelInheritanceCheck` is `false`.
523
- *
524
508
  * @typeParam T - The calling constructor type.
525
509
  * @param this - The constructor performing the check.
526
510
  * @param other - The object to test.
527
511
  * @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
528
512
  */
529
513
  static isOfTypeStrict(other) {
514
+ var _a;
530
515
  if (!isSigilInstance(other)) return false;
531
- const otherCtor = getConstructor(other);
532
- if (!otherCtor) return false;
533
- const otherLineage = otherCtor[__TYPE_LINEAGE__];
516
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_LINEAGE__];
534
517
  const thisLineage = this[__TYPE_LINEAGE__];
535
518
  return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
536
519
  }
520
+ /**
521
+ * Check whether `other` is (or inherits from) the type instance.
522
+ *
523
+ * Allows 'instanceof' like checks but in instances.
524
+ *
525
+ * @typeParam T - The instance type.
526
+ * @param this - The instance performing the check.
527
+ * @param other - The object to test.
528
+ * @returns `true` if `other` is the same instance of this type or a subtype.
529
+ */
530
+ isOfType(other) {
531
+ var _a;
532
+ if (!isSigilInstance(other)) return false;
533
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_SET__];
534
+ const thisType = getConstructor(this)[__TYPE__];
535
+ return !!otherSet && otherSet.has(thisType);
536
+ }
537
+ /**
538
+ * Strict lineage check: compares the type symbol lineage arrays element-by-element.
539
+ *
540
+ * Allows 'instanceof' like checks but in instances.
541
+ *
542
+ * @typeParam T - The instance type.
543
+ * @param this - The instance performing the check.
544
+ * @param other - The object to test.
545
+ * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
546
+ */
547
+ isOfTypeStrict(other) {
548
+ var _a, _b;
549
+ if (!isSigilInstance(other)) return false;
550
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_LINEAGE__];
551
+ const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__TYPE_LINEAGE__];
552
+ return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
553
+ }
537
554
  /**
538
555
  * Returns the human-readable sigil label of this instance's constructor.
539
556
  *
@@ -544,9 +561,7 @@
544
561
  const ctor = getConstructor(this);
545
562
  if (!ctor) {
546
563
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
547
- throw new Error(
548
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
549
- );
564
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
550
565
  return "@Sigil.unknown";
551
566
  }
552
567
  return ctor.SigilLabel;
@@ -561,9 +576,7 @@
561
576
  const ctor = getConstructor(this);
562
577
  if (!ctor) {
563
578
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
564
- throw new Error(
565
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
566
- );
579
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
567
580
  return /* @__PURE__ */ Symbol.for("@Sigil.unknown");
568
581
  }
569
582
  return ctor.SigilType;
@@ -578,9 +591,7 @@
578
591
  const ctor = getConstructor(this);
579
592
  if (!ctor) {
580
593
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
581
- throw new Error(
582
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
583
- );
594
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
584
595
  return [/* @__PURE__ */ Symbol.for("@Sigil.unknown")];
585
596
  }
586
597
  return ctor.SigilTypeLineage;
@@ -595,9 +606,7 @@
595
606
  const ctor = getConstructor(this);
596
607
  if (!ctor) {
597
608
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
598
- throw new Error(
599
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
600
- );
609
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
601
610
  return /* @__PURE__ */ new Set([/* @__PURE__ */ Symbol.for("@Sigil.unknown")]);
602
611
  }
603
612
  return ctor.SigilTypeSet;
@@ -609,8 +618,7 @@
609
618
  return Sigilified;
610
619
  }
611
620
  function SigilifyAbstract(Base, label, opts) {
612
- if (isSigilCtor(Base))
613
- throw new Error(`[Sigil Error] 'Sigilify(${label})' already siglified.`);
621
+ if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already siglified.`);
614
622
  let l;
615
623
  if (label) {
616
624
  verifyLabel(label, opts);
@@ -663,9 +671,7 @@
663
671
  const ctor = getConstructor(this);
664
672
  if (!ctor) {
665
673
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
666
- throw new Error(
667
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
668
- );
674
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
669
675
  return;
670
676
  }
671
677
  checkInheritance(ctor);
@@ -695,11 +701,11 @@
695
701
  * @returns `true` if `other` is an instance of this type or a subtype.
696
702
  */
697
703
  static isOfType(other) {
698
- if (!isSigilInstance(other)) return false;
699
- const otherCtor = getConstructor(other);
700
- if (!otherCtor) return false;
701
- const otherSet = otherCtor[__TYPE_SET__];
702
- return !!otherSet && otherSet.has(this.SigilType);
704
+ var _a;
705
+ if (!isSigilInstance(other) || !isSigilCtor(this)) return false;
706
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_SET__];
707
+ const thisType = this[__TYPE__];
708
+ return !!otherSet && otherSet.has(thisType);
703
709
  }
704
710
  /**
705
711
  * Strict lineage check: compares the type symbol lineage arrays element-by-element.
@@ -714,13 +720,46 @@
714
720
  * @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
715
721
  */
716
722
  static isOfTypeStrict(other) {
717
- if (!isSigilInstance(other)) return false;
718
- const otherCtor = getConstructor(other);
719
- if (!otherCtor) return false;
720
- const otherLineage = otherCtor[__TYPE_LINEAGE__];
723
+ var _a;
724
+ if (!isSigilInstance(other) || !isSigilCtor(this)) return false;
725
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_LINEAGE__];
721
726
  const thisLineage = this[__TYPE_LINEAGE__];
722
727
  return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
723
728
  }
729
+ /**
730
+ * Check whether `other` is (or inherits from) the type instance.
731
+ *
732
+ * Allows 'instanceof' like checks but in instances.
733
+ *
734
+ * @typeParam T - The instance type.
735
+ * @param this - The instance performing the check.
736
+ * @param other - The object to test.
737
+ * @returns `true` if `other` is the same instance of this type or a subtype.
738
+ */
739
+ isOfType(other) {
740
+ var _a;
741
+ if (!isSigilInstance(other) || !isSigilInstance(this)) return false;
742
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_SET__];
743
+ const thisType = getConstructor(this)[__TYPE__];
744
+ return !!otherSet && otherSet.has(thisType);
745
+ }
746
+ /**
747
+ * Strict lineage check: compares the type symbol lineage arrays element-by-element.
748
+ *
749
+ * Allows 'instanceof' like checks but in instances.
750
+ *
751
+ * @typeParam T - The instance type.
752
+ * @param this - The instance performing the check.
753
+ * @param other - The object to test.
754
+ * @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
755
+ */
756
+ isOfTypeStrict(other) {
757
+ var _a, _b;
758
+ if (!isSigilInstance(other) || !isSigilInstance(this)) return false;
759
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_LINEAGE__];
760
+ const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__TYPE_LINEAGE__];
761
+ return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
762
+ }
724
763
  /**
725
764
  * Returns the human-readable sigil label of this instance's constructor.
726
765
  *
@@ -731,9 +770,7 @@
731
770
  const ctor = getConstructor(this);
732
771
  if (!ctor) {
733
772
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
734
- throw new Error(
735
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
736
- );
773
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
737
774
  return "@Sigil.unknown";
738
775
  }
739
776
  return ctor.SigilLabel;
@@ -748,9 +785,7 @@
748
785
  const ctor = getConstructor(this);
749
786
  if (!ctor) {
750
787
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
751
- throw new Error(
752
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
753
- );
788
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
754
789
  return /* @__PURE__ */ Symbol.for("@Sigil.unknown");
755
790
  }
756
791
  return ctor.SigilType;
@@ -765,9 +800,7 @@
765
800
  const ctor = getConstructor(this);
766
801
  if (!ctor) {
767
802
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
768
- throw new Error(
769
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
770
- );
803
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
771
804
  return [/* @__PURE__ */ Symbol.for("@Sigil.unknown")];
772
805
  }
773
806
  return ctor.SigilTypeLineage;
@@ -782,9 +815,7 @@
782
815
  const ctor = getConstructor(this);
783
816
  if (!ctor) {
784
817
  if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
785
- throw new Error(
786
- `[Sigil Error] 'Sigilify(${label})' instance without constructor`
787
- );
818
+ throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
788
819
  return /* @__PURE__ */ new Set([/* @__PURE__ */ Symbol.for("@Sigil.unknown")]);
789
820
  }
790
821
  return ctor.SigilTypeSet;