From 27c4b326002415c8f695241668da9d5af1b056cc Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Thu, 24 Oct 2019 10:20:00 +0200 Subject: [PATCH] =?UTF-8?q?feat(importStar):=20Cache=C2=A0non=E2=80=91modu?= =?UTF-8?q?le=C2=A0results?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tslib.es6.js | 21 ++++++++++++++------- tslib.js | 17 ++++++++++++----- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/tslib.es6.js b/tslib.es6.js index bd73dce..8083232 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -209,13 +209,20 @@ var __setModuleDefault = Object.create ? (function(o, v) { o["default"] = v; }; -export function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -} +export var __importStar = function (mod) { + var cache = typeof WeakMap === "function" ? new WeakMap() : null; + __importStar = function (mod) { + if (mod === null || (typeof mod !== "object" && typeof mod !== "function")) return { default: mod }; + if (mod.__esModule) return mod; + if (cache && cache.has(mod)) return cache.get(mod); + var result = {}; + for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + if (cache) cache.set(mod, result); + return result; + } + return __importStar(mod); +}; export function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; diff --git a/tslib.js b/tslib.js index 4e2462e..8d350de 100644 --- a/tslib.js +++ b/tslib.js @@ -251,11 +251,18 @@ var __createBinding; }; __importStar = function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; + var cache = typeof WeakMap === "function" ? new WeakMap() : null; + __importStar = function (mod) { + if (mod === null || (typeof mod !== "object" && typeof mod !== "function")) return { default: mod }; + if (mod.__esModule) return mod; + if (cache && cache.has(mod)) return cache.get(mod); + var result = {}; + for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + if (cache) cache.set(mod, result); + return result; + } + return __importStar(mod); }; __importDefault = function (mod) {