From 8786d39d4b9e507dd8e151da65a09c40d0c26dec Mon Sep 17 00:00:00 2001 From: James Bronder <36022278+jbronder@users.noreply.github.com> Date: Fri, 2 May 2025 01:08:43 -0700 Subject: [PATCH] fix(ext/node): use primordials in `ext/node/polyfills/internal/options.ts` (#29119) Towards #24236. This PR replaces `Map` and `String` methods with their primordial versions. --- ext/node/polyfills/internal/options.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ext/node/polyfills/internal/options.ts b/ext/node/polyfills/internal/options.ts index 16ac62a69f..5262e9b5f6 100644 --- a/ext/node/polyfills/internal/options.ts +++ b/ext/node/polyfills/internal/options.ts @@ -20,10 +20,13 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -// TODO(petamoriken): enable prefer-primordials for node polyfills -// deno-lint-ignore-file prefer-primordials - import { getOptions } from "ext:deno_node/internal_binding/node_options.ts"; +import { primordials } from "ext:core/mod.js"; +const { + MapPrototypeGet, + StringPrototypeSlice, + StringPrototypeStartsWith, +} = primordials; let optionsMap: Map; @@ -38,11 +41,14 @@ function getOptionsFromBinding() { export function getOptionValue(optionName: string) { const options = getOptionsFromBinding(); - if (optionName.startsWith("--no-")) { - const option = options.get("--" + optionName.slice(5)); + if (StringPrototypeStartsWith(optionName, "--no-")) { + const option = MapPrototypeGet( + options, + "--" + StringPrototypeSlice(optionName, 5), + ); return option && !option.value; } - return options.get(optionName)?.value; + return MapPrototypeGet(options, optionName)?.value; }