File tree Expand file tree Collapse file tree 4 files changed +26
-23
lines changed Expand file tree Collapse file tree 4 files changed +26
-23
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,10 @@ export function parents(node) {
35
35
* Proxy of `node`.
36
36
*/
37
37
function wrapNode ( node , parent ) {
38
- if ( cache . has ( node ) ) {
39
- return cache . get ( node )
38
+ const entry = cache . get ( node )
39
+
40
+ if ( entry ) {
41
+ return entry
40
42
}
41
43
42
44
/** @type {Proxy } */
@@ -46,6 +48,7 @@ function wrapNode(node, parent) {
46
48
47
49
for ( key in node ) {
48
50
if ( key !== 'children' ) {
51
+ // @ts -expect-error: indexable.
49
52
proxy [ key ] = node [ key ]
50
53
}
51
54
}
Original file line number Diff line number Diff line change 39
39
"@types/unist" : " ^2.0.0"
40
40
},
41
41
"devDependencies" : {
42
- "@types/clone" : " ^2.1.1" ,
42
+ "@types/clone" : " ^2.0.0" ,
43
+ "@types/mdast" : " ^3.0.0" ,
43
44
"@types/tape" : " ^4.0.0" ,
44
45
"c8" : " ^7.0.0" ,
45
46
"clone" : " ^2.0.0" ,
46
47
"prettier" : " ^2.0.0" ,
47
48
"remark-cli" : " ^11.0.0" ,
48
49
"remark-preset-wooorm" : " ^9.0.0" ,
49
- "rimraf" : " ^3.0.0" ,
50
50
"tape" : " ^5.0.0" ,
51
51
"type-coverage" : " ^2.0.0" ,
52
52
"typescript" : " ^4.0.0" ,
53
53
"xo" : " ^0.53.0"
54
54
},
55
55
"scripts" : {
56
56
"prepack" : " npm run build && npm run format" ,
57
- "build" : " rimraf \" *.d.ts \" && tsc && type-coverage" ,
57
+ "build" : " tsc --build --clean && tsc --build && type-coverage" ,
58
58
"format" : " remark . -qfo && prettier . -w --loglevel warn && xo --fix" ,
59
- "test-api" : " node test.js" ,
60
- "test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 -- reporter lcov node test.js " ,
59
+ "test-api" : " node --conditions development test.js" ,
60
+ "test-coverage" : " c8 --check-coverage --100 --reporter lcov npm run test-api " ,
61
61
"test" : " npm run build && npm run format && npm run test-coverage"
62
62
},
63
63
"prettier" : {
76
76
},
77
77
"remarkConfig" : {
78
78
"plugins" : [
79
- " preset-wooorm"
79
+ " remark- preset-wooorm"
80
80
]
81
81
},
82
82
"typeCoverage" : {
Original file line number Diff line number Diff line change 1
1
/**
2
- * @typedef {import('unist ').Node } Node
2
+ * @typedef {import('mdast ').Root } Root
3
3
* @typedef {import('unist').Parent } Parent
4
4
*/
5
5
6
6
import test from 'tape'
7
+ // To do: replace with `structuredClone` when stable.
7
8
import clone from 'clone'
8
9
import { parents } from './index.js'
9
10
11
+ /** @type {Root } */
10
12
const ast = {
11
13
type : 'root' ,
12
14
children : [
@@ -29,12 +31,8 @@ test('immutable', function (t) {
29
31
t . deepEqual ( ast , original , 'original AST is unchanged' )
30
32
t . notEqual ( root , ast , 'returns a different object' )
31
33
t . deepEqual ( root , ast , 'structurally equivalent' )
32
- t . equal (
33
- // type-coverage:ignore-next-line, yeah, that’s expected.
34
- ast . children [ 0 ] . parent ,
35
- undefined ,
36
- 'original AST does not obtain parent links'
37
- )
34
+ const head = ast . children [ 0 ]
35
+ t . ok ( ! ( 'parent' in head ) , 'original AST does not obtain parent links' )
38
36
t . end ( )
39
37
} )
40
38
Original file line number Diff line number Diff line change 1
1
{
2
- "include" : [" *.js" ],
2
+ "include" : [" **/*.js" ],
3
+ "exclude" : [" coverage/" , " node_modules/" ],
3
4
"compilerOptions" : {
4
- "target" : " ES2020" ,
5
- "lib" : [" ES2020" ],
6
- "module" : " ES2020" ,
7
- "moduleResolution" : " node" ,
8
- "allowJs" : true ,
9
5
"checkJs" : true ,
10
6
"declaration" : true ,
11
7
"emitDeclarationOnly" : true ,
12
- "allowSyntheticDefaultImports" : true ,
13
- "skipLibCheck" : true
8
+ "exactOptionalPropertyTypes" : true ,
9
+ "forceConsistentCasingInFileNames" : true ,
10
+ "lib" : [" es2020" ],
11
+ "module" : " node16" ,
12
+ "newLine" : " lf" ,
13
+ "skipLibCheck" : true ,
14
+ "strict" : true ,
15
+ "target" : " es2020"
14
16
}
15
17
}
You can’t perform that action at this time.
0 commit comments