File tree 4 files changed +11
-13
lines changed
4 files changed +11
-13
lines changed Original file line number Diff line number Diff line change 6
6
7
7
import { visit } from 'unist-util-visit'
8
8
9
- var own = { } . hasOwnProperty
9
+ const own = { } . hasOwnProperty
10
10
11
11
/**
12
12
*
13
13
* @param {Node } node
14
14
*/
15
15
export function definitions ( node ) {
16
16
/** @type {Object.<string, Definition> } */
17
- var cache = Object . create ( null )
17
+ const cache = Object . create ( null )
18
18
19
19
if ( ! node || ! node . type ) {
20
20
throw new Error ( 'mdast-util-definitions expected node' )
@@ -26,7 +26,7 @@ export function definitions(node) {
26
26
27
27
/** @type {DefinitionVisitor } */
28
28
function ondefinition ( definition ) {
29
- var id = clean ( definition . identifier )
29
+ const id = clean ( definition . identifier )
30
30
if ( id && ! own . call ( cache , id ) ) {
31
31
cache [ id ] = definition
32
32
}
@@ -39,7 +39,7 @@ export function definitions(node) {
39
39
* @returns {Definition|null }
40
40
*/
41
41
function getDefinition ( identifier ) {
42
- var id = clean ( identifier )
42
+ const id = clean ( identifier )
43
43
return id && own . call ( cache , id ) ? cache [ id ] : null
44
44
}
45
45
}
Original file line number Diff line number Diff line change 71
71
"xo" : {
72
72
"prettier" : true ,
73
73
"rules" : {
74
- "capitalized-comments" : " off" ,
75
- "no-var" : " off" ,
76
- "prefer-arrow-callback" : " off"
74
+ "capitalized-comments" : " off"
77
75
}
78
76
},
79
77
"remarkConfig" : {
Original file line number Diff line number Diff line change @@ -26,12 +26,12 @@ npm install mdast-util-definitions
26
26
## Use
27
27
28
28
``` js
29
- import remark from ' remark'
29
+ import { remark } from ' remark'
30
30
import {definitions } from ' mdast-util-definitions'
31
31
32
- var tree = remark ().parse (' [example]: https://example.com "Example"' )
32
+ const tree = remark ().parse (' [example]: https://example.com "Example"' )
33
33
34
- var definition = definitions (tree)
34
+ const definition = definitions (tree)
35
35
36
36
definition (' example' )
37
37
// => {type: 'definition', 'title': 'Example', …}
Original file line number Diff line number Diff line change @@ -6,12 +6,12 @@ import test from 'tape'
6
6
import remark from 'remark'
7
7
import { definitions } from './index.js'
8
8
9
- test ( 'mdast-util-definitions' , function ( t ) {
9
+ test ( 'mdast-util-definitions' , ( t ) => {
10
10
/** @type {Node } */
11
- var tree
11
+ let tree
12
12
13
13
t . throws (
14
- function ( ) {
14
+ ( ) => {
15
15
// @ts -ignore runtime
16
16
definitions ( )
17
17
} ,
You can’t perform that action at this time.
0 commit comments