浏览代码

@uppy/utils: remove unused `settle` (#5210)

Antoine du Hamel 10 月之前
父节点
当前提交
ba5ab4fa7c
共有 3 个文件被更改,包括 0 次插入52 次删除
  1. 0 1
      packages/@uppy/utils/package.json
  2. 0 22
      packages/@uppy/utils/src/settle.js
  3. 0 29
      packages/@uppy/utils/src/settle.test.js

+ 0 - 1
packages/@uppy/utils/package.json

@@ -46,7 +46,6 @@
     "./lib/isTouchDevice": "./lib/isTouchDevice.js",
     "./lib/prettyETA": "./lib/prettyETA.js",
     "./lib/secondsToTime": "./lib/secondsToTime.js",
-    "./lib/settle": "./lib/settle.js",
     "./lib/toArray": "./lib/toArray.js",
     "./lib/FOCUSABLE_ELEMENTS": "./lib/FOCUSABLE_ELEMENTS.js",
     "./lib/AbortController": "./lib/AbortController.js",

+ 0 - 22
packages/@uppy/utils/src/settle.js

@@ -1,22 +0,0 @@
-// TODO remove (no longer in use)
-export default function settle (promises) {
-  const resolutions = []
-  const rejections = []
-  function resolved (value) {
-    resolutions.push(value)
-  }
-  function rejected (error) {
-    rejections.push(error)
-  }
-
-  const wait = Promise.all(
-    promises.map((promise) => promise.then(resolved, rejected)),
-  )
-
-  return wait.then(() => {
-    return {
-      successful: resolutions,
-      failed: rejections,
-    }
-  })
-}

+ 0 - 29
packages/@uppy/utils/src/settle.test.js

@@ -1,29 +0,0 @@
-import { describe, expect, it } from 'vitest'
-import settle from './settle.js'
-
-describe('settle', () => {
-  it('should resolve even if all input promises reject', async () => {
-    await expect(
-      settle([
-        Promise.reject(new Error('oops')),
-        Promise.reject(new Error('this went wrong')),
-      ]),
-    ).resolves.toMatchObject({
-      successful: [],
-      failed: [new Error('oops'), new Error('this went wrong')],
-    })
-  })
-
-  it('should resolve with an object if some input promises resolve', async () => {
-    await expect(
-      settle([
-        Promise.reject(new Error('rejected')),
-        Promise.resolve('resolved'),
-        Promise.resolve('also-resolved'),
-      ]),
-    ).resolves.toMatchObject({
-      successful: ['resolved', 'also-resolved'],
-      failed: [new Error('rejected')],
-    })
-  })
-})