From fadbd771ca113758772dc50b999fb74d79db2e15 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 7 Jul 2019 15:58:25 +1200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20refactor=20`#truncate`=20?= =?UTF-8?q?to=20be=20compatible=20w/=20`strictNullChecks`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/volume.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/volume.ts b/src/volume.ts index 59513fdb..667e3d88 100644 --- a/src/volume.ts +++ b/src/volume.ts @@ -1754,9 +1754,11 @@ export class Volume { truncate(id: TFileId, callback: TCallback); truncate(id: TFileId, len: number, callback: TCallback); truncate(id: TFileId, a: TCallback | number, b?: TCallback) { - if (isFd(id)) return this.ftruncate(id as number, a as any, b); + const len: number = typeof a === 'number' ? a : 0; + const callback: TCallback = validateCallback(typeof a === 'number' ? b : a); + + if (isFd(id)) return this.ftruncate(id as number, len, callback); - const [len, callback] = getArgAndCb(a, b, 0); this.wrapAsync(this.truncateBase, [id, len], callback); }