mirror of https://codeberg.org/pzp/pzp-goals.git
refactor: rename some assert functions
This commit is contained in:
parent
1b32169541
commit
3f73dada5b
10
lib/index.js
10
lib/index.js
|
@ -30,7 +30,7 @@ const Obz = require('obz')
|
|||
* @param {{ db: PPPPPDB | null }} peer
|
||||
* @returns {asserts peer is { db: PPPPPDB }}
|
||||
*/
|
||||
function assertDBExists(peer) {
|
||||
function assertDBPlugin(peer) {
|
||||
if (!peer.db) throw new Error('goals plugin requires ppppp-db plugin')
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ function assertDBExists(peer) {
|
|||
* @param {{ record: PPPPPRecord | null }} peer
|
||||
* @returns {asserts peer is { record: PPPPPRecord }}
|
||||
*/
|
||||
function assertRecordExists(peer) {
|
||||
function assertRecordPlugin(peer) {
|
||||
if (!peer.record) throw new Error('goals plugin requires ppppp-record plugin')
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class GoalImpl {
|
|||
* @param {unknown} config
|
||||
*/
|
||||
function initGoals(peer, config) {
|
||||
assertDBExists(peer)
|
||||
assertDBPlugin(peer)
|
||||
// Constants:
|
||||
const EMPTY_RANGE = /** @type {Range} */ ([1, 0])
|
||||
|
||||
|
@ -138,7 +138,7 @@ function initGoals(peer, config) {
|
|||
case 'set':
|
||||
return [0, maxDepth]
|
||||
case 'record':
|
||||
assertRecordExists(peer)
|
||||
assertRecordPlugin(peer)
|
||||
const minDepth = peer.record.getMinRequiredDepth(goal.id)
|
||||
return [minDepth, maxDepth]
|
||||
case 'newest':
|
||||
|
@ -174,7 +174,7 @@ function initGoals(peer, config) {
|
|||
* @returns {Purpose}
|
||||
*/
|
||||
function getRecordPurpose(rec) {
|
||||
assertDBExists(peer)
|
||||
assertDBPlugin(peer)
|
||||
let servesAsTrail = false
|
||||
|
||||
// Check whether this record is a goalful root of some tangle:
|
||||
|
|
Loading…
Reference in New Issue