New Upstream Release - node-promise

Ready changes

Summary

Merged new upstream version: 8.3.0 (was: 8.2.0).

Resulting package

Built on 2022-11-17T14:38 (took 2m58s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases node-promise

Lintian Result

Diff

diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..dbe993d
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: [ForbesLindesay]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: npm/promise # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/.github/workflows/rollingversions-canary.yml b/.github/workflows/rollingversions-canary.yml
new file mode 100644
index 0000000..46220bd
--- /dev/null
+++ b/.github/workflows/rollingversions-canary.yml
@@ -0,0 +1,40 @@
+name: Publish Canary
+
+on:
+  push:
+    branches:
+      - master
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        node-version: [14.x]
+
+    steps:
+      - uses: actions/checkout@v2
+      - name: Use Node.js ${{ matrix.node-version }}
+        uses: actions/setup-node@v1
+        with:
+          node-version: ${{ matrix.node-version }}
+      - run: yarn install
+      - run: yarn build
+      - run: yarn test
+
+  publish-canary:
+    runs-on: ubuntu-latest
+    needs: test
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions/setup-node@v1
+        with:
+          node-version: 14.x
+          registry-url: 'https://registry.npmjs.org'
+      - run: yarn install
+      - run: yarn build
+      - run: npx rollingversions publish --canary $GITHUB_RUN_NUMBER
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.github/workflows/rollingversions.yml b/.github/workflows/rollingversions.yml
new file mode 100644
index 0000000..a3a55d8
--- /dev/null
+++ b/.github/workflows/rollingversions.yml
@@ -0,0 +1,38 @@
+name: Release
+on:
+  repository_dispatch:
+    types: [rollingversions_publish_approved]
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        node-version: [14.x]
+
+    steps:
+      - uses: actions/checkout@v2
+      - name: Use Node.js ${{ matrix.node-version }}
+        uses: actions/setup-node@v1
+        with:
+          node-version: ${{ matrix.node-version }}
+      - run: yarn install
+      - run: yarn build
+      - run: yarn test
+
+  publish:
+    runs-on: ubuntu-latest
+    needs: test
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions/setup-node@v1
+        with:
+          node-version: 14.x
+          registry-url: 'https://registry.npmjs.org'
+      - run: yarn install
+      - run: yarn build
+      - run: npx rollingversions publish
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..cfdcb7d
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,24 @@
+name: Test
+
+on:
+  pull_request:
+    branches:
+      - master
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        node-version: [14.x]
+
+    steps:
+      - uses: actions/checkout@v2
+      - name: Use Node.js ${{ matrix.node-version }}
+        uses: actions/setup-node@v1
+        with:
+          node-version: ${{ matrix.node-version }}
+      - run: yarn install
+      - run: yarn build
+      - run: yarn test
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b0b5a36
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+components
+build
+node_modules
+/lib
+/domains
+/setimmediate
+coverage
+package-lock.json
\ No newline at end of file
diff --git a/Readme.md b/Readme.md
index 5933338..2896ce5 100644
--- a/Readme.md
+++ b/Readme.md
@@ -141,6 +141,20 @@ Promise.all([Promise.resolve('a'), 'b', Promise.resolve('c')])
   })
 ```
 
+#### Promise.any(array)
+
+Returns a single promise that fulfills as soon as any of the promises in the iterable fulfills, with the value of the fulfilled promise.  If no promises in the iterable fulfill (if all of the given promises are rejected), then the returned promise is rejected with an `AggregateError`
+
+```js
+var rejected = Promise.reject(0);
+var first = new Promise(function (resolve){ setTimeout(resolve, 100, 'quick') });
+var second = new Promise(function (resolve){ setTimeout(resolve, 500, 'slow') });
+
+var promises = [rejected, first, second];
+
+Promise.any(promises) // => succeeds with `quick`
+```
+
 #### Promise.allSettled(array)
 
 Returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects that each describes the outcome of each promise.
diff --git a/debian/changelog b/debian/changelog
index ca07a48..4dbda55 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+node-promise (8.3.0-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Thu, 17 Nov 2022 14:35:53 -0000
+
 node-promise (8.2.0-1) unstable; urgency=medium
 
   * Update standards version to 4.6.1, no changes needed.
diff --git a/debian/patches/fix-for-acorn-6.diff b/debian/patches/fix-for-acorn-6.diff
index 57b4e0f..9f36254 100644
--- a/debian/patches/fix-for-acorn-6.diff
+++ b/debian/patches/fix-for-acorn-6.diff
@@ -3,8 +3,10 @@ Author: Xavier Guimard <yadd@debian.org>
 Forwarded: no
 Last-Update: 2020-03-22
 
---- a/build.js
-+++ b/build.js
+Index: node-promise.git/build.js
+===================================================================
+--- node-promise.git.orig/build.js
++++ node-promise.git/build.js
 @@ -3,7 +3,7 @@
  var fs = require('fs');
  var rimraf = require('rimraf');
diff --git a/index.d.ts b/index.d.ts
index f168a7b..9a60f93 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -60,6 +60,21 @@ interface ThenPromiseConstructor {
    */
   new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => any): ThenPromise<T>;
 
+
+  /**
+   * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
+   * @param values An array or iterable of Promises.
+   * @returns A new Promise.
+   */
+  any<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
+
+  /**
+   * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
+   * @param values An array or iterable of Promises.
+   * @returns A new Promise.
+   */
+  any<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>
+
   /**
    * Creates a Promise that is resolved with an array of results when all
    * of the provided Promises resolve or reject.
diff --git a/src/es6-extensions.js b/src/es6-extensions.js
index 3f48e4a..f3e6198 100644
--- a/src/es6-extensions.js
+++ b/src/es6-extensions.js
@@ -140,3 +140,47 @@ Promise.race = function (values) {
 Promise.prototype['catch'] = function (onRejected) {
   return this.then(null, onRejected);
 };
+
+function getAggregateError(errors){
+  if(typeof AggregateError === 'function'){
+    return new AggregateError(errors,'All promises were rejected');
+  }
+
+  var error = new Error('All promises were rejected');
+
+  error.name = 'AggregateError';
+  error.errors = errors;
+
+  return error;
+}
+
+Promise.any = function promiseAny(values) {
+  return new Promise(function(resolve, reject) {
+    var promises = iterableToArray(values);
+    var hasResolved = false;
+    var rejectionReasons = [];
+
+    function resolveOnce(value) {
+      if (!hasResolved) {
+        hasResolved = true;
+        resolve(value);
+      }
+    }
+
+    function rejectionCheck(reason) {
+      rejectionReasons.push(reason);
+
+      if (rejectionReasons.length === promises.length) {
+        reject(getAggregateError(rejectionReasons));
+      }
+    }
+
+    if(promises.length === 0){
+      reject(getAggregateError(rejectionReasons));
+    } else {
+      promises.forEach(function(value){
+        Promise.resolve(value).then(resolveOnce, rejectionCheck);
+      });
+    }
+  });
+};
diff --git a/test/extensions-tests.js b/test/extensions-tests.js
index 321a168..f38485a 100644
--- a/test/extensions-tests.js
+++ b/test/extensions-tests.js
@@ -130,6 +130,76 @@ describe('extensions', function () {
       })
     })
   })
+  describe('Promise.any(...)', function () {
+    describe('an array', function () {
+      describe('that is empty', function () {
+        it('returns a rejected promise for an empty array', function (done) {
+          var res = Promise.any([])
+          assert(res instanceof Promise)
+          res.catch(function (err) {
+            assert(Array.isArray(err.errors))
+            assert(err.errors.length === 0)
+          }).nodeify(done)
+        })
+        it('returns a rejected promise for not argument', function (done) {
+          var res = Promise.any()
+          assert(res instanceof Promise)
+          res.catch(function (err) {
+            assert(err instanceof Error)
+          }).nodeify(done)
+        })
+      })
+      describe('of objects', function () {
+        it('resolved with a first fulfilled value', function (done) {
+          var res = Promise.any([a, b, c])
+          assert(res instanceof Promise)
+          res.then(function (res) {
+            assert(a === res)
+          }).nodeify(done)
+        })
+      })
+      describe('of promises', function () {
+        it('resolved with a first fulfilled value', function (done) {
+          var res = Promise.any([B, C])
+          assert(res instanceof Promise)
+          res.then(function (res) {
+            assert(b === res)
+          }).nodeify(done)
+        })
+      })
+      describe('of mixed values', function () {
+        it('returns a promise for an array containing the fulfilled values', function (done) {
+          var res = Promise.any([c,B])
+          assert(res instanceof Promise)
+          res.then(function (res) {
+            assert(res === c)
+          }).nodeify(done)
+        })
+      })
+      describe('containing all rejected promise', function () {
+        it('rejects the resulting promise', function (done) {
+          var rejectionB ={test:2}
+          var rejectedB = new Promise(function (resolve, reject) { reject(rejectionB) })
+          var res = Promise.any([rejected, rejectedB])
+          assert(res instanceof Promise)
+          res.catch(function (err) {
+            assert(Array.isArray(err.errors))
+            assert(err.errors[0] === rejection)
+            assert(err.errors[1] === rejectionB)
+            assert(err.errors.length === 2)
+          }).nodeify(done)
+        })
+      })
+      describe('when given a foreign promise', function () {
+        it('should provide the correct value of `this`', function (done) {
+          var p = {then: function (onFulfilled) { onFulfilled({self: this}); }};
+          Promise.any([p]).then(function (results) {
+            assert(p === results.self);
+          }).nodeify(done);
+        });
+      });
+    })
+  })
   describe('Promise.allSettled(...)', function () {
     describe('an array', function () {
       describe('that is empty', function () {

Debdiff

File lists identical (after any substitutions)

No differences were encountered in the control files

More details

Full run details