npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@playframe/oversync

v1.0.0

Published

Frame Rendering Engine

Readme

PlayFrame

OverSync

0.4 kB Frame Rendering Engine

Installation

npm install --save @playframe/oversync

Functionality Overview

import oversync from '@playframe/oversync'

const sync = oversync(Date.now, requestAnimationFrame)

Each method schedules given function to be executed in specific time and order

sync.next(fn) // events handling and dom read
sync.catch(fn) // error handling
sync.then(fn) // data work is done here
sync.finally(fn) // finilizing data
sync.render(fn) // dom manipulation

// Actual requestAnimationFrame callback
// No work should be done here
sync.frame(fn)

Execution strategy

Render a frame_0 first, then request a new frame_1 and immediately do work. After work is done VM is idling for up to 10ms until frame callback is fired and frame_1 finally rendered. Any event occuring after work is done but before frame_1 is rendered will schedule actual work to be done onlly after frame_1 is rendered

1ms Request frame_0 and setTimeout(work_for_frame_1)
2ms frame_0 is rendered by browser
3ms Request frame_1
4ms work_for_frame_1: read dom, do work, write dom
... idle
8ms Click: sync.next(click_handler) for frame_2
... idle
10ms Fetch: sync.then(fetch_handler) for frame_2
...idle
15ms Animation callback: setTimeout(work_for_frame_2)
16ms frame_1 is rendered
17ms Request frame_2
18ms work_for_frame_2: read dom, do work, write dom
...

Annotated Source

Let's define a higher order function that would take a now timestamp function, scheduling next function and optionally a list steps of desired execution order and method names and an optional step method name.

module.exports = (now, next, steps=[
  'next', 'catch', 'then', 'finally', 'render'
], step = 'frame')=>

For each step we would prepare and empty array

  step_ops = []
  steps_ops = steps.map => []

For measuring time deltas we would have a fancy runner function

  delta_runner = delta(now) runner

schedule function for requesting next frame in which we would run our frame operations and schedule work for the rest of the steps

  schedule = scheduler(next) =>
    run = delta_runner()
    run step_ops
    setTimeout => steps_ops.forEach run

A pusher function that will schedule on every push

  push_and_run = pusher schedule

Dynamically creating methods that would push operations and schedule execution and returning sync

  sync = {}

  sync[step] = push_and_run step_ops
  steps.forEach (step, i)=>
    sync[step] = push_and_run steps_ops[i]

  sync

Abstract functions

Our scheduler is creating a throttled schedule

scheduler = (next)=>(f)=>
  _scheduled = false
  g = (x)=> _scheduled = false; f x
  => unless _scheduled then _scheduled = true; next g; return

This pusher is creating a function that will run task before pushing op to ops

pusher = (task)=>(ops)=>(op)=> do task; ops.push op; return

Feeding timestamps produced by now to a given f like our runner

delta = (now)=>(f)=>
  _prev_ts = now()
  => f delta: (ts = now()) - _prev_ts, ts: (_prev_ts = ts)

This runner will feed x to a list of given ops. It will recover if any operation fails. Clearing ops list at the end

runner = (x)=>(ops)=>
  i = 0
  # Rechecking length in outer loop
  # could push more ops while running
  while (i < length = ops.length)
    try
      ops[i++] x while i < length
    catch e
      console.error e
      recover e if recover = ops[i - 1].r # recovering

  ops.length = 0 # mutating 👹
  return