From d53bbd226bb1b954de9ac7d9faf132d090ceb2c8 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sat, 22 Feb 2025 01:45:03 -0800 Subject: [PATCH] Rollback null-prototype to object prototype Name collision is unlikely and enumeration may be useful. And it is easier for JSDoc to parse normal object initialization than `Object.create`. --- src/errorStrategies.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/errorStrategies.js b/src/errorStrategies.js index 00968ad..a136b41 100644 --- a/src/errorStrategies.js +++ b/src/errorStrategies.js @@ -11,9 +11,7 @@ import { setTimeout } from 'node:timers/promises'; async function sleep(ms) { await setTimeout(ms); } -export const utils = Object.create(null, { - sleep: { value: sleep, writable: true, enumerable: true, configurable: true } -}); +export const utils = { sleep }; /** * Create a `TransformationErrorFunction` that handles errors by filling the output row with a given placeholder value. @@ -90,9 +88,5 @@ function backoff(iterations, maxExponent, value) { } } -export const ErrorStrategies = Object.create(null, { - placeholder: { value: placeholder }, - retry: { value: retry }, - backoff: { value: backoff } -}); +export const ErrorStrategies = { placeholder, retry, backoff }; Object.freeze(ErrorStrategies); \ No newline at end of file -- 2.47.3