@trenskow/results 0.0.16 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js CHANGED
@@ -5,7 +5,8 @@ module.exports = {
5
5
  "mocha": true
6
6
  },
7
7
  "parserOptions": {
8
- "ecmaVersion": 2017
8
+ "ecmaVersion": 2017,
9
+ "sourceType": "module"
9
10
  },
10
11
  "extends": "eslint:recommended",
11
12
  "rules": {
package/index.js CHANGED
@@ -1,9 +1,6 @@
1
- 'use strict';
1
+ import Puqeue from 'puqeue';
2
2
 
3
- const
4
- Puqeue = require('puqeue');
5
-
6
- exports = module.exports = async (promises, options = {}) => {
3
+ let results = async (promises, options = {}) => {
7
4
 
8
5
  if (!promises) return [[], []];
9
6
 
@@ -20,7 +17,7 @@ exports = module.exports = async (promises, options = {}) => {
20
17
  resolved.push(await Promise.resolve(promise));
21
18
  } catch (err) {
22
19
  rejected.push(err);
23
- }
20
+ }
24
21
  });
25
22
  }));
26
23
 
@@ -28,10 +25,17 @@ exports = module.exports = async (promises, options = {}) => {
28
25
 
29
26
  };
30
27
 
31
- exports.resolved = async (promises, options) => {
32
- return (await exports(promises, options))[0];
28
+ const resolved = async (promises, options) => {
29
+ return (await results(promises, options))[0];
33
30
  };
34
31
 
35
- exports.rejected = async (promises, options) => {
36
- return (await exports(promises, options))[1];
32
+ const rejected = async (promises, options) => {
33
+ return (await results(promises, options))[1];
37
34
  };
35
+
36
+ results.resolved = resolved;
37
+ results.rejected = rejected;
38
+
39
+ export default results;
40
+
41
+ export { resolved, rejected };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@trenskow/results",
3
- "version": "0.0.16",
3
+ "version": "0.1.0",
4
4
  "description": "Executes an array of promises and returns their resolved or rejected results.",
5
5
  "main": "index.js",
6
+ "type": "module",
6
7
  "scripts": {
7
8
  "test": "./node_modules/mocha/bin/_mocha test/index.js"
8
9
  },
package/test/index.js CHANGED
@@ -1,14 +1,9 @@
1
- 'use strict';
1
+ import { use as chaiUse, expect } from 'chai';
2
+ import chaiAsPromised from 'chai-as-promised';
2
3
 
3
- const
4
- chai = require('chai'),
5
- { expect } = chai,
6
- chaiAsPromised = require('chai-as-promised');
4
+ import results from '../index.js';
7
5
 
8
- chai.use(chaiAsPromised);
9
-
10
- const
11
- results = require('../');
6
+ chaiUse(chaiAsPromised);
12
7
 
13
8
  describe('results', function() {
14
9
  it ('should come back with resolved and rejected results separated.', () => {