Skip to content

Commit

Permalink
refactor: 💡 extract worker URL setting to be a param
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jun 19, 2023
1 parent 53784d9 commit 19eccbe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions demo/fsa/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import type * as fsa from '../../src/fsa/types';
import {FsaNodeFs, FsaNodeSyncAdapterWorker} from '../../src/fsa-to-node';

const demo = async (dir: fsa.IFileSystemDirectoryHandle) => {
console.log('demo', dir);
const adapter = await FsaNodeSyncAdapterWorker.start(dir);
const adapter = await FsaNodeSyncAdapterWorker.start('https://localhost:9876/worker.js', dir);
const fs = new FsaNodeFs(dir, adapter);

await fs.promises.mkdir('/dir');
Expand Down Expand Up @@ -104,6 +103,7 @@ const demo = async (dir: fsa.IFileSystemDirectoryHandle) => {
strictEqual(fs.existsSync('/new-file.txt'), false);
const fd = fs.openSync('/new-file.txt', 'w');
strictEqual(fs.existsSync('/new-file.txt'), true);
fs.unlinkSync('/new-file.txt');
strictEqual(typeof fd, 'number');
};

Expand Down
4 changes: 2 additions & 2 deletions src/fsa-to-node/worker/FsaNodeSyncAdapterWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import type {
let rootId = 0;

export class FsaNodeSyncAdapterWorker implements FsaNodeSyncAdapter {
public static async start(dir: fsa.IFileSystemDirectoryHandle): Promise<FsaNodeSyncAdapterWorker> {
const worker = new Worker('https://localhost:9876/worker.js');
public static async start(url: string, dir: fsa.IFileSystemDirectoryHandle): Promise<FsaNodeSyncAdapterWorker> {
const worker = new Worker(url);
const future = new Defer<FsaNodeSyncAdapterWorker>();
let id = rootId++;
let messenger: SyncMessenger | undefined = undefined;
Expand Down

0 comments on commit 19eccbe

Please sign in to comment.