Skip to content

Commit 7ce5abe

Browse files
committed
feature: try-to-catch: get rid of cjs
1 parent f627f7d commit 7ce5abe

6 files changed

Lines changed: 3 additions & 97 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Wrap function to avoid `try-catch` block, resolves `[error, result]`;
2626
Simplest example with `async-await`:
2727

2828
```js
29-
import tryToCatch from 'try-to-catch';
29+
import {tryToCatch} from 'try-to-catch';
3030

3131
const reject = Promise.reject.bind(Promise);
3232
await tryToCatch(reject, 'hi');

lib/try-to-catch.cjs

Lines changed: 0 additions & 6 deletions
This file was deleted.

lib/try-to-catch.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export const tryToCatch = async (fn, ...args) => {
1010
}
1111
};
1212

13-
export default tryToCatch;
14-
1513
function check(fn) {
1614
if (!isFn(fn))
1715
throw Error('fn should be a function!');

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
66
"description": "function try-catch wrapper for promises",
77
"homepage": "http://github.com/coderaiser/try-to-catch",
8-
"main": "lib/try-to-catch.cjs",
8+
"main": "lib/try-to-catch.js",
99
"exports": {
10-
".": {
11-
"require": "./lib/try-to-catch.cjs",
12-
"import": "./lib/try-to-catch.js"
13-
}
10+
".": "./lib/try-to-catch.js"
1411
},
1512
"repository": {
1613
"type": "git",

test/try-to-catch.cjs

Lines changed: 0 additions & 75 deletions
This file was deleted.

test/try-to-catch.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,3 @@ test('try-to-catch: resolves: promisify', async (t) => {
6464
t.equal(data, 3, 'should not be error');
6565
t.end();
6666
});
67-
68-
test('try-to-catch: nested', async (t) => {
69-
const fn = () => 5;
70-
const [, data] = await tryToCatch.tryToCatch(fn);
71-
72-
t.equal(data, 5, 'should not be error');
73-
t.end();
74-
});

0 commit comments

Comments
 (0)