@jbrowse/mobx-state-tree 5.10.0 → 5.10.2

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.
@@ -5745,6 +5745,33 @@ function union(optionsOrType, ...otherTypes) {
5745
5745
  function isUnionType(type) {
5746
5746
  return (type.flags & TypeFlags.Union) > 0;
5747
5747
  }
5748
+ /**
5749
+ * Returns the member types of a union.
5750
+ *
5751
+ * Wrapper types (`optional`, `refinement`, `late`) inherit the union flag from
5752
+ * the type they wrap, so `isUnionType` is true for e.g. an optional-of-union,
5753
+ * but their `getSubTypes()` reports the single wrapped type rather than the
5754
+ * union's members. This drills through those wrappers until the union's member
5755
+ * array surfaces.
5756
+ *
5757
+ * @param type a type for which `isUnionType` is true
5758
+ * @returns the array of member types of the underlying union
5759
+ */
5760
+ function getUnionSubtypes(type) {
5761
+ if (!isUnionType(type)) {
5762
+ throw fail("expected a union type");
5763
+ }
5764
+ let subtypes = type.getSubTypes();
5765
+ while (typeof subtypes === "object" &&
5766
+ subtypes !== null &&
5767
+ !Array.isArray(subtypes)) {
5768
+ subtypes = subtypes.getSubTypes();
5769
+ }
5770
+ if (!Array.isArray(subtypes)) {
5771
+ throw fail("could not extract subtypes from union type");
5772
+ }
5773
+ return subtypes;
5774
+ }
5748
5775
 
5749
5776
  /**
5750
5777
  * @hidden
@@ -6921,5 +6948,5 @@ const types = {
6921
6948
  resilient
6922
6949
  };
6923
6950
 
6924
- export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware, createActionTrackingMiddleware2, decorate, destroy, detach, escapeJsonPath, flow, getChildType, getEnv, getIdentifier, getLivelinessChecking, getMembers, getNodeId, getParent, getParentOfType, getPath, getPathParts, getPropertyMembers, getRelativePath, getRoot, getRunningActionContext, getSnapshot, getType, hasParent, hasParentOfType, isActionContextChildOf, isActionContextThisOrChildOf, isAlive, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isProtected, isReferenceType, isRefinementType, isRoot, isStateTreeNode, isType, isUnionType, isValidReference, joinJsonPath, onAction, onPatch, onSnapshot, process$1 as process, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setDevMode, setLivelinessChecking, setLivelynessChecking, splitJsonPath, types as t, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, unescapeJsonPath, unprotect, walk };
6951
+ export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware, createActionTrackingMiddleware2, decorate, destroy, detach, escapeJsonPath, flow, getChildType, getEnv, getIdentifier, getLivelinessChecking, getMembers, getNodeId, getParent, getParentOfType, getPath, getPathParts, getPropertyMembers, getRelativePath, getRoot, getRunningActionContext, getSnapshot, getType, getUnionSubtypes, hasParent, hasParentOfType, isActionContextChildOf, isActionContextThisOrChildOf, isAlive, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isProtected, isReferenceType, isRefinementType, isRoot, isStateTreeNode, isType, isUnionType, isValidReference, joinJsonPath, onAction, onPatch, onSnapshot, process$1 as process, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setDevMode, setLivelinessChecking, setLivelynessChecking, splitJsonPath, types as t, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, unescapeJsonPath, unprotect, walk };
6925
6952
  //# sourceMappingURL=mobx-state-tree.mjs.map