From 6142715c06d5eb3dbaa07901a6281ae1394483a9 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 3 Nov 2022 00:18:26 -0700 Subject: Introduce `import.meta.primordials` for builtin JS the `import.meta` object in Bun now has a `primordials` object which makes a handful of globals safe for access. Inside of bun: or node: modules, it is a special object (ownKeys is not implemented, so Object.keys() wont work on it) - Array - String - `isPromise` - `isCallable` - `isConstructable` - `tryGetById(foo, "bar')` which is like foo?.bar - `arrayPush` which is like `Array.prototype.push` - `Bun` - `isAbortSignal` cc @ThatOneBro @lawrencecchen --- src/bun.js/bindings/ZigGlobalObject.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/bun.js/bindings/ZigGlobalObject.h') diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index e91cf86bf..6863f72af 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -219,6 +219,7 @@ public: JSC::JSObject* encodeIntoObjectPrototype() { return m_encodeIntoObjectPrototype.getInitializedOnMainThread(this); } JSC::JSObject* performanceObject() { return m_performanceObject.getInitializedOnMainThread(this); } + JSC::JSObject* primordialsObject() { return m_primordialsObject.getInitializedOnMainThread(this); } JSC::JSObject* processObject() { @@ -417,6 +418,8 @@ private: LazyClassStructure m_JSReadableStateClassStructure; LazyClassStructure m_OnigurumaRegExpClassStructure; + LazyProperty m_primordialsObject; + LazyProperty m_navigatorObject; LazyProperty m_JSArrayBufferControllerPrototype; -- cgit v1.2.3