Skip to content

Commit

Permalink
chore(src): lint
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Nov 25, 2024
1 parent 851dc96 commit dca6561
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions src/impvol-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ function guessFormat(specifier: string): ModuleFormat | undefined {
}
}

function shouldReload(): boolean {
return Atomics.load(uint8, 0) !== 0;
}

function reload() {
const buffer = readFileSync(tmp);
const cbor = new Uint8Array(buffer);
Expand All @@ -85,6 +81,10 @@ function reload() {
debug('Reloaded snapshot from %s', tmp);
}

function shouldReload(): boolean {
return Atomics.load(uint8, 0) !== 0;
}

export const resolve: ResolveHook = (specifier, context, nextResolve) => {
const start = performance.now();
if (shouldReload()) {
Expand Down
42 changes: 21 additions & 21 deletions src/impvol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,6 @@ const metadata = new WeakMap<
}
>();

/**
* Updates the snapshot of the {@link ImportableVolume}.
*
* It writes to the temp file associated with the `ImportableVolume`, then sets
* the dirty bit.
*
* @param impvol {@link ImportableVolume} to snapshot
* @throws {ReferenceError} If metadata is missing
* @internal
*/
function update(impvol: ImportableVolume): void {
const snapshot = toBinarySnapshotSync({fs: impvol});
const {tmp, uint8} = metadata.get(impvol)!;
if (!tmp || !uint8) {
throw new ReferenceError('Missing metadata');
}
writeFileSync(tmp, snapshot);
Atomics.store(uint8, 0, 1);
debug('Updated snapshot');
}

export class ImportableVolume extends Volume {
constructor(props?: {File?: File; Link?: Link; Node?: Node}) {
super(props);
Expand Down Expand Up @@ -121,6 +100,27 @@ export class ImportableVolume extends Volume {
}
}

/**
* Updates the snapshot of the {@link ImportableVolume}.
*
* It writes to the temp file associated with the `ImportableVolume`, then sets
* the dirty bit.
*
* @param impvol {@link ImportableVolume} to snapshot
* @throws {ReferenceError} If metadata is missing
* @internal
*/
function update(impvol: ImportableVolume): void {
const snapshot = toBinarySnapshotSync({fs: impvol});
const {tmp, uint8} = metadata.get(impvol)!;
if (!tmp || !uint8) {
throw new ReferenceError('Missing metadata');
}
writeFileSync(tmp, snapshot);
Atomics.store(uint8, 0, 1);
debug('Updated snapshot');
}

// overrides private methods such that meaningful filesystem writes trigger an
// update on the worker thread. Note that using a `FSWatcher` was attempted, but
// memfs' implementation is probably Wrong; the change/rename events are emitted
Expand Down

0 comments on commit dca6561

Please sign in to comment.