From 7abb3233a5540f50827dd1b5f10697a2cae53c75 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 14 Mar 2022 00:01:46 +0200 Subject: [PATCH 1/9] Update nodejs.yml --- .github/workflows/nodejs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index c2197a1..6f05ac7 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -19,8 +19,8 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - - name: Install Redrun, Lerna - run: npm i redrun lerna -g + - name: Install + run: npm i - name: Lint run: redrun fix:lint - name: Commit fixes From 308e27b1e2b99392d14cbc77861959f20cc36a3a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 29 Mar 2022 20:32:52 +0300 Subject: [PATCH 2/9] Update nodejs.yml --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6f05ac7..6057e15 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -20,7 +20,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - name: Install - run: npm i + run: npm i && npm i redrun -g - name: Lint run: redrun fix:lint - name: Commit fixes From 565bc5c6d731139599b984b7bbbbc7d3c652658e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 29 Mar 2022 20:40:02 +0300 Subject: [PATCH 3/9] chore(npmrc) add --- .npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..43c97e7 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false From d297ad15f2d02405eb11270c82d177f48f595abc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Apr 2022 21:44:38 +0300 Subject: [PATCH 4/9] Update nodejs.yml --- .github/workflows/nodejs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6057e15..4334372 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -12,7 +12,7 @@ jobs: matrix: node-version: - 16.x - - 17.x + - 18.x steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} @@ -28,7 +28,7 @@ jobs: with: message: chore(${{ env.NAME }}) lint using actions - name: Coverage - run: redrun coverage:ci report + run: redrun coverage report - name: Coveralls uses: coverallsapp/github-action@master with: From be385bd528bb34108cc5ca46db5f6e80748b682f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Apr 2022 21:48:31 +0300 Subject: [PATCH 5/9] feature(package) eslint-plugin-putout v15.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e50bc70..8159a91 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "coveralls": "^3.0.0", "eslint": "^8.10.0", "eslint-plugin-node": "^11.0.0", - "eslint-plugin-putout": "^14.4.0", + "eslint-plugin-putout": "^15.1.1", "madrun": "^9.0.0", "nodemon": "^2.0.2", "nyc": "^15.0.0", From c3247eff86c2e2334bded42f820f8109d324c56c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Apr 2022 21:52:04 +0300 Subject: [PATCH 6/9] chore(try-to-catch) lint --- .madrun.js | 7 ++++--- README.md | 4 ++-- package.json | 3 +-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.madrun.js b/.madrun.js index 0fd6c0c..b900b61 100644 --- a/.madrun.js +++ b/.madrun.js @@ -4,10 +4,11 @@ const {run} = require('madrun'); module.exports = { 'test': () => `tape 'test/*.js'`, - 'watch:test': () => 'nodemon -w lib -w test -x "npm test"', + 'watch:test': async () => await run('watcher', await run('test')), + 'watcher': () => 'nodemon -w test -w lib -w bin --exec', 'lint': () => 'putout .', 'fix:lint': () => run('lint', '--fix'), - 'coverage': () => 'nyc npm test', - 'report': () => 'nyc report --reporter=text-lcov | coveralls', + 'coverage': async () => `c8 ${await run('test')}`, + 'report': () => 'c8 report --reporter=lcov', }; diff --git a/README.md b/README.md index ffe0d72..76b7ce0 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Try to Catch [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL] [NPMIMGURL]: https://img.shields.io/npm/v/try-to-catch.svg?style=flat&longCache=true -[BuildStatusIMGURL]: https://img.shields.io/travis/coderaiser/try-to-catch/master.svg?style=flat&longCache=true [NPMURL]: https://npmjs.org/package/try-to-catch "npm" -[BuildStatusURL]: https://travis-ci.org/coderaiser/try-to-catch "Build Status" [CoverageURL]: https://coveralls.io/github/coderaiser/try-to-catch?branch=master [CoverageIMGURL]: https://coveralls.io/repos/coderaiser/try-to-catch/badge.svg?branch=master&service=github +[BuildStatusURL]: https://github.com/coderaiser/putout/actions?query=workflow%3A%22Node+CI%22 "Build Status" +[BuildStatusIMGURL]: https://github.com/coderaiser/putout/workflows/Node%20CI/badge.svg Functional `try-catch` wrapper for `promises`. diff --git a/package.json b/package.json index 8159a91..f71c4a7 100644 --- a/package.json +++ b/package.json @@ -30,13 +30,12 @@ "then" ], "devDependencies": { - "coveralls": "^3.0.0", + "c8": "^7.11.2", "eslint": "^8.10.0", "eslint-plugin-node": "^11.0.0", "eslint-plugin-putout": "^15.1.1", "madrun": "^9.0.0", "nodemon": "^2.0.2", - "nyc": "^15.0.0", "putout": "^25.4.1", "supertape": "^7.2.0" }, From 172b86ed4ce006e4bc0ec170145acfa1710435b1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Apr 2022 21:54:36 +0300 Subject: [PATCH 7/9] chore(try-to-catch) rm travis --- .travis.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9b08e29..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: node_js -node_js: - - 13 - - 12 - - 10 - - 8 - -script: - - npm run lint - - npm run coverage && npm run report - -notifications: - email: - on_success: never - on_failure: change - -sudo: false - From 566655bc90115b6ccb30c341ddb0df12fd4a670e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Apr 2022 21:58:15 +0300 Subject: [PATCH 8/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 76b7ce0..9fc661a 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ [NPMURL]: https://npmjs.org/package/try-to-catch "npm" [CoverageURL]: https://coveralls.io/github/coderaiser/try-to-catch?branch=master [CoverageIMGURL]: https://coveralls.io/repos/coderaiser/try-to-catch/badge.svg?branch=master&service=github -[BuildStatusURL]: https://github.com/coderaiser/putout/actions?query=workflow%3A%22Node+CI%22 "Build Status" -[BuildStatusIMGURL]: https://github.com/coderaiser/putout/workflows/Node%20CI/badge.svg +[BuildStatusURL]: https://github.com/coderaiser/try-to-catch/actions?query=workflow%3A%22Node+CI%22 "Build Status" +[BuildStatusIMGURL]: https://github.com/coderaiser/try-to-catch/workflows/Node%20CI/badge.svg Functional `try-catch` wrapper for `promises`. From e0a161fabdeec3da40fc5d5e170f89ca50bb7629 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sat, 20 Sep 2025 08:43:15 +0200 Subject: [PATCH 9/9] docs: README: require -> import --- README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9fc661a..138a091 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Wrap function to avoid `try-catch` block, resolves `[error, result]`; Simplest example with `async-await`: ```js -const tryToCatch = require('try-to-catch'); +import tryToCatch from 'try-to-catch'; const reject = Promise.reject.bind(Promise); await tryToCatch(reject, 'hi'); // returns @@ -36,7 +36,7 @@ await tryToCatch(reject, 'hi'); Can be used with functions: ```js -const tryToCatch = require('try-to-catch'); +import tryToCatch from 'try-to-catch'; await tryToCatch(() => 5); // returns [null, 5]; @@ -45,12 +45,17 @@ await tryToCatch(() => 5); Advanced example: ```js -const {readFile, readdir} = require('fs/promises'); -const tryToCatch = require('try-to-catch'); +import {readFile, readdir} = from 'node:fs/promises'; +import tryToCatch from 'try-to-catch'; -read(process.argv[2]) - .then(console.log) - .catch(console.error); +const [error, data] = await tryToCatch(read, process.argv[2]); + +if (error) { + console.error(error); + process.exit(1); +} + +console.log(data); async function read(path) { const [error, data] = await tryToCatch(readFile, path, 'utf8');