Skip to content

Commit 7be7988

Browse files
chore: fix JavaScript lint errors (issue #9825)
1 parent 1b8a546 commit 7be7988

1 file changed

Lines changed: 31 additions & 19 deletions

File tree

  • lib/node_modules/@stdlib/_tools/remark/plugins/remark-stdlib-urls-www/lib

lib/node_modules/@stdlib/_tools/remark/plugins/remark-stdlib-urls-www/lib/transformer.js

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,36 @@ var debug = logger( 'remark-stdlib-urls-www:transformer' );
3030
var RE_STDLIB = /^@stdlib\//;
3131

3232

33+
// FUNCTIONS //
34+
35+
/**
36+
* Returns a visitor function.
37+
*
38+
* @private
39+
* @param {Options} opts - transformer options
40+
* @param {string} opts.base - base path for internal URLs
41+
* @returns {Function} visitor function
42+
*/
43+
function createVisitor( opts ) {
44+
/**
45+
* Callback invoked upon finding a matching node.
46+
*
47+
* @private
48+
* @param {Node} node - reference node
49+
*/
50+
return function visitor( node ) {
51+
debug( 'Found a definition: %s', node.identifier );
52+
if ( RE_STDLIB.test( node.identifier ) ) {
53+
debug( 'Found a package identifier.' );
54+
55+
debug( 'Current URL: %s', node.url );
56+
node.url = opts.base + node.identifier;
57+
debug( 'Resolved URL: %s', node.url );
58+
}
59+
};
60+
}
61+
62+
3363
// MAIN //
3464

3565
/**
@@ -41,36 +71,18 @@ var RE_STDLIB = /^@stdlib\//;
4171
* @returns {Function} transformer function
4272
*/
4373
function factory( opts ) {
74+
var visitor = createVisitor( opts );
4475
return transformer;
4576

4677
/**
4778
* Transforms a Markdown abstract syntax tree (AST).
4879
*
4980
* @private
5081
* @param {Node} tree - root AST node
51-
* @param {File} file - virtual file
5282
*/
5383
function transformer( tree ) {
5484
debug( 'Processing virtual file...' );
5585
visit( tree, 'definition', visitor );
56-
57-
/**
58-
* Callback invoked upon finding a matching node.
59-
*
60-
* @private
61-
* @param {Node} node - reference node
62-
*/
63-
function visitor( node ) {
64-
debug( 'Found a definition: %s', node.identifier );
65-
if ( RE_STDLIB.test( node.identifier ) ) {
66-
debug( 'Found a package identifier.' );
67-
68-
debug( 'Current URL: %s', node.url );
69-
node.url = opts.base + node.identifier;
70-
71-
debug( 'Resolved URL: %s', node.url );
72-
}
73-
}
7486
}
7587
}
7688

0 commit comments

Comments
 (0)