Debian Codegraph @

packages/babel-core/src/config/caching.ts

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 import gensync from "gensync";
2 import type { Handler } from "gensync";
3 import {
4 maybeAsyncscip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/maybeAsync().,
5 isAsyncscip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/isAsync.,
6 onFirstPausescip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/onFirstPause.,
7 waitForscip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/waitFor.,
8 isThenablescip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/isThenable().,
9 } from "../gensync-utils/async"scip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/;
10 import { isIterableIteratorscip-typescript npm @babel/core 7.20.12 src/config/`util.ts`/isIterableIterator(). } from "./util"scip-typescript npm @babel/core 7.20.12 src/config/`util.ts`/;
11
12 export type { CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator# };
13
14 export type SimpleCacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleCacheConfigurator# = {
15 (forever: boolean): void;
16 <T>(handler: () => T): T;
17
18 foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleCacheConfigurator#typeLiteral2:forever.: () => void;
19 neverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleCacheConfigurator#typeLiteral2:never.: () => void;
20 usingscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleCacheConfigurator#typeLiteral2:using.: <T>(handler: () => T) => T;
21 invalidatescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleCacheConfigurator#typeLiteral2:invalidate.: <T>(handler: () => T) => T;
22 };
23
24 export type CacheEntryscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#[SideChannel]> = Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<{
25 valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:value.: ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#[ResultT];
26 validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:valid.: (channel: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#[SideChannel]) => Handler<boolean>;
27 }>;
28
29 const synchronizescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/synchronize. = <ArgsT extends unknown[], ResultT>(
30 gen: (...args: ArgsT) => Handler<ResultT>,
31 ): ((...args: ArgsT) => ResultT) => {
32 return gensync(gen).sync;
33 };
34
35 // eslint-disable-next-line require-yield
36 function* genTruescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/genTrue().() {
37 return true;
38 }
39
40 export function makeWeakCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[ArgT] extends object, ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[SideChannel]>(
41 handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().(handler): (
42 arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[ArgT],
43 cache: CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#<SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[SideChannel]>,
44 ) => Handler<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[ResultT]> | ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[ResultT],
45 ): (arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[ArgT], data: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[SideChannel]) => Handler<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[ResultT]> {
46 return makeCachedFunctionscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().[SideChannel]>(WeakMapscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#, handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().(handler));
47 }
48
49 export function makeWeakCacheSyncscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ArgT] extends object, ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[SideChannel]>(
50 handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().(handler): (arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ArgT], cache?: CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#<SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[SideChannel]>) => ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ResultT],
51 ): (arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ArgT], data?: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[SideChannel]) => ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ResultT] {
52 return synchronizescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/synchronize.<[ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ArgT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[SideChannel]], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ResultT]>(
53 makeWeakCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCache().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().[SideChannel]>(handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeWeakCacheSync().(handler)),
54 );
55 }
56
57 export function makeStrongCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[SideChannel]>(
58 handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().(handler): (
59 arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[ArgT],
60 cache: CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#<SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[SideChannel]>,
61 ) => Handler<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[ResultT]> | ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[ResultT],
62 ): (arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[ArgT], data: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[SideChannel]) => Handler<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[ResultT]> {
63 return makeCachedFunctionscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().[SideChannel]>(Mapscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#, handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().(handler));
64 }
65
66 export function makeStrongCacheSyncscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[SideChannel]>(
67 handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().(handler): (arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ArgT], cache?: CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#<SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[SideChannel]>) => ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ResultT],
68 ): (arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ArgT], data?: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[SideChannel]) => ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ResultT] {
69 return synchronizescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/synchronize.<[ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ArgT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[SideChannel]], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ResultT]>(
70 makeStrongCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCache().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().[SideChannel]>(handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeStrongCacheSync().(handler)),
71 );
72 }
73
74 /* NOTE: Part of the logic explained in this comment is explained in the
75 * getCachedValueOrWait and setupAsyncLocks functions.
76 *
77 * > There are only two hard things in Computer Science: cache invalidation and naming things.
78 * > -- Phil Karlton
79 *
80 * I don't know if Phil was also thinking about handling a cache whose invalidation function is
81 * defined asynchronously is considered, but it is REALLY hard to do correctly.
82 *
83 * The implemented logic (only when gensync is run asynchronously) is the following:
84 * 1. If there is a valid cache associated to the current "arg" parameter,
85 * a. RETURN the cached value
86 * 3. If there is a FinishLock associated to the current "arg" parameter representing a valid cache,
87 * a. Wait for that lock to be released
88 * b. RETURN the value associated with that lock
89 * 5. Start executing the function to be cached
90 * a. If it pauses on a promise, then
91 * i. Let FinishLock be a new lock
92 * ii. Store FinishLock as associated to the current "arg" parameter
93 * iii. Wait for the function to finish executing
94 * iv. Release FinishLock
95 * v. Send the function result to anyone waiting on FinishLock
96 * 6. Store the result in the cache
97 * 7. RETURN the result
98 */
99 function makeCachedFunctionscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[SideChannel]>(
100 CallCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().(CallCache): new <Cached>() => CacheMapscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ArgT], Cached, SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[SideChannel]>,
101 handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().(handler): (
102 arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ArgT],
103 cache: CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#<SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[SideChannel]>,
104 ) => Handler<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT]> | ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT],
105 ): (arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ArgT], data: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[SideChannel]) => Handler<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT]> {
106 const callCacheSync = new CallCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().(CallCache)<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT]>();
107 const callCacheAsync = new CallCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().(CallCache)<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT]>();
108 const futureCache = new CallCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().(CallCache)<Lockscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT]>>();
109
110 return function* cachedFunction(arg: ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ArgT], data: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[SideChannel]) {
111 const asyncContext = yield* isAsyncscip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/isAsync.();
112 const callCache = asyncContext ? callCacheAsync : callCacheSync;
113
114 const cached = yield* getCachedValueOrWaitscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[SideChannel]>(
115 asyncContext,
116 callCache,
117 futureCache,
118 arg,
119 data,
120 );
121 if (cached.valid) return cached.value;
122
123 const cache = new CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#`<constructor>`().(data);
124
125 const handlerResult: Handler<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT]> | ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT] = handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().(handler)(arg, cache);
126
127 let finishLock: Lockscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT]>;
128 let value: ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeCachedFunction().[ResultT];
129
130 if (isIterableIteratorscip-typescript npm @babel/core 7.20.12 src/config/`util.ts`/isIterableIterator().(handlerResult)) {
131 value = yield* onFirstPausescip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/onFirstPause.(handlerResult, () => {
132 finishLock = setupAsyncLocksscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().(cache, futureCache, arg);
133 });
134 } else {
135 value = handlerResult;
136 }
137
138 updateFunctionCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(callCache, cache, arg, value);
139
140 if (finishLock) {
141 futureCache.deletescip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#delete().(arg);
142 finishLock.releasescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#release().(value);
143 }
144
145 return value;
146 };
147 }
148
149 type CacheMapscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#[SideChannel]> =
150 | Mapscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#[ArgT], CacheEntryscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#[SideChannel]>>
151 // @ts-expect-error todo(flow->ts): add `extends object` constraint to ArgT
152 | WeakMapscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/WeakMap#<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#[ArgT], CacheEntryscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#[SideChannel]>>;
153
154 function* getCachedValuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[SideChannel]>(
155 cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().(cache): CacheMapscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[SideChannel]>,
156 argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().(arg): ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[ArgT],
157 datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().(data): SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[SideChannel],
158 ): Handler<{ valid: true; value: ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[ResultT] } | { valid: false; value: null }> {
159 const cachedValue: CacheEntryscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().[SideChannel]> | void = cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().(cache).getscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#get().(argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().(arg));
160
161 if (cachedValue) {
162 for (const { valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:value., validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:valid. } of cachedValue) {
163 if (yield* valid(datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().(data))) return { validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/valid0:: true, valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/value0: };
164 }
165 }
166
167 return { validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/valid1:: false, valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/value1:: null };
168 }
169
170 function* getCachedValueOrWaitscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[SideChannel]>(
171 asyncContextscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(asyncContext): boolean,
172 callCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(callCache): CacheMapscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[SideChannel]>,
173 futureCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(futureCache): CacheMapscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[ArgT], Lockscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[ResultT]>, SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[SideChannel]>,
174 argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(arg): ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[ArgT],
175 datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(data): SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[SideChannel],
176 ): Handler<{ valid: true; value: ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[ResultT] } | { valid: false; value: null }> {
177 const cached = yield* getCachedValuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().(callCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(callCache), argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(arg), datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(data));
178 if (cached.valid) {
179 return cached;
180 }
181
182 if (asyncContextscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(asyncContext)) {
183 const cached = yield* getCachedValuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValue().(futureCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(futureCache), argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(arg), datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().(data));
184 if (cached.valid) {
185 const value = yield* waitForscip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/waitFor.<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/getCachedValueOrWait().[ResultT]>(cached.value.promise);
186 return { validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/valid2:: true, valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/value2: };
187 }
188 }
189
190 return { validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/valid3:: false, valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/value3:: null };
191 }
192
193 function setupAsyncLocksscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[SideChannel]>(
194 configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().(config): CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#<SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[SideChannel]>,
195 futureCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().(futureCache): CacheMapscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[ArgT], Lockscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[ResultT]>, SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[SideChannel]>,
196 argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().(arg): ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[ArgT],
197 ): Lockscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[ResultT]> {
198 const finishLock = new Lockscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#`<constructor>`().<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().[ResultT]>();
199
200 updateFunctionCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(futureCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().(futureCache), configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().(config), argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/setupAsyncLocks().(arg), finishLock);
201
202 return finishLock;
203 }
204
205 function updateFunctionCachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().<
206 ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[ArgT],
207 ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[ResultT],
208 SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[SideChannel],
209 Cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[Cache] extends CacheMapscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheMap#<ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[ArgT], ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[SideChannel]>,
210 >(
211 cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(cache): Cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[Cache],
212 configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(config): CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#<SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[SideChannel]>,
213 argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(arg): ArgTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[ArgT],
214 valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(value): ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[ResultT],
215 ) {
216 if (!configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(config).configuredscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#configured().()) configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(config).foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#forever().();
217
218 let cachedValue: CacheEntryscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#<ResultTscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[ResultT], SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().[SideChannel]> | void = cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(cache).getscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#get().(argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(arg));
219
220 configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(config).deactivatescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#deactivate().();
221
222 switch (configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(config).modescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#mode().()) {
223 case "forever":
224 cachedValue = [{ valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:value., validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:valid.: genTruescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/genTrue(). }];
225 cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(cache).setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#set().(argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(arg), cachedValue);
226 break;
227 case "invalidate":
228 cachedValue = [{ valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:value., validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:valid.: configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(config).validatorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#validator().() }];
229 cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(cache).setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#set().(argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(arg), cachedValue);
230 break;
231 case "valid":
232 if (cachedValue) {
233 cachedValue.pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().({ valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:value., validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:valid.: configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(config).validatorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#validator().() });
234 } else {
235 cachedValue = [{ valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:value., validscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheEntry#Array:typeLiteral14:valid.: configscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(config).validatorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#validator().() }];
236 cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(cache).setscip-typescript npm typescript 5.9.3 lib/`lib.es2015.collection.d.ts`/Map#set().(argscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/updateFunctionCache().(arg), cachedValue);
237 }
238 }
239 }
240
241 class CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#<SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#[SideChannel] = void> {
242 _activescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_active.: boolean = true;
243 _neverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_never.: boolean = false;
244 _foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_forever.: boolean = false;
245 _invalidatescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_invalidate.: boolean = false;
246
247 _configuredscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_configured.: boolean = false;
248
249 _pairsscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_pairs.: Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#<
250 [cachedValue: unknown, handler: (data: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#[SideChannel]) => Handler<unknown>]
251 > = [];
252
253 _datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_data.: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#[SideChannel];
254
255 constructorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#`<constructor>`().(datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#`<constructor>`().(data): SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#[SideChannel]) {
256 this._datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_data. = datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#`<constructor>`().(data);
257 }
258
259 simplescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#simple().() {
260 return makeSimpleConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(this);
261 }
262
263 modescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#mode().() {
264 if (this._neverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_never.) return "never";
265 if (this._foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_forever.) return "forever";
266 if (this._invalidatescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_invalidate.) return "invalidate";
267 return "valid";
268 }
269
270 foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#forever().() {
271 if (!this._activescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_active.) {
272 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#("Cannot change caching after evaluation has completed.");
273 }
274 if (this._neverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_never.) {
275 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#("Caching has already been configured with .never()");
276 }
277 this._foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_forever. = true;
278 this._configuredscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_configured. = true;
279 }
280
281 neverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#never().() {
282 if (!this._activescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_active.) {
283 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#("Cannot change caching after evaluation has completed.");
284 }
285 if (this._foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_forever.) {
286 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#("Caching has already been configured with .forever()");
287 }
288 this._neverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_never. = true;
289 this._configuredscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_configured. = true;
290 }
291
292 usingscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().<Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().[T]>(handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().(handler): (data: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#[SideChannel]) => Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().[T]): Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().[T] {
293 if (!this._activescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_active.) {
294 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#("Cannot change caching after evaluation has completed.");
295 }
296 if (this._neverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_never. || this._foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_forever.) {
297 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
298 "Caching has already been configured with .never or .forever()",
299 );
300 }
301 this._configuredscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_configured. = true;
302
303 const key = handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().(handler)(this._datascip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_data.);
304
305 const fn = maybeAsyncscip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/maybeAsync().(
306 handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().(handler),
307 `You appear to be using an async cache handler, but Babel has been called synchronously`,
308 );
309
310 if (isThenablescip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/isThenable().(key)) {
311 // @ts-expect-error todo(flow->ts): improve function return type annotation
312 return key.thenscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/PromiseLike#then().((key: unknown) => {
313 this._pairsscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_pairs..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().([key, fn]);
314 return key;
315 });
316 }
317
318 this._pairsscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_pairs..pushscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#push().([key, fn]);
319 return key;
320 }
321
322 invalidatescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#invalidate().<Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#invalidate().[T]>(handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#invalidate().(handler): (data: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#[SideChannel]) => Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#invalidate().[T]): Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#invalidate().[T] {
323 this._invalidatescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_invalidate. = true;
324 return this.usingscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().(handlerscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#invalidate().(handler));
325 }
326
327 validatorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#validator().(): (data: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#[SideChannel]) => Handler<boolean> {
328 const pairs = this._pairsscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_pairs.;
329 return function* (data: SideChannelscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#[SideChannel]) {
330 for (const [key, fn] of pairs) {
331 if (key !== (yield* fn(data))) return false;
332 }
333 return true;
334 };
335 }
336
337 deactivatescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#deactivate().() {
338 this._activescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_active. = false;
339 }
340
341 configuredscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#configured().() {
342 return this._configuredscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#_configured.;
343 }
344 }
345
346 function makeSimpleConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(
347 cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(cache): CacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#<any>,
348 ): SimpleCacheConfiguratorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleCacheConfigurator# {
349 function cacheFn(val: any) {
350 if (typeof val === "boolean") {
351 if (val) cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(cache).foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#forever().();
352 else cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(cache).neverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#never().();
353 return;
354 }
355
356 return cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(cache).usingscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().(() => assertSimpleTypescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(val()));
357 }
358 cacheFn.forever = () => cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(cache).foreverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#forever().();
359 cacheFn.never = () => cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(cache).neverscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#never().();
360 cacheFn.using = (cb: { (): SimpleTypescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleType# }) =>
361 cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(cache).usingscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#using().(() => assertSimpleTypescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(cb()));
362 cacheFn.invalidate = (cb: { (): SimpleTypescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleType# }) =>
363 cachescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/makeSimpleConfigurator().(cache).invalidatescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/CacheConfigurator#invalidate().(() => assertSimpleTypescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(cb()));
364
365 return cacheFn as any;
366 }
367
368 // Types are limited here so that in the future these values can be used
369 // as part of Babel's caching logic.
370 export type SimpleTypescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleType# =
371 | string
372 | boolean
373 | number
374 | null
375 | void
376 | Promisescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Promise#<SimpleTypescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleType#>;
377 export function assertSimpleTypescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(value): unknown): SimpleTypescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/SimpleType# {
378 if (isThenablescip-typescript npm @babel/core 7.20.12 src/gensync-utils/`async.ts`/isThenable().(valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(value))) {
379 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
380 `You appear to be using an async cache handler, ` +
381 `which your current version of Babel does not support. ` +
382 `We may add support for this in the future, ` +
383 `but if you're on the most recent version of @babel/core and still ` +
384 `seeing this error, then you'll need to synchronously handle your caching logic.`,
385 );
386 }
387
388 if (
389 valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(value) != null &&
390 typeof valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(value) !== "string" &&
391 typeof valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(value) !== "boolean" &&
392 typeof valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(value) !== "number"
393 ) {
394 throw new Errorscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Error#(
395 "Cache keys must be either string, boolean, number, null, or undefined.",
396 );
397 }
•398 // @ts-ignore Type 'unknown' is not assignable to type 'SimpleType'. This can be removed
399 // when strictNullCheck is enabled
400 return valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/assertSimpleType().(value);
401 }
402
403 class Lockscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#<Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#[T]> {
404 releasedscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#released.: boolean = false;
405 promisescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#promise.: Promisescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Promise#<Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#[T]>;
406 _resolvescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#_resolve.: (value: Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#[T]) => void;
407
408 constructorscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#`<constructor>`().() {
409 this.promisescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#promise. = new Promisescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Promise#(resolve => {
410 this._resolvescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#_resolve. = resolve;
411 });
412 }
413
414 releasescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#release().(valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#release().(value): Tscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#[T]) {
415 this.releasedscip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#released. = true;
416 this._resolvescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#_resolve.(valuescip-typescript npm @babel/core 7.20.12 src/config/`caching.ts`/Lock#release().(value));
417 }
418 }