Skip to content

Commit

Permalink
INSIGHT-28289 the.callback() should throw original Error if one is pa…
Browse files Browse the repository at this point in the history
…ssed (#47)

* INSIGHT-28289 the.callback() should throw existing Error if one is passed

* Test on various node versions

* No Node 10

* disable code coverage

* Fix merge conflict

* Set minimum node version to 12
  • Loading branch information
craigforster committed Sep 7, 2023
1 parent 0e25805 commit 45abd04
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .semaphore/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deployment to Production
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
os_image: ubuntu2004
blocks:
- name: "Deploy to Production"
task:
Expand Down
2 changes: 1 addition & 1 deletion .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ blocks:
- name: "Lint & Test"
matrix:
- env_var: 'NODE_VERSION'
values: ['10', '12', '14', '16', '18', '20']
values: ['12', '14', '16', '18', '20']
commands:
- sem-version node $NODE_VERSION
- checkout
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Await The Promise

[![Build Status](https://mediafly.semaphoreci.com/badges/await-the/branches/main.svg)](https://mediafly.semaphoreci.com/projects/await-the)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Build
Status](https://mediafly.semaphoreci.com/badges/await-the/branches/main.svg)](https://mediafly.semaphoreci.com/projects/await-the)
[![code style:
prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

A utility which provides straight-forward, powerful functions for working with async/await in JavaScript.

Expand All @@ -24,7 +26,7 @@ npm install await-the

<dl>
<dt><a href="#module_Limiter">Limiter</a></dt>
<dd><p>Given a collection and a task return resolved values of the task being ran per value via the emitters</p>
<dd><p>Given a collection and a task, return resolved values of the task being ran per value via emitted events.</p>
</dd>
<dt><a href="#module_all">all</a> ⇒ <code>Array</code></dt>
<dd><p>Given a collection of functions, promises, or basic types &#39;run&#39; them all at a specified limit</p>
Expand Down Expand Up @@ -86,7 +88,7 @@ as the only parameter.</p>
<a name="module_Limiter"></a>

## Limiter
Given a collection and a task return resolved values of the task being ran per value via the emitters
Given a collection and a task, return resolved values of the task being ran per value via emitted events.


| Param | Type | Description |
Expand Down Expand Up @@ -198,7 +200,7 @@ const myFunc = async (args, callback) => {
const result = await somePromise();
return the.callback(callback, null, result);
} catch (e) {
return the.callback(callback, e.message);
return the.callback(callback, e);
}
};

Expand Down Expand Up @@ -511,5 +513,4 @@ Updates this README with the [API Reference](#api-reference).

```bash
npm run docs
```

```
9 changes: 5 additions & 4 deletions jsdoc2md/README.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Await The Promise

[![Build Status](https://travis-ci.com/olono/await-the.svg?branch=master)](https://travis-ci.com/olono/await-the)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Build
Status](https://mediafly.semaphoreci.com/badges/await-the/branches/main.svg)](https://mediafly.semaphoreci.com/projects/await-the)
[![code style:
prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

A utility which provides straight-forward, powerful functions for working with async/await in JavaScript.

Expand Down Expand Up @@ -56,5 +58,4 @@ Updates this README with the [API Reference](#api-reference).

```bash
npm run docs
```

```
8 changes: 6 additions & 2 deletions lib/callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const _ = require('lodash');
* const result = await somePromise();
* return the.callback(callback, null, result);
* } catch (e) {
* return the.callback(callback, e.message);
* return the.callback(callback, e);
* }
* };
*
Expand All @@ -39,7 +39,11 @@ module.exports = (callback, err, result) => {
}

if (err) {
throw new Error(err);
if (err instanceof Error) {
throw err;
} else {
throw new Error(err);
}
}

return result;
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "await-the",
"version": "4.3.4",
"version": "4.4.0",
"description": "A utility module which provides straight-forward, powerful functions for working with async/await in JavaScript.",
"main": "index.js",
"author": "Mediafly, Inc.",
Expand Down Expand Up @@ -39,10 +39,12 @@
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-prettier": "^3.1.2",
"jsdoc-to-markdown": "^4.0.1",
"mocha": "^5.0.1",
"nyc": "^13.0.1",
"prettier": "^1.19.1",
"prettier-eslint-cli": "^5.0.0"
"jsdoc-to-markdown": "^8.0.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"prettier": "^1.19.1"
},
"engines": {
"node": ">=12.0.0"
}
}

0 comments on commit 45abd04

Please sign in to comment.