Skip to content

Commit

Permalink
feat(importStar): Cache non‑module results
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Jan 6, 2021
1 parent 54a056a commit 27c4b32
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
21 changes: 14 additions & 7 deletions tslib.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
17 changes: 12 additions & 5 deletions tslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 27c4b32

Please sign in to comment.