| 45 | } |
| 46 | |
| 47 | function diffRevalidationState( |
| 48 | prev: RevalidationState, |
| 49 | curr: RevalidationState |
| 50 | ): RevalidationState { |
| 51 | const prevTagsWithProfile = new Set( |
| 52 | prev.pendingRevalidatedTags.map((item) => { |
| 53 | const profileKey = |
| 54 | typeof item.profile === 'object' |
| 55 | ? JSON.stringify(item.profile) |
| 56 | : item.profile || '' |
| 57 | return `${item.tag}:${profileKey}` |
| 58 | }) |
| 59 | ) |
| 60 | const prevRevalidateWrites = new Set(prev.pendingRevalidateWrites) |
| 61 | return { |
| 62 | pendingRevalidatedTags: curr.pendingRevalidatedTags.filter((item) => { |
| 63 | const profileKey = |
| 64 | typeof item.profile === 'object' |
| 65 | ? JSON.stringify(item.profile) |
| 66 | : item.profile || '' |
| 67 | return !prevTagsWithProfile.has(`${item.tag}:${profileKey}`) |
| 68 | }), |
| 69 | pendingRevalidates: Object.fromEntries( |
| 70 | Object.entries(curr.pendingRevalidates).filter( |
| 71 | ([key]) => !(key in prev.pendingRevalidates) |
| 72 | ) |
| 73 | ), |
| 74 | pendingRevalidateWrites: curr.pendingRevalidateWrites.filter( |
| 75 | (promise) => !prevRevalidateWrites.has(promise) |
| 76 | ), |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | async function revalidateTags( |
| 81 | tagsWithProfile: Array<{ |