PHP 8.2.30
Preview: index.js Size: 793 B
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/raf-schd/src/index.js

// @flow

type WrapperFn<T> = {
  [[call]]: (...T) => void,
  cancel: () => void,
};

const rafSchd = <T: $ReadOnlyArray<any>>(
  fn: (...T) => void,
): WrapperFn<T> => {
  let lastArgs: T = ([]: any);
  let frameId: ?AnimationFrameID = null;

  const wrapperFn: WrapperFn<T> = (...args: T) => {
    // Always capture the latest value
    lastArgs = args;

    // There is already a frame queued
    if (frameId) {
      return;
    }

    // Schedule a new frame
    frameId = requestAnimationFrame(() => {
      frameId = null;
      fn(...lastArgs);
    });
  };

  // Adding cancel property to result function
  wrapperFn.cancel = () => {
    if (!frameId) {
      return;
    }

    cancelAnimationFrame(frameId);
    frameId = null;
  };

  return wrapperFn;
};

export default rafSchd;

Directory Contents

Dirs: 0 × Files: 1

Name Size Perms Modified Actions
793 B lrw-r--r-- 2026-02-28 00:26:56
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).