Skip to content

Commit

Permalink
Removing bluebird dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
manchicken committed Sep 7, 2023
1 parent 4016306 commit 7610217
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 55 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changes

## 0.0.3 (2023-09-07)

### Changed

- Removed dependency on Bluebird promises
- Fixed tests to work with native promises

## 0.0.2 (2022-11-10)

### Added
Expand Down
13 changes: 0 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"devDependencies": {
"@types/jest": "^29.1.1",
"bluebird": "^3.7.2",
"jest": "^29.1.2"
"@types/jest": "^29.5.4",
"jest": "^29.6.4"
},
"name": "@manchicken/promise-regulation",
"description": "This is a simple Node library to help you take a bit more control over your Promises.",
"version": "0.0.2",
"version": "0.0.3",
"main": "index.js",
"scripts": {
"test": "jest"
Expand All @@ -28,4 +27,4 @@
"url": "https://github.com/manchicken/promise-regulation/issues"
},
"homepage": "https://github.com/manchicken/promise-regulation#readme"
}
}
48 changes: 14 additions & 34 deletions src/__tests__/protected-promise.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,31 @@ const {
PromiseProtectedRejected,
} = require('../protected-promise')

const BluebirdPromise = require('bluebird')

describe('ProtectedPromise', () => {
test('protectPromise(simple promise, resolves)', async () => {
const thePromise = Promise.resolve(123)
expect(thePromise).not.toBeInstanceOf(BluebirdPromise)
const thePromise = protectPromise(Promise.resolve(123))
expect(thePromise).toBeInstanceOf(Promise)

const theProtectedPromise = protectPromise(thePromise)

expect(theProtectedPromise).resolves.toBe(123)
expect(thePromise).resolves.toBe(123)
})

test('protectPromise(simple promise, rejects)', async () => {
const thePromise = Promise.resolve().then(() => {
throw Error('TEST')
})
const theProtectedPromise = protectPromise(thePromise)

expect(theProtectedPromise).resolves.toBeInstanceOf(
PromiseProtectedRejected,
const thePromise = protectPromise(
Promise.resolve().then(() => {
throw Error('TEST')
}),
)
})

test('protectPromise(bluebird promise, resolves)', async () => {
const thePromise = BluebirdPromise.resolve(123)
expect(thePromise).toBeInstanceOf(BluebirdPromise)
expect(thePromise).not.toBeInstanceOf(Promise)

const theProtectedPromise = protectPromise(thePromise)

expect(theProtectedPromise).resolves.toBe(123)
expect(thePromise).resolves.toBeInstanceOf(PromiseProtectedRejected)
})

test('protectPromise(bluebird promise, rejects)', async () => {
const thePromise = BluebirdPromise.resolve().then(() => {
throw Error('TEST')
})
expect(thePromise).toBeInstanceOf(BluebirdPromise)
expect(thePromise).not.toBeInstanceOf(Promise)

const theProtectedPromise = protectPromise(thePromise)

expect(theProtectedPromise).resolves.toBeInstanceOf(
PromiseProtectedRejected,
test('protectPromise(promise, rejects)', async () => {
const thePromise = protectPromise(
Promise.resolve().then(() => Promise.reject(Error('TEST'))),
)
expect(thePromise).toBeInstanceOf(Promise)
expect(thePromise).not.toBeInstanceOf(Error)

expect(thePromise).resolves.toBeInstanceOf(PromiseProtectedRejected)
})
})
2 changes: 1 addition & 1 deletion src/coalesce-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {

/**
* This function will run your list of promises, and then it'll return an object containing a list of which promises resolved and which ones rejected.
* @param {Array<Promise|Bluebird>} listOfPromises - This is an `Array` of `Promise`s suitable for `Promise.all()`.
* @param {Array<Promise>} listOfPromises - This is an `Array` of `Promise`s suitable for `Promise.all()`.
* @returns {Promise<Object>} - Returns a `Promise` which resolves to an `Object` with properties `resolved` and `rejected`, containing an `Array` of `Promise`s which resolved and rejected, respectively.
* @exports
* @public
Expand Down
1 change: 0 additions & 1 deletion src/limited-concurrency.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { resolve } = require('bluebird')
const { coalescePromises } = require('./coalesce-promises')
const { protectPromise } = require('./protected-promise')

Expand Down
2 changes: 1 addition & 1 deletion src/protected-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PromiseProtectedRejected extends Error {

/**
* Protect a Promise type, regardless of which type of Promise it is.
* @param {Promise|Bluebird} ward - This is the Promise to protect.
* @param {Promise} ward - This is the Promise to protect.
* @param {Object} options - Options for protection.
* @param {Boolean} options.verbose - Log verbose messages with regard to this Promise
* @exports
Expand Down

0 comments on commit 7610217

Please sign in to comment.