restructure index.js for better exported types

This commit is contained in:
Andre Staltz 2023-09-20 15:33:32 +03:00
parent 037aec208c
commit d8a0f841fe
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
2 changed files with 123 additions and 129 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ pnpm-lock.yaml
package-lock.json
coverage
*~
lib/*.d.ts

View File

@ -26,9 +26,7 @@ const Obz = require('obz')
*/
/**
* @param {{
* db: PPPPPDB | null,
* }} peer
* @param {{ db: PPPPPDB | null }} peer
* @returns {asserts peer is { db: PPPPPDB }}
*/
function assertDBExists(peer) {
@ -110,18 +108,11 @@ class GoalImpl {
}
}
module.exports = {
name: 'goals',
manifest: {},
permissions: {
anonymous: {},
},
/**
* @param {{ db: PPPPPDB | null, close: ClosableHook }} peer
* @param {{ path: string; keypair: Keypair; }} config
/**
* @param {{ db: PPPPPDB | null }} peer
* @param {unknown} config
*/
init(peer, config) {
function initGoals(peer, config) {
assertDBExists(peer)
// Constants:
const EMPTY_RANGE = /** @type {Range} */ ([1, 0])
@ -246,5 +237,7 @@ module.exports = {
list,
listen,
}
},
}
exports.name = 'goals'
exports.init = initGoals