Closed james-pre closed 1 year ago
Internally, BrowserFS follows Node's FS API. For example (in a backend):
operation(path: string, cred: Cred, callback: BFSOneArgCallback<ResultType>); operationSync(path: string, cred: Cred): ResultType;
While emulating Node's API for the end user is the goal, we can be simpler internally. In conjunction with #342 we can simply do something like follows:
operation(path: string, cred: Cred, callback: BFSOneArgCallback<ResultType>): ResultType;
A sync backend could do something like this:
operation(path: string, cred: Cred, callback: BFSOneArgCallback<ResultType>): ResultType { const result = this._doSomething(path, cred); callback(result); return result; }
While an async backend could implement something like this (See #342):
operation(path: string, cred: Cred, callback: BFSOneArgCallback<ResultType>): ResultType { const result = this._sync._doSomething(path, cred); this._async.doSomething(path, cred, callback); return result; }
Then, the consumer (FS module) can use the sync or async part of the function.
This is unnecessary since the current system works fine.
Internally, BrowserFS follows Node's FS API. For example (in a backend):
While emulating Node's API for the end user is the goal, we can be simpler internally. In conjunction with #342 we can simply do something like follows:
A sync backend could do something like this:
While an async backend could implement something like this (See #342):
Then, the consumer (FS module) can use the sync or async part of the function.