Socket
Socket
Sign inDemoInstall

event-replay-helpers

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    event-replay-helpers

Helpers for serialising and rehydrating JavaScript mouse and touch events


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
9.98 kB
Created
Weekly downloads
 

Readme

Source

Event Serialisation / Rehydration Helpers

Ever needed to save JavaScript (mouse/touch) events to the server to be replayed later? I did once, so now you have this shitty library.

yarn add event-replay-helpers

alt Demo GIF

Currently only works for mousemove, mousedown, mouseup, mouseover, click, touchstart, touchmove, and touchend for potential security reasons - I will deal with this soon (maybe)

import { rehydrateSerialisedEvent, serialiseEvent } from 'event-replay-helpers'

// the serialiseEvent function also accepts an optional startTimeStamp (number) - useful for recording a bunch of events with offsets to play them back at

document.addEventListener('click', (e) => {
  // serialise it, this can be sent to the server and stored in a database if you like
  const serialisedEvent = serialiseEvent(e)

  // wait a second and play it again
  setTimeout(() => {
    // this actually a function that dispatches the event when we call it, then returns the event as it's result
    const dispatchEvent = rehydrateSerialisedEvent(e)
    const rehydratedEvent = dispatchEvent()
  }, 1000)
})

To better understand how it works and how to use it, just have a look at the index.ts - it's only ~130 lines of code.

FAQs

Last updated on 23 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc