Browse Source

ref: remove types.ts

Sv443 1 year ago
parent
commit
2b6e2dbb85
4 changed files with 24 additions and 32 deletions
  1. 0 1
      lib/index.ts
  2. 4 1
      lib/misc.ts
  3. 20 1
      lib/onSelector.ts
  4. 0 29
      lib/types.ts

+ 0 - 1
lib/index.ts

@@ -3,4 +3,3 @@ export * from "./dom";
 export * from "./math";
 export * from "./misc";
 export * from "./onSelector";
-export type * from "./types";

+ 4 - 1
lib/misc.ts

@@ -1,4 +1,7 @@
-import type { FetchAdvancedOpts } from "./types";
+export type FetchAdvancedOpts = RequestInit & Partial<{
+  /** Timeout in milliseconds after which the fetch call will be canceled with an AbortController signal */
+  timeout: number;
+}>;
 
 /**
  * Automatically appends an `s` to the passed `word`, if `num` is not equal to 1

+ 20 - 1
lib/onSelector.ts

@@ -1,4 +1,23 @@
-import type { OnSelectorOpts } from "./types";
+export type OnSelectorOpts<TElem extends Element = HTMLElement> = SelectorOptsOne<TElem> | SelectorOptsAll<TElem>;
+
+type SelectorOptsOne<TElem extends Element> = SelectorOptsBase & {
+  /** Whether to use `querySelectorAll()` instead - default is false */
+  all?: false;
+  /** Gets called whenever the selector was found in the DOM */
+  listener: (element: TElem) => void;
+};
+
+type SelectorOptsAll<TElem extends Element> = SelectorOptsBase & {
+  /** Whether to use `querySelectorAll()` instead - default is false */
+  all: true;
+  /** Gets called whenever the selector was found in the DOM */
+  listener: (elements: NodeListOf<TElem>) => void;
+};
+
+type SelectorOptsBase = {
+  /** Whether to call the listener continuously instead of once - default is false */
+  continuous?: boolean;
+};
 
 const selectorMap = new Map<string, OnSelectorOpts[]>();
 

+ 0 - 29
lib/types.ts

@@ -1,29 +0,0 @@
-//#SECTION selector exists
-
-export type OnSelectorOpts<TElem extends Element = HTMLElement> = SelectorOptsOne<TElem> | SelectorOptsAll<TElem>;
-
-type SelectorOptsOne<TElem extends Element> = SelectorOptsBase & {
-  /** Whether to use `querySelectorAll()` instead - default is false */
-  all?: false;
-  /** Gets called whenever the selector was found in the DOM */
-  listener: (element: TElem) => void;
-};
-
-type SelectorOptsAll<TElem extends Element> = SelectorOptsBase & {
-  /** Whether to use `querySelectorAll()` instead - default is false */
-  all: true;
-  /** Gets called whenever the selector was found in the DOM */
-  listener: (elements: NodeListOf<TElem>) => void;
-};
-
-type SelectorOptsBase = {
-  /** Whether to call the listener continuously instead of once - default is false */
-  continuous?: boolean;
-};
-
-//#SECTION fetch advanced
-
-export type FetchAdvancedOpts = RequestInit & Partial<{
-  /** Timeout in milliseconds after which the fetch call will be canceled with an AbortController signal */
-  timeout: number;
-}>;