@data-eden/network
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -1,2 +0,19 @@ | ||
const TrackingInfoPerFetch = new WeakMap(); | ||
const TrackingInfoPerFetchSymbol = Symbol.for('_DATA_EDEN_TRACKING_INFO_PER_FETCH'); | ||
const TrackingInfoPerFetch = (() => { | ||
// in some bundling contexts (e.g. webpack as used by ember-auto-import) you might | ||
// end up with multiple copies of this module in the final bundle. In that case | ||
// we need to ensure that we have a single global tracking map. We do this by | ||
// using a symbol that is the same across all copies, and then using that symbol | ||
// to store the map on the global object. | ||
// | ||
// this ensures that at any given time (regardless of how many copies of this module exist) | ||
// we can always get the same map (and therefore our API's work properly). | ||
// TODO: figure out how to make this work without the casting `globalThis` | ||
let _global = globalThis; | ||
let trackingInfoPerFetch = _global[TrackingInfoPerFetchSymbol]; | ||
if (!trackingInfoPerFetch) { | ||
trackingInfoPerFetch = _global[TrackingInfoPerFetchSymbol] = new WeakMap(); | ||
} | ||
return trackingInfoPerFetch; | ||
})(); | ||
const RequestsCompletedPromisesByToken = new WeakMap(); | ||
@@ -3,0 +20,0 @@ /** |
{ | ||
"name": "@data-eden/network", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"repository": { | ||
@@ -33,3 +33,3 @@ "type": "git", | ||
"devDependencies": { | ||
"@data-eden/shared-test-utilities": "0.7.0", | ||
"@data-eden/shared-test-utilities": "0.7.1", | ||
"cross-fetch": "^3.1.5" | ||
@@ -36,0 +36,0 @@ }, |
@@ -18,3 +18,27 @@ import type { MiddlewareMetadata, NormalizedFetch } from './fetch.js'; | ||
const TrackingInfoPerFetch: WeakMap<Fetch, FetchDebugInfo[]> = new WeakMap(); | ||
const TrackingInfoPerFetchSymbol = Symbol.for( | ||
'_DATA_EDEN_TRACKING_INFO_PER_FETCH' | ||
); | ||
const TrackingInfoPerFetch: WeakMap<Fetch, FetchDebugInfo[]> = (() => { | ||
// in some bundling contexts (e.g. webpack as used by ember-auto-import) you might | ||
// end up with multiple copies of this module in the final bundle. In that case | ||
// we need to ensure that we have a single global tracking map. We do this by | ||
// using a symbol that is the same across all copies, and then using that symbol | ||
// to store the map on the global object. | ||
// | ||
// this ensures that at any given time (regardless of how many copies of this module exist) | ||
// we can always get the same map (and therefore our API's work properly). | ||
// TODO: figure out how to make this work without the casting `globalThis` | ||
let _global = globalThis as Record<string | symbol, unknown>; | ||
let trackingInfoPerFetch = _global[TrackingInfoPerFetchSymbol]; | ||
if (!trackingInfoPerFetch) { | ||
trackingInfoPerFetch = _global[TrackingInfoPerFetchSymbol] = new WeakMap(); | ||
} | ||
return trackingInfoPerFetch as WeakMap<Fetch, FetchDebugInfo[]>; | ||
})(); | ||
const RequestsCompletedPromisesByToken: WeakMap<Fetch, InternalDeferred> = | ||
@@ -21,0 +45,0 @@ new WeakMap(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
311183
1501