function withScope(
  ...rest
) {
  // eslint-disable-next-line deprecation/deprecation
  const hub$1 = hub.getCurrentHub();

  // If a scope is defined, we want to make this the active scope instead of the default one
  if (rest.length === 2) {
    const [scope, callback] = rest;
    if (!scope) {
      // eslint-disable-next-line deprecation/deprecation
      return hub$1.withScope(callback);
    }

    // eslint-disable-next-line deprecation/deprecation
    return hub$1.withScope(() => {
      // eslint-disable-next-line deprecation/deprecation
      hub$1.getStackTop().scope = scope ;
      return callback(scope );
    });
  }

  // eslint-disable-next-line deprecation/deprecation
  return hub$1.withScope(rest[0]);
}
Either creates a new active scope, or sets the given scope as active scope in the given callback.