@@ -64,11 +64,14 @@ const installAsyncProxy = function (self) {
6464 toss ( 'This API requires navigator.storage.getDirectory.' ) ;
6565 }
6666
67- /** Will hold state copied to this object from the syncronous side of this API. */
67+ /**
68+ * Will hold state copied to this object from the syncronous side of
69+ * this API.
70+ */
6871 const state = Object . create ( null ) ;
6972
7073 /**
71- * Verbose :
74+ * verbose :
7275 *
7376 * 0 = no logging output
7477 * 1 = only errors
@@ -132,20 +135,20 @@ const installAsyncProxy = function (self) {
132135 } ;
133136
134137 /**
135- * __openFiles is a map of sqlite3_file pointers (integers) to metadata
136- * related to a given OPFS file handles. The pointers are, in this side of the
137- * interface, opaque file handle IDs provided by the synchronous part of this
138- * constellation. Each value is an object with a structure demonstrated in the
139- * xOpen() impl.
138+ * __openFiles is a map of sqlite3_file pointers (integers) to
139+ * metadata related to a given OPFS file handles. The pointers are, in
140+ * this side of the interface, opaque file handle IDs provided by the
141+ * synchronous part of this constellation. Each value is an object
142+ * with a structure demonstrated in the xOpen() impl.
140143 */
141144 const __openFiles = Object . create ( null ) ;
142145 /**
143146 * __implicitLocks is a Set of sqlite3_file pointers (integers) which were
144- * "auto-locked". i.e. those for which we obtained a sync access handle
145- * without an explicit xLock() call. Such locks will be released during db
146- * connection idle time, whereas a sync access handle obtained via xLock(), or
147- * subsequently xLock()'d after auto-acquisition, will not be released until
148- * xUnlock() is called.
147+ * "auto-locked". i.e. those for which we obtained a sync access
148+ * handle without an explicit xLock() call. Such locks will be
149+ * released during db connection idle time, whereas a sync access
150+ * handle obtained via xLock(), or subsequently xLock()'d after
151+ * auto-acquisition, will not be released until xUnlock() is called.
149152 *
150153 * Maintenance reminder: if we relinquish auto-locks at the end of the
151154 * operation which acquires them, we pay a massive performance
@@ -155,21 +158,21 @@ const installAsyncProxy = function (self) {
155158 const __implicitLocks = new Set ( ) ;
156159
157160 /**
158- * Expects an OPFS file path. It gets resolved, such that ".." components are
159- * properly expanded, and returned. If the 2nd arg is true, the result is
160- * returned as an array of path elements, else an absolute path string is
161- * returned.
161+ * Expects an OPFS file path. It gets resolved, such that ".."
162+ * components are properly expanded, and returned. If the 2nd arg is
163+ * true, the result is returned as an array of path elements, else an
164+ * absolute path string is returned.
162165 */
163166 const getResolvedPath = function ( filename , splitIt ) {
164167 const p = new URL ( filename , 'file://irrelevant' ) . pathname ;
165168 return splitIt ? p . split ( '/' ) . filter ( ( v ) => ! ! v ) : p ;
166169 } ;
167170
168171 /**
169- * Takes the absolute path to a filesystem element. Returns an array of
170- * [handleOfContainingDir, filename]. If the 2nd argument is truthy then each
171- * directory element leading to the file is created along the way. Throws if
172- * any creation or resolution fails.
172+ * Takes the absolute path to a filesystem element. Returns an array
173+ * of [handleOfContainingDir, filename]. If the 2nd argument is truthy
174+ * then each directory element leading to the file is created along
175+ * the way. Throws if any creation or resolution fails.
173176 */
174177 const getDirForFilename = async function f ( absFilename , createDirs = false ) {
175178 const path = getResolvedPath ( absFilename , true ) ;
@@ -184,14 +187,14 @@ const installAsyncProxy = function (self) {
184187 } ;
185188
186189 /**
187- * If the given file-holding object has a sync handle attached to it, that
188- * handle is remove and asynchronously closed. Though it may sound sensible to
189- * continue work as soon as the close() returns (noting that it's
190- * asynchronous), doing so can cause operations performed soon afterwards,
191- * e.g. a call to getSyncHandle() to fail because they may happen out of order
192- * from the close(). OPFS does not guaranty that the actual order of
193- * operations is retained in such cases. i.e. always "await" on the result of
194- * this function.
190+ * If the given file-holding object has a sync handle attached to it,
191+ * that handle is remove and asynchronously closed. Though it may
192+ * sound sensible to continue work as soon as the close() returns
193+ * (noting that it's asynchronous), doing so can cause operations
194+ * performed soon afterwards, e.g. a call to getSyncHandle() to fail
195+ * because they may happen out of order from the close(). OPFS does
196+ * not guaranty that the actual order of operations is retained in
197+ * such cases. i.e. always "await" on the result of this function.
195198 */
196199 const closeSyncHandle = async ( fh ) => {
197200 if ( fh . syncHandle ) {
@@ -236,9 +239,9 @@ const installAsyncProxy = function (self) {
236239 } ;
237240
238241 /**
239- * An experiment in improving concurrency by freeing up implicit locks sooner.
240- * This is known to impact performance dramatically but it has also shown to
241- * improve concurrency considerably.
242+ * An experiment in improving concurrency by freeing up implicit locks
243+ * sooner. This is known to impact performance dramatically but it has
244+ * also shown to improve concurrency considerably.
242245 *
243246 * If fh.releaseImplicitLocks is truthy and fh is in __implicitLocks,
244247 * this routine returns closeSyncHandleNoThrow(), else it is a no-op.
@@ -250,11 +253,11 @@ const installAsyncProxy = function (self) {
250253 } ;
251254
252255 /**
253- * An error class specifically for use with getSyncHandle(), the goal of which
254- * is to eventually be able to distinguish unambiguously between
255- * locking-related failures and other types, noting that we cannot currently
256- * do so because createSyncAccessHandle() does not define its exceptions in
257- * the required level of detail.
256+ * An error class specifically for use with getSyncHandle(), the goal
257+ * of which is to eventually be able to distinguish unambiguously
258+ * between locking-related failures and other types, noting that we
259+ * cannot currently do so because createSyncAccessHandle() does not
260+ * define its exceptions in the required level of detail.
258261 *
259262 * 2022-11-29: according to:
260263 *
@@ -294,9 +297,9 @@ const installAsyncProxy = function (self) {
294297 }
295298 } ;
296299 /**
297- * Returns the sync access handle associated with the given file handle object
298- * (which must be a valid handle object, as created by xOpen()), lazily
299- * opening it if needed.
300+ * Returns the sync access handle associated with the given file
301+ * handle object (which must be a valid handle object, as created by
302+ * xOpen()), lazily opening it if needed.
300303 *
301304 * In order to help alleviate cross-tab contention for a dabase, if
302305 * an exception is thrown while acquiring the handle, this routine
@@ -365,7 +368,7 @@ const installAsyncProxy = function (self) {
365368
366369 /**
367370 * Stores the given value at state.sabOPView[state.opIds.rc] and then
368- * Atomics.notify()'s it.
371+ * Atomics.notify()'s it.
369372 */
370373 const storeAndNotify = ( opName , value ) => {
371374 log ( opName + '() => notify(' , value , ')' ) ;
@@ -379,11 +382,11 @@ const installAsyncProxy = function (self) {
379382 } ;
380383
381384 /**
382- * We track 2 different timers: the "metrics" timer records how much time we
383- * spend performing work. The "wait" timer records how much time we spend
384- * waiting on the underlying OPFS timer. See the calls to mTimeStart(),
385- * mTimeEnd(), wTimeStart(), and wTimeEnd() throughout this file to see how
386- * they're used.
385+ * We track 2 different timers: the "metrics" timer records how much
386+ * time we spend performing work. The "wait" timer records how much
387+ * time we spend waiting on the underlying OPFS timer. See the calls
388+ * to mTimeStart(), mTimeEnd(), wTimeStart(), and wTimeEnd()
389+ * throughout this file to see how they're used.
387390 */
388391 const __mTimer = Object . create ( null ) ;
389392 __mTimer . op = undefined ;
@@ -408,17 +411,17 @@ const installAsyncProxy = function (self) {
408411 ( metrics [ __wTimer . op ] . wait += performance . now ( ) - __wTimer . start ) ;
409412
410413 /**
411- * Gets set to true by the 'opfs-async-shutdown' command to quit the wait
412- * loop. This is only intended for debugging purposes: we cannot inspect this
413- * file's state while the tight waitLoop() is running and need a way to stop
414- * that loop for introspection purposes.
414+ * Gets set to true by the 'opfs-async-shutdown' command to quit the
415+ * wait loop. This is only intended for debugging purposes: we cannot
416+ * inspect this file's state while the tight waitLoop() is running and
417+ * need a way to stop that loop for introspection purposes.
415418 */
416419 let flagAsyncShutdown = false ;
417420
418421 /**
419- * Asynchronous wrappers for sqlite3_vfs and sqlite3_io_methods methods, as
420- * well as helpers like mkdir(). Maintenance reminder: members are in
421- * alphabetical order to simplify finding them.
422+ * Asynchronous wrappers for sqlite3_vfs and sqlite3_io_methods
423+ * methods, as well as helpers like mkdir(). Maintenance reminder:
424+ * members are in alphabetical order to simplify finding them.
422425 */
423426 const vfsAsyncImpls = {
424427 'opfs-async-metrics' : async ( ) => {
@@ -757,8 +760,8 @@ const installAsyncProxy = function (self) {
757760
758761 const initS11n = ( ) => {
759762 /**
760- * ACHTUNG: this code is 100% duplicated in the other half of this proxy!
761- * The documentation is maintained in the "synchronous half".
763+ * ACHTUNG: this code is 100% duplicated in the other half of this
764+ * proxy! The documentation is maintained in the "synchronous half".
762765 */
763766 if ( state . s11n ) return state . s11n ;
764767 const textDecoder = new TextDecoder ( ) ,
0 commit comments