tangled
alpha
login
or
join now
tbeseda.com
/
array-treeify
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
fix readme example test
tbeseda.com
11 months ago
01460fef
eea7844a
+10
-34
4 changed files
expand all
collapse all
unified
split
README.md
package.json
src
edge-cases.test.ts
readme-examples.test.ts
+5
-5
README.md
···
54
54
'...',
55
55
'Jame Eagan',
56
56
['Helena Eagan']
57
57
-
],
57
57
+
],
58
58
+
'Ambrose Eagan',
58
59
],
59
59
-
'Ambrose Eagan'
60
60
]
61
61
console.log(treeify(eagan))
62
62
/*
63
63
Kier Eagan
64
64
├─ ...
65
65
-
| ├─ ...
66
66
-
| └─ Jame Eagan
67
67
-
| └─ Helena Eagan
65
65
+
│ ├─ ...
66
66
+
│ └─ Jame Eagan
67
67
+
│ └─ Helena Eagan
68
68
└─ Ambrose Eagan
69
69
*/
70
70
+1
-1
package.json
···
11
11
"files": ["dist"],
12
12
"scripts": {
13
13
"lint": "biome check --write .",
14
14
-
"build": "tsc",
14
14
+
"build": "rm -rf dist && tsc",
15
15
"pretest": "npm run build",
16
16
"test": "node --test",
17
17
"posttest": "npm run lint",
-23
src/edge-cases.test.ts
···
1
1
-
import assert from 'node:assert'
2
2
-
import { describe, test } from 'node:test'
3
3
-
import { treeify } from './index.js'
4
4
-
5
5
-
describe('edge cases', () => {
6
6
-
test('root with nested children and sibling', () => {
7
7
-
const input = [
8
8
-
'root',
9
9
-
['child1', ['grandchild1', 'grandchild2']],
10
10
-
'sibling',
11
11
-
]
12
12
-
const expected = `root
13
13
-
├─ child1
14
14
-
│ ├─ grandchild1
15
15
-
│ └─ grandchild2
16
16
-
└─ sibling`
17
17
-
18
18
-
const result = treeify(input)
19
19
-
console.log('\nRoot with nested children and sibling:')
20
20
-
console.log(result)
21
21
-
assert.strictEqual(result, expected)
22
22
-
})
23
23
-
})
+4
-5
src/readme-examples.test.ts
···
6
6
test('basic example', () => {
7
7
const eagan = [
8
8
'Kier Eagan',
9
9
-
['...', ['...', 'Jame Eagan', ['Helena Eagan']]],
10
10
-
'Ambrose Eagan',
9
9
+
['...', ['...', 'Jame Eagan', ['Helena Eagan']], 'Ambrose Eagan'],
11
10
]
12
11
const expected = `Kier Eagan
13
12
├─ ...
14
14
-
| ├─ ...
15
15
-
| └─ Jame Eagan
16
16
-
| └─ Helena Eagan
13
13
+
│ ├─ ...
14
14
+
│ └─ Jame Eagan
15
15
+
│ └─ Helena Eagan
17
16
└─ Ambrose Eagan`
18
17
19
18
const result = treeify(eagan)