From ffb58a8a6e2d145121feeb3cfb4465a362994979 Mon Sep 17 00:00:00 2001 From: Samual Date: Tue, 16 Apr 2024 21:32:03 +0100 Subject: [PATCH] make `Object.call.bind` something shorter when available #130 --- src/processScript/transform.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/processScript/transform.ts b/src/processScript/transform.ts index 0ba6119..ca29f37 100644 --- a/src/processScript/transform.ts +++ b/src/processScript/transform.ts @@ -675,7 +675,12 @@ export const transform = (file: File, sourceCode: string, { t.callExpression( t.memberExpression( t.memberExpression( - t.identifier(`Object`), + t.identifier( + // non-null assertion is safe because this path is only reached if there is no + // `let Object` in the script which means we will always find `"Object"` in the worst + // case scenario + globalFunctionsUnder7Characters.find(name => !program.scope.hasOwnBinding(name))! + ), t.identifier(`call`) ), t.identifier(`bind`) -- knotmirror 0.0.1