-
Notifications
You must be signed in to change notification settings - Fork 10
/
path.js
46 lines (36 loc) · 770 Bytes
/
path.js
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
'use strict';
exports.start = start;
function start() {
return ['start'];
}
exports.toName = pathToName;
function pathToName(path) {
var name = path[0];
var i;
for (i = 1; i < path.length - 1; i++) {
name += '.' + path[i];
}
var last = path[i];
if (path.length > 1 && last !== 0) {
name += '.' + last;
}
return name;
}
exports.next = nextPath;
function nextPath(path) {
path = path.slice();
path[path.length - 1]++;
return path;
}
exports.firstChild = firstChildPath;
function firstChildPath(path) {
path = path.slice();
path.push(1);
return path;
}
exports.zerothChild = zerothChildPath;
function zerothChildPath(path) {
path = path.slice();
path.push(0);
return path;
}