@@ -22,7 +22,8 @@ import {
2222} from 'query:options'
2323
2424/**
25- * Stores the default fetcher function.
25+ * Creates a default fetcher function that performs JSON requests
26+ * using the provided fetch implementation.
2627 */
2728export function defaultFetcher < T > (
2829 fetch : ( input : RequestInfo | URL , init ?: RequestInit ) => Promise < Response >
@@ -70,7 +71,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
7071 *
7172 * By default it does not use any broadcast channel.
7273 * If a broadcast channel is provided, query
73- * won't close automatically, therefore, the responsability
74+ * won't close automatically, therefore, the responsibility
7475 * of closing the broadcast channel is up to the user.
7576 */
7677 let broadcast = instanceOptions ?. broadcast
@@ -153,7 +154,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
153154 * does have a payload parameter that will contain relevant
154155 * information depending on the event type.
155156 * If there's a pending resolver for that key, the `refetching`
156- * event is fired immediatly .
157+ * event is fired immediately .
157158 */
158159 function subscribe < T = unknown > (
159160 key : string ,
@@ -163,7 +164,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
163164 events . addEventListener ( `${ event } :${ key } ` , listener )
164165 const value = resolversCache . get ( key )
165166
166- // For the refetching event, we want to immediatly return if there's
167+ // For the refetching event, we want to immediately return if there's
167168 // a pending resolver.
168169 if ( event === 'refetching' && value !== undefined ) {
169170 emit ( key , event , value . item )
@@ -177,7 +178,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
177178 /**
178179 * Mutates the key with a given optimistic value.
179180 * The mutated value is considered expired and will be
180- * replaced immediatly if a refetch happens when expired
181+ * replaced immediately if a refetch happens when expired
181182 * is true. If expired is false, the value expiration time
182183 * is added as if it was a valid data refetched. Alternatively
183184 * you can provide a Date to decide when the expiration happens.
@@ -224,7 +225,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
224225 }
225226
226227 /**
227- * Determines if the given key is currently resolving .
228+ * Returns all keys currently stored in the specified cache .
228229 */
229230 function keys ( type : CacheType = 'items' ) : readonly string [ ] {
230231 return Array . from ( type === 'items' ? itemsCache . keys ( ) : resolversCache . keys ( ) )
@@ -335,7 +336,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
335336 const fetcher = ( options ?. fetcher ?? instanceFetcher ) as FetcherFunction < T >
336337
337338 /**
338- * Determines if we can return a sale item
339+ * Determines if we can return a stale item.
339340 * If true, it will return the previous stale item
340341 * stored in the cache if it has expired. It will attempt
341342 * to revalidate it in the background. If false, the returned
@@ -384,7 +385,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
384385 // before we write to the cache, bail out to avoid writing
385386 // stale data that contradicts the abort.
386387 if ( controller . signal . aborted ) {
387- reject ( controller . signal . reason as Error )
388+ reject ( controller . signal . reason )
388389 return
389390 }
390391
@@ -418,7 +419,7 @@ export function createQuery(instanceOptions?: Configuration): Query {
418419 emit ( key , 'error' , error )
419420
420421 // Throw back the error.
421- reject ( error as Error )
422+ reject ( error )
422423 }
423424 }
424425 } )
@@ -461,13 +462,13 @@ export function createQuery(instanceOptions?: Configuration): Query {
461462 // in the background.
462463 if ( hasExpired && stale ) {
463464 // We have to silence the error to avoid unhandled promises.
464- // Refer to the error event if you need full controll of errors.
465+ // Refer to the error event if you need full control of errors.
465466 refetch ( key ) . catch ( ( ) => { } )
466467
467468 return cached . item as Promise < T >
468469 }
469470
470- // The item has expired but we dont allow stale
471+ // The item has expired but we don't allow stale
471472 // responses so we need to wait for the revalidation.
472473 if ( hasExpired ) {
473474 return refetch ( key )
0 commit comments