packages/devtools-components/src/tree.js
function oncePerAnimationFrame(fn) {
  let animationId = null;
  let argsToPass = null;
  return function(...args) {
    argsToPass = args;
    if (animationId !== null) {
      return;
    }

    animationId = requestAnimationFrame(() => {
      fn.call(this, ...argsToPass);
      animationId = null;
      argsToPass = null;
    });
  };
}
function oncePerAnimationFrame(fn) {
  let animationId = null;
  let argsToPass = null;
  return function(...args) {
    argsToPass = args;
    if (animationId !== null) {
      return;
    }

    animationId = requestAnimationFrame(() => {
      fn.call(this, ...argsToPass);
      animationId = null;
      argsToPass = null;
    });
  };
}
function oncePerAnimationFrame ( fn ) { let animationId = null ; let argsToPass = null ; return function ( ... args ) { argsToPass = args ; if ( animationId !== null ) { return ; } animationId = requestAnimationFrame ( ( ) => { fn . call ( this , ... argsToPass ) ; animationId = null ; argsToPass = null ; } ) ; } ; }
Create a function that calls the given function `fn` only once per animation
frame.

@param {Function} fn
@returns {Function}
Create a function that calls the given function fn only once per animation frame .