MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / readFresh

Method readFresh

packager/src/node-haste/Module.js:378–405  ·  view source on GitHub ↗

* Gathers relevant data about a module: source code, transformed code, * dependencies, etc. This function reads and transforms the source from * scratch. We don't repeat the same work as `readCached` because we assume * call sites have called it already.

(transformOptions: TransformOptions)

Source from the content-addressed store, hash-verified

376 * call sites have called it already.
377 */
378 readFresh(transformOptions: TransformOptions): Promise<ReadResult> {
379 const key = stableObjectHash(transformOptions || {});
380 const promise = this._readPromises.get(key);
381 if (promise != null) {
382 return promise;
383 }
384 const freshPromise = Promise.resolve().then(() => {
385 const cacheProps = this._getCacheProps(transformOptions, key);
386 return new Promise((resolve, reject) => {
387 this._getAndCacheTransformedCode(
388 cacheProps,
389 (transformError, freshResult) => {
390 if (transformError) {
391 reject(transformError);
392 return;
393 }
394 invariant(freshResult != null, 'inconsistent state');
395 resolve(this._finalizeReadResult(cacheProps.sourceCode, freshResult));
396 },
397 );
398 }).then(result => {
399 this._readResultsByOptionsKey.set(key, {result, outdatedDependencies: []});
400 return result;
401 });
402 });
403 this._readPromises.set(key, freshPromise);
404 return freshPromise;
405 }
406
407 _getCacheProps(transformOptions: TransformOptions, transformOptionsKey: string) {
408 const sourceCode = this._readSourceCode();

Callers 3

readMethod · 0.95
resolveDependenciesMethod · 0.45
preprocessModuleMethod · 0.45

Calls 9

_getCachePropsMethod · 0.95
_finalizeReadResultMethod · 0.95
stableObjectHashFunction · 0.85
invariantFunction · 0.85
resolveMethod · 0.65
getMethod · 0.45
thenMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected