Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: πŸ› refactor #access to be compatible w/ strictNullChecks
  • Loading branch information
G-Rath committed Jul 7, 2019
1 parent ba0c20a commit 82ed81b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/volume.ts
Expand Up @@ -1591,16 +1591,17 @@ export class Volume {
access(path: TFilePath, callback: TCallback<void>);
access(path: TFilePath, mode: number, callback: TCallback<void>);
access(path: TFilePath, a: TCallback<void> | number, b?: TCallback<void>) {
let mode: number = a as number;
let callback: TCallback<void> = b;
let mode: number = F_OK;
let callback: TCallback<void>;

if (typeof mode === 'function') {
mode = F_OK;
callback = a as TCallback<void>;
if (typeof a !== 'function') {
mode = a | 0; // cast to number
callback = validateCallback(b);
} else {
callback = a;
}

const filename = pathToFilename(path);
mode = mode | 0;

this.wrapAsync(this.accessBase, [filename, mode], callback);
}
Expand Down

0 comments on commit 82ed81b

Please sign in to comment.