function safeCall (fn, args) {
  // Get the function arguments as an array
  args = Array.prototype.slice.call(arguments, 1);

  // Replace the callback function with a wrapper that ensures it will only be called once
  let callback = call.once(args.pop());
  args.push(callback);

  try {
    fn.apply(null, args);
  }
  catch (err) {
    callback(err);
  }
}
function safeCall (fn, args) {
  
  args = Array.prototype.slice.call(arguments, 1);

  
  let callback = call.once(args.pop());
  args.push(callback);

  try {
    fn.apply(null, args);
  }
  catch (err) {
    callback(err);
  }
}
function safeCall ( fn , args ) { // Get the function arguments as an array args = Array . prototype . slice . call ( arguments , 1 ) ; // Replace the callback function with a wrapper that ensures it will only be called once let callback = call . once ( args . pop ( ) ) ; args . push ( callback ) ; try { fn . apply ( null , args ) ; } catch ( err ) { callback ( err ) ; } }
Calls a function with the given arguments, and ensures that the error-first callback is _always_
invoked exactly once, even if the function throws an error.

@param {function} fn - The function to invoke
@param {...*} args - The arguments to pass to the function. The final argument must be a callback function.
Calls a function with the given arguments and ensures that the error - first callback is _always_ invoked exactly once even if the function throws an error .