Skip to content

Commit

Permalink
chore: modernize dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
seriousme committed Feb 25, 2025
1 parent b10124a commit abfca3f
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 87 deletions.
2 changes: 0 additions & 2 deletions abstract.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict'

const parent = require('aedes-persistence/abstract')

module.exports = parent
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('neostandard')({})
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const QlobberSub = require('qlobber/aedes/qlobber-sub')
const { Packet } = require('aedes-persistence')
const MultiStream = require('multistream')
const parallel = require('fastparallel')
const { EventEmitter } = require('events')
const { EventEmitter } = require('node:events')
const QlobberOpts = {
wildcard_one: '+',
wildcard_some: '#',
Expand Down Expand Up @@ -154,8 +154,8 @@ class CachedPersistence extends EventEmitter {
cleanSubscriptions (client, cb) {
this.subscriptionsByClient(client, (err, subs, client) => {
if (err || !subs) { return cb(err, client) }
subs = subs.map(subToTopic)
this.removeSubscriptions(client, subs, cb)
const newSubs = subs.map(subToTopic)
this.removeSubscriptions(client, newSubs, cb)
})
}

Expand Down Expand Up @@ -208,7 +208,7 @@ function subToTopic (sub) {
}

function getKey (clientId, isSub, topic) {
return clientId + '-' + (isSub ? 'sub_' : 'unsub_') + (topic || '')
return `${clientId}-${isSub ? 'sub_' : 'unsub_'}${topic || ''}`
}

module.exports = CachedPersistence
Expand Down
144 changes: 69 additions & 75 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,77 +1,71 @@
{
"name": "aedes-cached-persistence",
"version": "9.0.0",
"description": "Abstract class to write an Aedes persistence with in-process caching of subscriptions",
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"lint": "npm run lint:standard",
"lint:standard": "standard --verbose | snazzy",
"unit": "tape test.js | faucet",
"test": "npm run lint && npm run unit && tsd",
"test:types": "tsd",
"coverage": "nyc --reporter=lcov tape test.js",
"test:ci": "npm run lint && npm run coverage",
"license-checker": "license-checker --production --onlyAllow='MIT;ISC;BSD-3-Clause;BSD-2-Clause'",
"release": "read -p 'GITHUB_TOKEN: ' GITHUB_TOKEN && export GITHUB_TOKEN=$GITHUB_TOKEN && release-it --disable-metrics"
},
"release-it": {
"github": {
"release": true
},
"git": {
"tagName": "v${version}"
},
"hooks": {
"before:init": [
"npm run test"
]
},
"npm": {
"publish": true
}
},
"pre-commit": [
"test"
],
"engines": {
"node": ">=14"
},
"repository": {
"type": "git",
"url": "git+https://github.com/moscajs/aedes-cached-persistence.git"
},
"keywords": [
"aedes",
"persistence",
"cache",
"in-memory"
],
"author": "Matteo Collina <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/moscajs/aedes-cached-persistence/issues"
},
"homepage": "https://github.com/moscajs/aedes-cached-persistence#readme",
"devDependencies": {
"aedes": "^0.46.3",
"concat-stream": "^2.0.0",
"faucet": "0.0.1",
"license-checker": "^25.0.1",
"mqemitter": "^4.5.0",
"nyc": "^15.1.0",
"pump": "^3.0.0",
"release-it": "^15.0.0",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"tape": "^5.2.1",
"through2": "^4.0.2",
"tsd": "^0.20.0"
},
"dependencies": {
"aedes-persistence": "^9.1.2",
"fastparallel": "^2.4.1",
"multistream": "^4.1.0",
"qlobber": "^7.0.0"
}
"name": "aedes-cached-persistence",
"version": "9.0.0",
"description": "Abstract class to write an Aedes persistence with in-process caching of subscriptions",
"main": "index.js",
"types": "types/index.d.ts",
"scripts": {
"lint": "eslint",
"lint:fix": "eslint --fix",
"unit": "node --test test.js",
"test": "npm run lint && npm run unit && tsd",
"test:typescript": "tsd",
"coverage": "nyc --reporter=lcov node --test test.js",
"test:ci": "npm run lint && npm run coverage && npm run test:typescript",
"license-checker": "license-checker --production --onlyAllow='MIT;ISC;BSD-3-Clause;BSD-2-Clause'",
"release": "read -p 'GITHUB_TOKEN: ' GITHUB_TOKEN && export GITHUB_TOKEN=$GITHUB_TOKEN && release-it --disable-metrics"
},
"release-it": {
"github": {
"release": true
},
"git": {
"tagName": "v${version}"
},
"hooks": {
"before:init": [
"npm run test"
]
},
"npm": {
"publish": true
}
},
"pre-commit": [
"test"
],
"engines": {
"node": ">=20"
},
"repository": {
"type": "git",
"url": "git+https://github.com/moscajs/aedes-cached-persistence.git"
},
"keywords": [
"aedes",
"persistence",
"cache",
"in-memory"
],
"author": "Matteo Collina <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/moscajs/aedes-cached-persistence/issues"
},
"homepage": "https://github.com/moscajs/aedes-cached-persistence#readme",
"devDependencies": {
"aedes": "^0.51.3",
"eslint": "^9.21.0",
"license-checker": "^25.0.1",
"neostandard": "^0.12.1",
"nyc": "^17.1.0",
"release-it": "^18.1.2",
"tsd": "^0.31.2"
},
"dependencies": {
"aedes-persistence": "^10.0.0",
"fastparallel": "^2.4.1",
"multistream": "^4.1.0",
"qlobber": "^8.0.1"
}
}
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const test = require('tape').test
const test = require('node:test')
const CachedPersistence = require('./')
const Memory = require('aedes-persistence')
const abs = require('./abstract')
Expand All @@ -16,9 +16,9 @@ class MyPersistence extends CachedPersistence {
'createRetainedStream',
'outgoingStream', 'subscriptionsByClient',
'getWill', 'streamWill', 'getClientList', 'destroy']
methods.forEach((key) => {
for (const key of methods) {
this[key] = this.backend[key].bind(this.backend)
})
}
// putWill is a special because it needs this.broker.id
this.putWill = (client, packet, cb) => {
this.backend.broker = this.broker
Expand Down
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type {
CallbackError,
Packet,
} from 'aedes-persistence';
import type { EventEmitter } from 'events';
import type { Readable } from 'stream';
import type { EventEmitter } from 'node:events';
import type { Readable } from 'node:stream';

export type { Packet } from 'aedes-persistence';

Expand Down
2 changes: 1 addition & 1 deletion types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
CallbackError,
} from 'aedes-persistence';
import { expectType } from 'tsd';
import aedesCachedPersistence, { AedesCachedPersistence, Packet } from '.';
import aedesCachedPersistence, { type AedesCachedPersistence, type Packet } from '.';

expectType<AedesCachedPersistence>(aedesCachedPersistence());

Expand Down

0 comments on commit abfca3f

Please sign in to comment.