Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Commit 619004e

Browse files
samvloeberghsfknop
authored andcommitted
Update bytes.pipe.ts (#89)
I've put an if check inside the format loop, checking for `hasOwnProperty.` Why: https://palantir.github.io/tslint/rules/forin/ Another approach would have been to use `Object.keys(BytesPipe.formats).forEach` but there is no nice way of breaking out a forEach.
1 parent b2f5d37 commit 619004e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/math/bytes.pipe.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ export class BytesPipe implements PipeTransform {
4444
}
4545

4646
for (const key in BytesPipe.formats) {
47-
const format = BytesPipe.formats[key];
48-
if (bytes < format.max) {
47+
if (BytesPipe.formats.hasOwnProperty(key)) {
48+
const format = BytesPipe.formats[key];
49+
if (bytes < format.max) {
4950

50-
const result = toDecimal(BytesPipe.calculateResult(format, bytes), decimal);
51+
const result = toDecimal(BytesPipe.calculateResult(format, bytes), decimal);
5152

52-
return BytesPipe.formatResult(result, key);
53+
return BytesPipe.formatResult(result, key);
54+
}
5355
}
5456
}
5557
}
@@ -62,4 +64,4 @@ export class BytesPipe implements PipeTransform {
6264
const prev = format.prev ? BytesPipe.formats[format.prev] : undefined;
6365
return prev ? bytes / prev.max : bytes;
6466
}
65-
}
67+
}

0 commit comments

Comments
 (0)