Commit b1325c1

Anton Golub <antongolub@antongolub.com>
2025-06-19 10:57:25
refactor: internal naming imprs (#1232)
1 parent a32e54c
build/cli.js
build/index.cjs
@@ -179,7 +179,7 @@ function retry(count, d, cb) {
     if (typeof d === "function") return retry(count, 0, d);
     (0, import_node_assert.default)(cb);
     const total = count;
-    const getDelay = typeof d === "object" ? d : function* () {
+    const gen = typeof d === "object" ? d : function* () {
       while (true) yield (0, import_util.parseDuration)(d);
     }();
     let attempt = 0;
@@ -190,7 +190,7 @@ function retry(count, d, cb) {
         return yield cb();
       } catch (err) {
         lastErr = err;
-        const delay = getDelay.next().value;
+        const delay = gen.next().value;
         import_core.$.log({
           kind: "retry",
           total,
@@ -217,10 +217,7 @@ function* expBackoff(max = "60s", delay = "100ms") {
 }
 function spinner(title, callback) {
   return __async(this, null, function* () {
-    if (typeof title === "function") {
-      callback = title;
-      title = "";
-    }
+    if (typeof title === "function") return spinner("", title);
     if (import_core.$.quiet || import_node_process.default.env.CI) return callback();
     let i = 0;
     const stream = import_core.$.log.output || import_node_process.default.stderr;
src/core.ts
@@ -42,7 +42,6 @@ import {
   which,
   ps,
   VoidStream,
-  type ChalkInstance,
   type TSpawnStore,
 } from './vendor-core.ts'
 import {
src/goods.ts
@@ -182,7 +182,7 @@ export async function retry<T>(
   assert(cb)
 
   const total = count
-  const getDelay =
+  const gen =
     typeof d === 'object'
       ? d
       : (function* () {
@@ -197,7 +197,7 @@ export async function retry<T>(
       return await cb()
     } catch (err) {
       lastErr = err
-      const delay = getDelay.next().value
+      const delay = gen.next().value
 
       $.log({
         kind: 'retry',
@@ -232,10 +232,7 @@ export async function spinner<T>(
   title: string | (() => T),
   callback?: () => T
 ): Promise<T> {
-  if (typeof title === 'function') {
-    callback = title
-    title = ''
-  }
+  if (typeof title === 'function') return spinner('', title)
   if ($.quiet || process.env.CI) return callback!()
 
   let i = 0
src/util.ts
@@ -16,8 +16,8 @@ import os from 'node:os'
 import path from 'node:path'
 import fs, { type Mode } from 'node:fs'
 import { type Buffer } from 'node:buffer'
-import { type TSpawnStoreChunks } from './vendor-core.ts'
 import process from 'node:process'
+import { type TSpawnStoreChunks } from './vendor-core.ts'
 
 export { isStringLiteral } from './vendor-core.ts'
 
test/goods.test.ts
@@ -139,7 +139,7 @@ describe('goods', () => {
       }
     })
 
-    test('trows undefined on count misconfiguration', async () => {
+    test('throws undefined on count misconfiguration', async () => {
       try {
         await retry(0, () => 'ok')
       } catch (e) {
.size-limit.json
@@ -62,7 +62,7 @@
       "README.md",
       "LICENSE"
     ],
-    "limit": "867.40 kB",
+    "limit": "867.35 kB",
     "brotli": false,
     "gzip": false
   }