event-toolkit
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

event-toolkit

Toolkit for DOM events.

npm i event-toolkit pnpm add event-toolkit yarn add event-toolkit

API

# AbortOptions src/abort.ts#L4
# DispatchOptions src/dispatch.ts#L4
# EventOptions src/event.ts#L7
# OnOptions src/on.ts#L15
# QueueOptions src/queue.ts#L11
# EventHandler

    # this
    # event

      E & {

      # currentTarget
      # target

        Element

      }

EventHandler(this, event)  =>

    any
# Hooks src/queue.ts#L6
# before src/queue.ts#L7

    # ()

      ()  =>

        void

# AnyFn src/helpers.ts#L1

    # (args)

      # args

        any []

      (args)  =>

        any

| void | false
# Dispatch src/dispatch.ts#L10
# Fn

    # (args)

      # args

      (args)  =>

# Off src/on.ts#L10

    # ()

      ()  =>

        void

# On src/on.ts#L11
# OnEvent src/on.ts#L12
# OnGetter src/on.ts#L13
# Task src/task.ts#L17
# MouseButton  =  ... src/constants.ts#L1
# Task(fn, self, args) src/task.ts#L17

    # fn

      Fn<any, any>

    # self

      any

    # args

      any

    Task(fn, self, args)  =>

# abort(fn) src/abort.ts#L10

    # fn(signal)

      # signal

        AbortSignal

      fn(signal)  =>

abort<P, R>(fn)  =>

    Fn<P, R extends Promise<any> ? R : Promise<R>>
# chain(rest) src/helpers.ts#L3

    # rest

    chain(rest)  =>

      # ()

        ()  =>

          any
    # rest

    chain(rest)  =>

      # ()

        ()  =>

          any
# dispatch(el, nameOrEvent, detail, init) src/dispatch.ts#L19

    # el
    # nameOrEvent

      Narrow<K, string> | Event

    # detail

      DetailOf<T, template-literal>

    # init

      CustomEventInit<any>

    dispatch<T extends  EventTarget, K>(el, nameOrEvent, detail, init)  =>

      any
# dispatchBind(el) src/dispatch.ts#L29

    # el

    dispatchBind<T extends  EventTarget>(el)  =>

      Fluent<
      # (nameOrEvent, detail, init)

        # nameOrEvent

          Event | Narrow<K, string>

        # detail

          DetailOf<T, template-literal>

        # init

          CustomEventInit<any>

        <K>(nameOrEvent, detail, init)  =>

          any
      , Required<DispatchOptions>>
# event(fn) src/event.ts#L74

    # fn  =  ...

    event<T extends  Target, E extends  Event>(fn)  =>

      Fn<[ named-tuple-member ], any>
# on(el) src/on.ts#L78

    # el

    on<T extends  EventTarget>(el)  =>

    # el
    # key

    on<T extends  EventTarget, K>(el, key)  =>

# onAll(target, listener, args) src/helpers.ts#L17

    # target

      EventTarget

    # listener

      EventListener

    # args

      any []

    onAll(target, listener, args)  =>

      # ()

        ()  =>

          void
# queue(queueFn) src/queue.ts#L252

    # queueFn

    queue<P, R>(queueFn)  =>

      Fn<P, R extends Promise<any> ? R : Promise<R>>
# taskGroup(other, tasks) src/task.ts#L30

    # other
    # tasks

    taskGroup(other, tasks)  =>

      void
# taskRun(task, res) src/task.ts#L23

    # task
    # res

      any

    taskRun(task, res)  =>

      any
# wrapEvent(options) src/event.ts#L16

    # options  =  ...

    wrapEvent(options)  =>

      # (fn)

        # fn  =  ...

        <T extends  Target, E extends  Event>(fn)  =>

          Fn<[ named-tuple-member ], any>
# wrapQueue(options) src/queue.ts#L29

    # options  =  {}

    wrapQueue(options)  =>

      # (queueFn)

        # queueFn

        <P, R>(queueFn)  =>

          Fn<P, R extends Promise<any> ? R : Promise<R>>

Credits

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2023 stagas

Readme

Keywords

none

Package Sidebar

Install

npm i event-toolkit

Weekly Downloads

209

Version

1.3.1

License

MIT

Unpacked Size

287 kB

Total Files

53

Last publish

Collaborators

  • stagas