CachedInputFileSystem.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. // eslint-disable-next-line n/prefer-global/process
  7. const { nextTick } = require("process");
  8. /** @typedef {import("./Resolver").FileSystem} FileSystem */
  9. /** @typedef {import("./Resolver").PathLike} PathLike */
  10. /** @typedef {import("./Resolver").PathOrFileDescriptor} PathOrFileDescriptor */
  11. /** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */
  12. /** @typedef {FileSystem & SyncFileSystem} BaseFileSystem */
  13. /**
  14. * @template T
  15. * @typedef {import("./Resolver").FileSystemCallback<T>} FileSystemCallback<T>
  16. */
  17. /**
  18. * @param {string} path path
  19. * @returns {string} dirname
  20. */
  21. const dirname = (path) => {
  22. let idx = path.length - 1;
  23. while (idx >= 0) {
  24. const char = path.charCodeAt(idx);
  25. // slash or backslash
  26. if (char === 47 || char === 92) break;
  27. idx--;
  28. }
  29. if (idx < 0) return "";
  30. return path.slice(0, idx);
  31. };
  32. /**
  33. * @template T
  34. * @param {FileSystemCallback<T>[]} callbacks callbacks
  35. * @param {Error | null} err error
  36. * @param {T} result result
  37. */
  38. const runCallbacks = (callbacks, err, result) => {
  39. if (callbacks.length === 1) {
  40. callbacks[0](err, result);
  41. callbacks.length = 0;
  42. return;
  43. }
  44. let error;
  45. for (const callback of callbacks) {
  46. try {
  47. callback(err, result);
  48. } catch (err) {
  49. if (!error) error = err;
  50. }
  51. }
  52. callbacks.length = 0;
  53. if (error) throw error;
  54. };
  55. // eslint-disable-next-line jsdoc/reject-function-type
  56. /** @typedef {Function} EXPECTED_FUNCTION */
  57. // eslint-disable-next-line jsdoc/reject-any-type
  58. /** @typedef {any} EXPECTED_ANY */
  59. class OperationMergerBackend {
  60. /**
  61. * @param {EXPECTED_FUNCTION | undefined} provider async method in filesystem
  62. * @param {EXPECTED_FUNCTION | undefined} syncProvider sync method in filesystem
  63. * @param {BaseFileSystem} providerContext call context for the provider methods
  64. */
  65. constructor(provider, syncProvider, providerContext) {
  66. this._provider = provider;
  67. this._syncProvider = syncProvider;
  68. this._providerContext = providerContext;
  69. this._activeAsyncOperations = new Map();
  70. this.provide = this._provider
  71. ? // Comment to align jsdoc
  72. /**
  73. * @param {PathLike | PathOrFileDescriptor} path path
  74. * @param {object | FileSystemCallback<EXPECTED_ANY> | undefined} options options
  75. * @param {FileSystemCallback<EXPECTED_ANY>=} callback callback
  76. * @returns {EXPECTED_ANY} result
  77. */
  78. (path, options, callback) => {
  79. if (typeof options === "function") {
  80. callback =
  81. /** @type {FileSystemCallback<EXPECTED_ANY>} */
  82. (options);
  83. options = undefined;
  84. }
  85. if (
  86. typeof path !== "string" &&
  87. !Buffer.isBuffer(path) &&
  88. !(path instanceof URL) &&
  89. typeof path !== "number"
  90. ) {
  91. /** @type {EXPECTED_FUNCTION} */
  92. (callback)(
  93. new TypeError("path must be a string, Buffer, URL or number"),
  94. );
  95. return;
  96. }
  97. if (options) {
  98. return /** @type {EXPECTED_FUNCTION} */ (this._provider).call(
  99. this._providerContext,
  100. path,
  101. options,
  102. callback,
  103. );
  104. }
  105. let callbacks = this._activeAsyncOperations.get(path);
  106. if (callbacks) {
  107. callbacks.push(callback);
  108. return;
  109. }
  110. this._activeAsyncOperations.set(path, (callbacks = [callback]));
  111. /** @type {EXPECTED_FUNCTION} */
  112. (provider)(
  113. path,
  114. /**
  115. * @param {Error} err error
  116. * @param {EXPECTED_ANY} result result
  117. */
  118. (err, result) => {
  119. this._activeAsyncOperations.delete(path);
  120. runCallbacks(callbacks, err, result);
  121. },
  122. );
  123. }
  124. : null;
  125. this.provideSync = this._syncProvider
  126. ? // Comment to align jsdoc
  127. /**
  128. * @param {PathLike | PathOrFileDescriptor} path path
  129. * @param {object=} options options
  130. * @returns {EXPECTED_ANY} result
  131. */
  132. (path, options) =>
  133. /** @type {EXPECTED_FUNCTION} */ (this._syncProvider).call(
  134. this._providerContext,
  135. path,
  136. options,
  137. )
  138. : null;
  139. }
  140. purge() {}
  141. purgeParent() {}
  142. }
  143. /*
  144. IDLE:
  145. insert data: goto SYNC
  146. SYNC:
  147. before provide: run ticks
  148. event loop tick: goto ASYNC_ACTIVE
  149. ASYNC:
  150. timeout: run tick, goto ASYNC_PASSIVE
  151. ASYNC_PASSIVE:
  152. before provide: run ticks
  153. IDLE --[insert data]--> SYNC --[event loop tick]--> ASYNC_ACTIVE --[interval tick]-> ASYNC_PASSIVE
  154. ^ |
  155. +---------[insert data]-------+
  156. */
  157. const STORAGE_MODE_IDLE = 0;
  158. const STORAGE_MODE_SYNC = 1;
  159. const STORAGE_MODE_ASYNC = 2;
  160. /**
  161. * @callback Provide
  162. * @param {PathLike | PathOrFileDescriptor} path path
  163. * @param {EXPECTED_ANY} options options
  164. * @param {FileSystemCallback<EXPECTED_ANY>} callback callback
  165. * @returns {void}
  166. */
  167. class CacheBackend {
  168. /**
  169. * @param {number} duration max cache duration of items
  170. * @param {EXPECTED_FUNCTION | undefined} provider async method
  171. * @param {EXPECTED_FUNCTION | undefined} syncProvider sync method
  172. * @param {BaseFileSystem} providerContext call context for the provider methods
  173. */
  174. constructor(duration, provider, syncProvider, providerContext) {
  175. this._duration = duration;
  176. this._provider = provider;
  177. this._syncProvider = syncProvider;
  178. this._providerContext = providerContext;
  179. /** @type {Map<string, FileSystemCallback<EXPECTED_ANY>[]>} */
  180. this._activeAsyncOperations = new Map();
  181. /** @type {Map<string, { err: Error | null, result?: EXPECTED_ANY, level: Set<string> }>} */
  182. this._data = new Map();
  183. /** @type {Set<string>[]} */
  184. this._levels = [];
  185. for (let i = 0; i < 10; i++) this._levels.push(new Set());
  186. if (duration !== Infinity) {
  187. for (let i = 5000; i < duration; i += 500) {
  188. this._levels.push(new Set());
  189. }
  190. }
  191. this._currentLevel = 0;
  192. this._tickInterval = Math.floor(duration / this._levels.length);
  193. /** @type {STORAGE_MODE_IDLE | STORAGE_MODE_SYNC | STORAGE_MODE_ASYNC} */
  194. this._mode = STORAGE_MODE_IDLE;
  195. /** @type {NodeJS.Timeout | undefined} */
  196. this._timeout = undefined;
  197. /** @type {number | undefined} */
  198. this._nextDecay = undefined;
  199. // eslint-disable-next-line no-warning-comments
  200. // @ts-ignore
  201. this.provide = provider ? this.provide.bind(this) : null;
  202. // eslint-disable-next-line no-warning-comments
  203. // @ts-ignore
  204. this.provideSync = syncProvider ? this.provideSync.bind(this) : null;
  205. }
  206. /**
  207. * @param {PathLike | PathOrFileDescriptor} path path
  208. * @param {EXPECTED_ANY} options options
  209. * @param {FileSystemCallback<EXPECTED_ANY>} callback callback
  210. * @returns {void}
  211. */
  212. provide(path, options, callback) {
  213. if (typeof options === "function") {
  214. callback = options;
  215. options = undefined;
  216. }
  217. if (
  218. typeof path !== "string" &&
  219. !Buffer.isBuffer(path) &&
  220. !(path instanceof URL) &&
  221. typeof path !== "number"
  222. ) {
  223. callback(new TypeError("path must be a string, Buffer, URL or number"));
  224. return;
  225. }
  226. const strPath = typeof path !== "string" ? path.toString() : path;
  227. if (options) {
  228. return /** @type {EXPECTED_FUNCTION} */ (this._provider).call(
  229. this._providerContext,
  230. path,
  231. options,
  232. callback,
  233. );
  234. }
  235. // When in sync mode we can move to async mode
  236. if (this._mode === STORAGE_MODE_SYNC) {
  237. this._enterAsyncMode();
  238. }
  239. // Check in cache
  240. const cacheEntry = this._data.get(strPath);
  241. if (cacheEntry !== undefined) {
  242. if (cacheEntry.err) return nextTick(callback, cacheEntry.err);
  243. return nextTick(callback, null, cacheEntry.result);
  244. }
  245. // Check if there is already the same operation running
  246. let callbacks = this._activeAsyncOperations.get(strPath);
  247. if (callbacks !== undefined) {
  248. callbacks.push(callback);
  249. return;
  250. }
  251. this._activeAsyncOperations.set(strPath, (callbacks = [callback]));
  252. // Run the operation
  253. /** @type {EXPECTED_FUNCTION} */
  254. (this._provider).call(
  255. this._providerContext,
  256. path,
  257. /**
  258. * @param {Error | null} err error
  259. * @param {EXPECTED_ANY=} result result
  260. */
  261. (err, result) => {
  262. this._activeAsyncOperations.delete(strPath);
  263. this._storeResult(strPath, err, result);
  264. // Enter async mode if not yet done
  265. this._enterAsyncMode();
  266. runCallbacks(
  267. /** @type {FileSystemCallback<EXPECTED_ANY>[]} */ (callbacks),
  268. err,
  269. result,
  270. );
  271. },
  272. );
  273. }
  274. /**
  275. * @param {PathLike | PathOrFileDescriptor} path path
  276. * @param {EXPECTED_ANY} options options
  277. * @returns {EXPECTED_ANY} result
  278. */
  279. provideSync(path, options) {
  280. if (
  281. typeof path !== "string" &&
  282. !Buffer.isBuffer(path) &&
  283. !(path instanceof URL) &&
  284. typeof path !== "number"
  285. ) {
  286. throw new TypeError("path must be a string");
  287. }
  288. const strPath = typeof path !== "string" ? path.toString() : path;
  289. if (options) {
  290. return /** @type {EXPECTED_FUNCTION} */ (this._syncProvider).call(
  291. this._providerContext,
  292. path,
  293. options,
  294. );
  295. }
  296. // In sync mode we may have to decay some cache items
  297. if (this._mode === STORAGE_MODE_SYNC) {
  298. this._runDecays();
  299. }
  300. // Check in cache
  301. const cacheEntry = this._data.get(strPath);
  302. if (cacheEntry !== undefined) {
  303. if (cacheEntry.err) throw cacheEntry.err;
  304. return cacheEntry.result;
  305. }
  306. // Get all active async operations
  307. // This sync operation will also complete them
  308. const callbacks = this._activeAsyncOperations.get(strPath);
  309. this._activeAsyncOperations.delete(strPath);
  310. // Run the operation
  311. // When in idle mode, we will enter sync mode
  312. let result;
  313. try {
  314. result = /** @type {EXPECTED_FUNCTION} */ (this._syncProvider).call(
  315. this._providerContext,
  316. path,
  317. );
  318. } catch (err) {
  319. this._storeResult(strPath, /** @type {Error} */ (err), undefined);
  320. this._enterSyncModeWhenIdle();
  321. if (callbacks) {
  322. runCallbacks(callbacks, /** @type {Error} */ (err), undefined);
  323. }
  324. throw err;
  325. }
  326. this._storeResult(strPath, null, result);
  327. this._enterSyncModeWhenIdle();
  328. if (callbacks) {
  329. runCallbacks(callbacks, null, result);
  330. }
  331. return result;
  332. }
  333. /**
  334. * @param {(string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>)=} what what to purge
  335. */
  336. purge(what) {
  337. if (!what) {
  338. if (this._mode !== STORAGE_MODE_IDLE) {
  339. this._data.clear();
  340. for (const level of this._levels) {
  341. level.clear();
  342. }
  343. this._enterIdleMode();
  344. }
  345. } else if (
  346. typeof what === "string" ||
  347. Buffer.isBuffer(what) ||
  348. what instanceof URL ||
  349. typeof what === "number"
  350. ) {
  351. const strWhat = typeof what !== "string" ? what.toString() : what;
  352. for (const [key, data] of this._data) {
  353. if (key.startsWith(strWhat)) {
  354. this._data.delete(key);
  355. data.level.delete(key);
  356. }
  357. }
  358. if (this._data.size === 0) {
  359. this._enterIdleMode();
  360. }
  361. } else {
  362. for (const [key, data] of this._data) {
  363. for (const item of what) {
  364. const strItem = typeof item !== "string" ? item.toString() : item;
  365. if (key.startsWith(strItem)) {
  366. this._data.delete(key);
  367. data.level.delete(key);
  368. break;
  369. }
  370. }
  371. }
  372. if (this._data.size === 0) {
  373. this._enterIdleMode();
  374. }
  375. }
  376. }
  377. /**
  378. * @param {(string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>)=} what what to purge
  379. */
  380. purgeParent(what) {
  381. if (!what) {
  382. this.purge();
  383. } else if (
  384. typeof what === "string" ||
  385. Buffer.isBuffer(what) ||
  386. what instanceof URL ||
  387. typeof what === "number"
  388. ) {
  389. const strWhat = typeof what !== "string" ? what.toString() : what;
  390. this.purge(dirname(strWhat));
  391. } else {
  392. const set = new Set();
  393. for (const item of what) {
  394. const strItem = typeof item !== "string" ? item.toString() : item;
  395. set.add(dirname(strItem));
  396. }
  397. this.purge(set);
  398. }
  399. }
  400. /**
  401. * @param {string} path path
  402. * @param {Error | null} err error
  403. * @param {EXPECTED_ANY} result result
  404. */
  405. _storeResult(path, err, result) {
  406. if (this._data.has(path)) return;
  407. const level = this._levels[this._currentLevel];
  408. this._data.set(path, { err, result, level });
  409. level.add(path);
  410. }
  411. _decayLevel() {
  412. const nextLevel = (this._currentLevel + 1) % this._levels.length;
  413. const decay = this._levels[nextLevel];
  414. this._currentLevel = nextLevel;
  415. for (const item of decay) {
  416. this._data.delete(item);
  417. }
  418. decay.clear();
  419. if (this._data.size === 0) {
  420. this._enterIdleMode();
  421. } else {
  422. /** @type {number} */
  423. (this._nextDecay) += this._tickInterval;
  424. }
  425. }
  426. _runDecays() {
  427. while (
  428. /** @type {number} */ (this._nextDecay) <= Date.now() &&
  429. this._mode !== STORAGE_MODE_IDLE
  430. ) {
  431. this._decayLevel();
  432. }
  433. }
  434. _enterAsyncMode() {
  435. let timeout = 0;
  436. switch (this._mode) {
  437. case STORAGE_MODE_ASYNC:
  438. return;
  439. case STORAGE_MODE_IDLE:
  440. this._nextDecay = Date.now() + this._tickInterval;
  441. timeout = this._tickInterval;
  442. break;
  443. case STORAGE_MODE_SYNC:
  444. this._runDecays();
  445. // _runDecays may change the mode
  446. if (
  447. /** @type {STORAGE_MODE_IDLE | STORAGE_MODE_SYNC | STORAGE_MODE_ASYNC} */
  448. (this._mode) === STORAGE_MODE_IDLE
  449. ) {
  450. return;
  451. }
  452. timeout = Math.max(
  453. 0,
  454. /** @type {number} */ (this._nextDecay) - Date.now(),
  455. );
  456. break;
  457. }
  458. this._mode = STORAGE_MODE_ASYNC;
  459. // When duration is Infinity, cache entries never expire, so there
  460. // is no need to schedule a decay timer.
  461. if (this._duration === Infinity) {
  462. return;
  463. }
  464. const ref = setTimeout(() => {
  465. this._mode = STORAGE_MODE_SYNC;
  466. this._runDecays();
  467. }, timeout);
  468. if (ref.unref) ref.unref();
  469. this._timeout = ref;
  470. }
  471. _enterSyncModeWhenIdle() {
  472. if (this._mode === STORAGE_MODE_IDLE) {
  473. this._mode = STORAGE_MODE_SYNC;
  474. this._nextDecay = Date.now() + this._tickInterval;
  475. }
  476. }
  477. _enterIdleMode() {
  478. this._mode = STORAGE_MODE_IDLE;
  479. this._nextDecay = undefined;
  480. if (this._timeout) clearTimeout(this._timeout);
  481. }
  482. }
  483. /**
  484. * @template {EXPECTED_FUNCTION} Provider
  485. * @template {EXPECTED_FUNCTION} AsyncProvider
  486. * @template FileSystem
  487. * @param {number} duration duration in ms files are cached
  488. * @param {Provider | undefined} provider provider
  489. * @param {AsyncProvider | undefined} syncProvider sync provider
  490. * @param {BaseFileSystem} providerContext provider context
  491. * @returns {OperationMergerBackend | CacheBackend} backend
  492. */
  493. const createBackend = (duration, provider, syncProvider, providerContext) => {
  494. if (duration > 0) {
  495. return new CacheBackend(duration, provider, syncProvider, providerContext);
  496. }
  497. return new OperationMergerBackend(provider, syncProvider, providerContext);
  498. };
  499. module.exports = class CachedInputFileSystem {
  500. /**
  501. * @param {BaseFileSystem} fileSystem file system
  502. * @param {number} duration duration in ms files are cached
  503. */
  504. constructor(fileSystem, duration) {
  505. this.fileSystem = fileSystem;
  506. this._lstatBackend = createBackend(
  507. duration,
  508. this.fileSystem.lstat,
  509. this.fileSystem.lstatSync,
  510. this.fileSystem,
  511. );
  512. const lstat = this._lstatBackend.provide;
  513. this.lstat = /** @type {FileSystem["lstat"]} */ (lstat);
  514. const lstatSync = this._lstatBackend.provideSync;
  515. this.lstatSync = /** @type {SyncFileSystem["lstatSync"]} */ (lstatSync);
  516. this._statBackend = createBackend(
  517. duration,
  518. this.fileSystem.stat,
  519. this.fileSystem.statSync,
  520. this.fileSystem,
  521. );
  522. const stat = this._statBackend.provide;
  523. this.stat = /** @type {FileSystem["stat"]} */ (stat);
  524. const statSync = this._statBackend.provideSync;
  525. this.statSync = /** @type {SyncFileSystem["statSync"]} */ (statSync);
  526. this._readdirBackend = createBackend(
  527. duration,
  528. this.fileSystem.readdir,
  529. this.fileSystem.readdirSync,
  530. this.fileSystem,
  531. );
  532. const readdir = this._readdirBackend.provide;
  533. this.readdir = /** @type {FileSystem["readdir"]} */ (readdir);
  534. const readdirSync = this._readdirBackend.provideSync;
  535. this.readdirSync = /** @type {SyncFileSystem["readdirSync"]} */ (
  536. readdirSync
  537. );
  538. this._readFileBackend = createBackend(
  539. duration,
  540. this.fileSystem.readFile,
  541. this.fileSystem.readFileSync,
  542. this.fileSystem,
  543. );
  544. const readFile = this._readFileBackend.provide;
  545. this.readFile = /** @type {FileSystem["readFile"]} */ (readFile);
  546. const readFileSync = this._readFileBackend.provideSync;
  547. this.readFileSync = /** @type {SyncFileSystem["readFileSync"]} */ (
  548. readFileSync
  549. );
  550. this._readJsonBackend = createBackend(
  551. duration,
  552. // prettier-ignore
  553. this.fileSystem.readJson ||
  554. (this.readFile &&
  555. (
  556. /**
  557. * @param {string} path path
  558. * @param {FileSystemCallback<EXPECTED_ANY>} callback callback
  559. */
  560. (path, callback) => {
  561. this.readFile(path, (err, buffer) => {
  562. if (err) return callback(err);
  563. if (!buffer || buffer.length === 0)
  564. {return callback(new Error("No file content"));}
  565. let data;
  566. try {
  567. data = JSON.parse(buffer.toString("utf8"));
  568. } catch (err_) {
  569. return callback(/** @type {Error} */ (err_));
  570. }
  571. callback(null, data);
  572. });
  573. })
  574. ),
  575. // prettier-ignore
  576. this.fileSystem.readJsonSync ||
  577. (this.readFileSync &&
  578. (
  579. /**
  580. * @param {string} path path
  581. * @returns {EXPECTED_ANY} result
  582. */
  583. (path) => {
  584. const buffer = this.readFileSync(path);
  585. const data = JSON.parse(buffer.toString("utf8"));
  586. return data;
  587. }
  588. )),
  589. this.fileSystem,
  590. );
  591. const readJson = this._readJsonBackend.provide;
  592. this.readJson = /** @type {FileSystem["readJson"]} */ (readJson);
  593. const readJsonSync = this._readJsonBackend.provideSync;
  594. this.readJsonSync = /** @type {SyncFileSystem["readJsonSync"]} */ (
  595. readJsonSync
  596. );
  597. this._readlinkBackend = createBackend(
  598. duration,
  599. this.fileSystem.readlink,
  600. this.fileSystem.readlinkSync,
  601. this.fileSystem,
  602. );
  603. const readlink = this._readlinkBackend.provide;
  604. this.readlink = /** @type {FileSystem["readlink"]} */ (readlink);
  605. const readlinkSync = this._readlinkBackend.provideSync;
  606. this.readlinkSync = /** @type {SyncFileSystem["readlinkSync"]} */ (
  607. readlinkSync
  608. );
  609. this._realpathBackend = createBackend(
  610. duration,
  611. this.fileSystem.realpath,
  612. this.fileSystem.realpathSync,
  613. this.fileSystem,
  614. );
  615. const realpath = this._realpathBackend.provide;
  616. this.realpath = /** @type {FileSystem["realpath"]} */ (realpath);
  617. const realpathSync = this._realpathBackend.provideSync;
  618. this.realpathSync = /** @type {SyncFileSystem["realpathSync"]} */ (
  619. realpathSync
  620. );
  621. }
  622. /**
  623. * @param {(string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>)=} what what to purge
  624. */
  625. purge(what) {
  626. this._statBackend.purge(what);
  627. this._lstatBackend.purge(what);
  628. this._readdirBackend.purgeParent(what);
  629. this._readFileBackend.purge(what);
  630. this._readlinkBackend.purge(what);
  631. this._readJsonBackend.purge(what);
  632. this._realpathBackend.purge(what);
  633. }
  634. };