From d5417cf8076752bd38ce20e07ca4b769d766e09c Mon Sep 17 00:00:00 2001 From: kkapsner Date: Mon, 2 Nov 2020 13:11:50 +0100 Subject: [PATCH] Improved exportFunctionWithName To reduce the need of double exports. --- lib/extension.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/extension.js b/lib/extension.js index 8eaf6db..7d8a6e2 100644 --- a/lib/extension.js +++ b/lib/extension.js @@ -95,7 +95,8 @@ }; scope.exportFunctionWithName = function exportFunctionWithName(func, context, name){ - const exportedTry = exportFunction(func, context, {allowCrossOriginArguments: true}); + const targetObject = scope.getWrapped(context).Object.create(null); + const exportedTry = exportFunction(func, targetObject, {allowCrossOriginArguments: true, defineAs: name}); if (exportedTry.name === name){ return exportedTry; }