function repairFunction(name, declaration) {
    let FunctionInstance;
    try {
      // eslint-disable-next-line no-new-func
      FunctionInstance = (0, eval)(declaration);
    } catch (e) {
      if (e instanceof SyntaxError) {
        // Prevent failure on platforms where async and/or generators
        // are not supported.
        return;
      }
      // Re-throw
      throw e;
    }
    const FunctionPrototype = getPrototypeOf(FunctionInstance);

    // Prevents the evaluation of source when calling constructor on the
    // prototype of functions.
    const TamedFunction = function() {
      throw new TypeError('Not available');
    };
    defineProperties(TamedFunction, { name: { value: name } });

    // (new Error()).constructors does not inherit from Function, because Error
    // was defined before ES6 classes. So we don't need to repair it too.

    // (Error()).constructor inherit from Function, which gets a tamed
    // constructor here.

    // todo: in an ES6 class that does not inherit from anything, what does its
    // constructor inherit from? We worry that it inherits from Function, in
    // which case instances could give access to unsafeFunction. markm says
    // we're fine: the constructor inherits from Object.prototype

    // This line replaces the original constructor in the prototype chain
    // with the tamed one. No copy of the original is peserved.
    defineProperties(FunctionPrototype, {
      constructor: { value: TamedFunction }
    });

    // This line sets the tamed constructor's prototype data property to
    // the original one.
    defineProperties(TamedFunction, {
      prototype: { value: FunctionPrototype }
    });

    if (TamedFunction !== Function.prototype.constructor) {
      // Ensures that all functions meet "instanceof Function" in a realm.
      setPrototypeOf(TamedFunction, Function.prototype.constructor);
    }
  }
/**
   * The process to repair constructors:
   * 1. Create an instance of the function by evaluating syntax
   * 2. Obtain the prototype from the instance
   * 3. Create a substitute tamed constructor
   * 4. Replace the original constructor with the tamed constructor
   * 5. Replace tamed constructor prototype property with the original one
   * 6. Replace its [[Prototype]] slot with the tamed constructor of Function
   */
The process to repair constructors:
1. Create an instance of the function by evaluating syntax
2. Obtain the prototype from the instance
3. Create a substitute tamed constructor
4. Replace the original constructor with the tamed constructor
5. Replace tamed constructor prototype property with the original one
6. Replace its [[Prototype]] slot with the tamed constructor of Function
The process to repair constructors : 1 . Create an instance of the function by evaluating syntax 2 . Obtain the prototype from the instance 3 . Create a substitute tamed constructor 4 . Replace the original constructor with the tamed constructor 5 . Replace tamed constructor prototype property with the original one 6 . Replace its [[ Prototype ]] slot with the tamed constructor of Function
function repairFunction(name, declaration) {
    let FunctionInstance;
    try {
      FunctionInstance = (0, eval)(declaration);
    } catch (e) {
      if (e instanceof SyntaxError) {
        return;
      }
      throw e;
    }
    const FunctionPrototype = getPrototypeOf(FunctionInstance);
    const TamedFunction = function() {
      throw new TypeError('Not available');
    };
    defineProperties(TamedFunction, { name: { value: name } });
    defineProperties(FunctionPrototype, {
      constructor: { value: TamedFunction }
    });
    defineProperties(TamedFunction, {
      prototype: { value: FunctionPrototype }
    });
    if (TamedFunction !== Function.prototype.constructor) {
      setPrototypeOf(TamedFunction, Function.prototype.constructor);
    }
  }
function repairFunction ( name , declaration ) { let FunctionInstance ; try { FunctionInstance = ( 0 , eval ) ( declaration ) ; } catch ( e ) { if ( e instanceof SyntaxError ) { return ; } throw e ; } const FunctionPrototype = getPrototypeOf ( FunctionInstance ) ; const TamedFunction = function ( ) { throw new TypeError ( 'Not available' ) ; } ; defineProperties ( TamedFunction , { name : { value : name } } ) ; defineProperties ( FunctionPrototype , { constructor : { value : TamedFunction } } ) ; defineProperties ( TamedFunction , { prototype : { value : FunctionPrototype } } ) ; if ( TamedFunction !== Function . prototype . constructor ) { setPrototypeOf ( TamedFunction , Function . prototype . constructor ) ; } }
The process to repair constructors:
 1.
The process to repair constructors : 1 .
// eslint-disable-next-line no-new-func // Prevent failure on platforms where async and/or generators // are not supported. // Re-throw // Prevents the evaluation of source when calling constructor on the // prototype of functions. // (new Error()).constructors does not inherit from Function, because Error // was defined before ES6 classes. So we don't need to repair it too. // (Error()).constructor inherit from Function, which gets a tamed // constructor here. // todo: in an ES6 class that does not inherit from anything, what does its // constructor inherit from? We worry that it inherits from Function, in // which case instances could give access to unsafeFunction. markm says // we're fine: the constructor inherits from Object.prototype // This line replaces the original constructor in the prototype chain // with the tamed one. No copy of the original is peserved. // This line sets the tamed constructor's prototype data property to // the original one. // Ensures that all functions meet "instanceof Function" in a realm.