We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7f76569 commit 6df8579Copy full SHA for 6df8579
src/index.js
@@ -15,6 +15,11 @@ const types = [
15
'hamt-sharded-directory'
16
]
17
18
+const dirTypes = [
19
+ 'directory',
20
+ 'hamt-sharded-directory'
21
+]
22
+
23
function Data (type, data) {
24
if (!(this instanceof Data)) {
25
return new Data(type, data)
@@ -37,6 +42,11 @@ function Data (type, data) {
37
42
38
43
// data.length + blockSizes
39
44
this.fileSize = () => {
45
+ if (dirTypes.indexOf(this.type) >= 0) {
46
+ // dirs don't have file size
47
+ return undefined
48
+ }
49
40
50
let sum = 0
41
51
this.blockSizes.forEach((size) => {
52
sum += size
@@ -63,7 +73,7 @@ function Data (type, data) {
63
73
}
64
74
let fileSize = this.fileSize()
65
75
66
- if (fileSize === 0) {
76
+ if (!fileSize) {
67
77
fileSize = undefined
68
78
69
79
0 commit comments