add some JSDoc

pull/15844/head
Rich Harris 3 months ago
parent e888b5b2d4
commit cf2bdd1d31

@ -26,19 +26,37 @@ let uid = 1;
export class Batch { export class Batch {
id = uid++; id = uid++;
/** @type {Map<Source, any>} */ /**
#previous = new Map(); * The current values of any sources that are updated in this batch
* They keys of this map are identical to `this.#previous`
/** @type {Map<Source, any>} */ * @type {Map<Source, any>}
*/
#current = new Map(); #current = new Map();
/** @type {Set<() => void>} */ /**
* The values of any sources that are updated in this batch _before_ those updates took place.
* They keys of this map are identical to `this.#current`
* @type {Map<Source, any>}
*/
#previous = new Map();
/**
* When the batch is committed (and the DOM is updated), we need to remove old branches
* and append new ones by calling the functions added inside (if/each/key/etc) blocks
* @type {Set<() => void>}
*/
#callbacks = new Set(); #callbacks = new Set();
/**
* The number of async effects that are currently in flight
*/
#pending = 0; #pending = 0;
/** @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null} */ /**
// TODO replace with Promise.withResolvers once supported widely enough * A deferred that resolves when the batch is committed, used with `settled()`
* TODO replace with Promise.withResolvers once supported widely enough
* @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
*/
#deferred = null; #deferred = null;
/** @type {Effect[]} */ /** @type {Effect[]} */
@ -53,7 +71,11 @@ export class Batch {
/** @type {Effect[]} */ /** @type {Effect[]} */
effects = []; effects = [];
/** @type {Set<Effect>} */ /**
* A set of branches that still exist, but will be destroyed when this batch
* is committed we skip over these during `process`
* @type {Set<Effect>}
*/
skipped_effects = new Set(); skipped_effects = new Set();
/** /**

Loading…
Cancel
Save