Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps #35

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -6,14 +6,14 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '16.x'
- run: npm install
- run: npm run build
- run: npm test
env:
CI: true

- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm install
- run: npm run build
- run: npm test
env:
CI: true
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -12,9 +12,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 14
node-version: 20
registry-url: https://registry.npmjs.org/
cache: npm
- run: npm ci
8 changes: 4 additions & 4 deletions karma.config.cjs
Original file line number Diff line number Diff line change
@@ -19,9 +19,9 @@ module.exports = function (config) {
config.set({
frameworks: ['mocha', 'chai'],
files: [
{ pattern: 'dist/index.js', type: 'module' },
{ pattern: 'dist/async-tasks.js', type: 'module' },
{ pattern: 'test/test.js', type: 'module' }
{pattern: 'dist/index.js', type: 'module'},
{pattern: 'dist/async-tasks.js', type: 'module'},
{pattern: 'test/test.js', type: 'module'},
],
reporters: ['mocha'],
port: 9876,
@@ -30,6 +30,6 @@ module.exports = function (config) {
browsers: ['ChromeHeadless'],
autoWatch: false,
singleRun: true,
concurrency: Infinity
concurrency: Infinity,
})
}
4,446 changes: 3,245 additions & 1,201 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -15,30 +15,30 @@
"scripts": {
"clean": "rm -rf dist",
"lint": "eslint src/*.ts test/*.js",
"prebuild": "npm run clean && npm run lint && npm run compile",
"prebuild": "npm run clean && npm run compile",
"compile": "tsc",
"build": "rollup -c",
"pretest": "npm run build",
"test": "karma start karma.config.cjs",
"test": "npm run lint && karma start karma.config.cjs",
"prepublishOnly": "npm run build",
"postpublish": "npm publish --ignore-scripts --@github:registry='https://npm.pkg.github.com'"
},
"prettier": "@github/prettier-config",
"devDependencies": {
"@github/prettier-config": "0.0.4",
"@github/prettier-config": "0.0.6",
"chai": "^4.1.2",
"chromium": "^3.0.3",
"eslint": "^7.7.0",
"eslint-plugin-github": "^4.1.1",
"karma": "^6.3.16",
"eslint": "^8.0.1",
"eslint-plugin-github": "^5.0.2",
"karma": "^6.4.4",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-chrome-launcher": "^3.2.0",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^10.2.0",
"mocha": "^10.7.3",
"nodejs-websocket": "^1.7.2",
"rollup": "^2.26.3",
"typescript": "^3.9.7"
"rollup": "^4.24.0",
"typescript": "^5.6.3"
},
"eslintConfig": {
"extends": [
8 changes: 4 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const pkg = require('./package.json')
import pkg from './package.json' assert {type: 'json'}

export default {
input: 'dist/index.js',
output: {
file: pkg['module'],
format: 'es'
}
file: pkg.module,
format: 'es',
},
}
5 changes: 3 additions & 2 deletions src/async-tasks.ts
Original file line number Diff line number Diff line change
@@ -67,14 +67,15 @@ export async function retry<T>(
fn: () => Promise<T>,
attempts: number,
maxDelay = Infinity,
signal?: AbortSignal
signal?: AbortSignal,
): Promise<T> {
const aborted = signal ? whenAborted(signal) : null
for (let i = 0; i < attempts; i++) {
try {
const op = aborted ? Promise.race([fn(), aborted]) : fn()
return await op
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
if (e.name === 'AbortError') throw e
if (i === attempts - 1) throw e
const ms = Math.pow(2, i) * 1000
6 changes: 4 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// eslint-disable-next-line import/extensions
import {retry, timeout, wait} from '../dist/async-tasks.js'
// eslint-disable-next-line import/extensions
import {StableSocket} from '../dist/index.js'

class Delegate {
@@ -175,7 +177,7 @@ describe('async-tasks', function () {
try {
const value = await retry(fn, 1)
assert.equal(42, value)
} catch (e) {
} catch {
assert.fail('rejected')
}
})
@@ -185,7 +187,7 @@ describe('async-tasks', function () {
try {
const value = await retry(fn, 2)
assert.equal(42, value)
} catch (e) {
} catch {
assert.fail('rejected')
}
})
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -5,7 +5,8 @@
"strict": true,
"declaration": true,
"outDir": "dist",
"removeComments": true
"removeComments": true,
"skipLibCheck": true
},
"files": [
"src/index.ts"