Skip to content

Commit

Permalink
fix: πŸ› refactor #truncate to be compatible w/ strictNullChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jul 7, 2019
1 parent 415a186 commit fadbd77
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/volume.ts
Expand Up @@ -1754,9 +1754,11 @@ export class Volume {
truncate(id: TFileId, callback: TCallback<void>);
truncate(id: TFileId, len: number, callback: TCallback<void>);
truncate(id: TFileId, a: TCallback<void> | number, b?: TCallback<void>) {
if (isFd(id)) return this.ftruncate(id as number, a as any, b);
const len: number = typeof a === 'number' ? a : 0;
const callback: TCallback<void> = validateCallback(typeof a === 'number' ? b : a);

if (isFd(id)) return this.ftruncate(id as number, len, callback);

const [len, callback] = getArgAndCb<number, void>(a, b, 0);
this.wrapAsync(this.truncateBase, [id, len], callback);
}

Expand Down

0 comments on commit fadbd77

Please sign in to comment.