-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvfs.js
More file actions
103 lines (101 loc) · 2.83 KB
/
Copy pathvfs.js
File metadata and controls
103 lines (101 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
export const fs = {
'/': {
type: 'dir',
children: {
'theres_nowt_here.txt': {
type: 'file',
content: 'What are you looking for? Did you find it?'
},
'home': {
type: 'dir',
children: {
'hello_world.txt': {
type: 'file',
content: `Why did the developer go broke?
Because he used up all his cache printing "Hello, World!" in 15 different languages.`
},
'user': {
type: 'dir',
children: {
'resume': {
type: 'dir',
children: {
'profile.txt': {
type: 'cv',
content: 'This is profile.txt content'
},
'experience.txt': {
type: 'cv',
content: 'This is experience.txt content'
},
'technical_skills.txt': {
type: 'cv',
content: 'This is techincal_skills.txt content'
},
'education.txt': {
type: 'cv',
content: 'This is education.txt content'
},
'languages.txt': {
type: 'cv',
content: 'This is languages.txt content'
},
}
},
'blog': {
type: 'dir',
children: {
'old_posts': { type: 'dir', children: {} }
}
},
'portfolio': {
type: 'dir',
children: {
'est_service.tf': {
type: 'repo',
},
'smiley_kivy.py': {
type: 'repo'
},
'tf-sync.sh': {
type: 'repo'
},
'esp_iot.h': {
type: 'repo'
},
'data-board.tf': {
type: 'repo',
},
'actuallypav.github.io.js': {
type: 'repo',
},
}
},
'contact': {
type: 'dir',
children: {
'contact.txt': {
type: 'cv',
content: 'This is contact.txt content'
}
}
}
}
}
}
}
}
}
};
export function getNodeFromPath(p, fsRoot = fs['/']) {
const parts = p.split('/').filter(Boolean);
let node = fsRoot;
for (let part of parts) {
if (node.children[part]) {
node = node.children[part];
} else {
return null;
}
}
return node;
}