Skip to content

Commit 3ffc44f

Browse files
addaleaxdurran
authored andcommitted
fixup! fix: clean up instanceof usage
1 parent 9b6d52a commit 3ffc44f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/parser/calculate_size.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ function calculateElement(
8383
return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (12 + 1);
8484
} else if (value instanceof Date || isDate(value)) {
8585
return (name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (8 + 1);
86-
} else if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer || isAnyArrayBuffer(value)) {
86+
} else if (
87+
ArrayBuffer.isView(value) ||
88+
value instanceof ArrayBuffer ||
89+
isAnyArrayBuffer(value)
90+
) {
8791
return (
8892
(name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) + (1 + 4 + 1) + value.byteLength
8993
);
@@ -185,10 +189,7 @@ function calculateElement(
185189
}
186190
case 'function':
187191
// WTF for 0.4.X where typeof /someregexp/ === 'function'
188-
if (
189-
value instanceof RegExp || isRegExp(value) ||
190-
String.call(value) === '[object RegExp]'
191-
) {
192+
if (value instanceof RegExp || isRegExp(value) || String.call(value) === '[object RegExp]') {
192193
return (
193194
(name != null ? Buffer.byteLength(name, 'utf8') + 1 : 0) +
194195
1 +

src/parser/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export const randomBytes = detectRandomBytes();
6464

6565
export function isAnyArrayBuffer(value: unknown): value is ArrayBuffer {
6666
return ['[object ArrayBuffer]', '[object SharedArrayBuffer]'].includes(
67-
Object.prototype.toString.call(value));
67+
Object.prototype.toString.call(value)
68+
);
6869
}
6970

7071
export function isUint8Array(value: unknown): value is Uint8Array {

0 commit comments

Comments
 (0)