From 41fd9749a6a607f0d370c8af520f213aedef8712 Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Thu, 14 Sep 2023 14:19:33 +0300 Subject: [PATCH] export type Goal --- lib/index.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/index.js b/lib/index.js index b2235f4..c51927b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,9 +6,10 @@ const Obz = require('obz') * @typedef {import('ppppp-db').Tangle} Tangle * @typedef {'none'|'all'|`newest-${number}`|`oldest-${number}`|'record'|'set'} GoalDSL * @typedef {[number, number]} Range + * @typedef {Goal_} Goal */ -class Goal { +class Goal_ { /** @type {string} */ #id @@ -96,12 +97,12 @@ module.exports = { const EMPTY_RANGE = /** @type {Range} */ ([1, 0]) // State: - const goals = /** @type {Map} */ (new Map()) + const goals = /** @type {Map} */ (new Map()) const listen = Obz() /** * @private - * @param {Goal} goal + * @param {Goal_} goal * @param {Tangle} tangle * @returns {Range} */ @@ -130,7 +131,7 @@ module.exports = { * @returns {void} */ function set(tangleID, goalDSL) { - const goal = new Goal(tangleID, goalDSL) + const goal = new Goal_(tangleID, goalDSL) goals.set(tangleID, goal) listen.set(goal) } @@ -138,7 +139,7 @@ module.exports = { /** * @public * @param {string} msgID - * @returns {Goal | null} + * @returns {Goal_ | null} */ function getByID(msgID) { return goals.get(msgID) ?? null @@ -147,18 +148,18 @@ module.exports = { /** * @public * @param {RecPresent} rec - * @returns {Array} + * @returns {Array} */ function getByRec(rec) { const arr = [] if (goals.has(rec.id)) { - const goal = /** @type {Goal} */ (goals.get(rec.id)) + const goal = /** @type {Goal_} */ (goals.get(rec.id)) arr.push(goal) } if (rec.msg) { for (const tangleID in rec.msg.metadata.tangles) { if (goals.has(tangleID)) { - const goal = /** @type {Goal} */ (goals.get(tangleID)) + const goal = /** @type {Goal_} */ (goals.get(tangleID)) const tangle = peer.db.getTangle(tangleID) if (tangle) { const [min, max] = crossGoalWithTangle(goal, tangle) @@ -173,7 +174,7 @@ module.exports = { /** * @public - * @returns {IterableIterator} + * @returns {IterableIterator} */ function list() { return goals.values()