3
3
*/
4
4
5
5
// --------------------------------------------------------------------------------
6
- // Require
6
+ // Import
7
7
// --------------------------------------------------------------------------------
8
8
9
- const cheerio = require ( 'cheerio' ) ;
10
-
11
- const UriTypes = require ( '../uri-types' ) ;
12
- const getDefinitionNodeUriType = require ( '../get-definition-node-uri-type' ) ;
9
+ import * as cheerio from 'cheerio' ;
10
+ import UriTypes from '../uri-types/index.js' ;
11
+ import getDefinitionNodeUriType from '../get-definition-node-uri-type/index.js' ;
13
12
14
13
// --------------------------------------------------------------------------------
15
14
// Typedefs
@@ -20,30 +19,32 @@ const getDefinitionNodeUriType = require('../get-definition-node-uri-type');
20
19
*/
21
20
22
21
// --------------------------------------------------------------------------------
23
- // Helpers
22
+ // Export
24
23
// --------------------------------------------------------------------------------
25
24
26
25
/**
27
26
* Retrieves URI from a given `Link` node and returns an instance of `UriTypes`.
28
27
* @param {TxtLinkNode } node `Link` type node.
29
28
* @return {UriTypes }
30
29
*/
31
- const getUriTypesLink = ( { url } ) => new UriTypes ( ) . push ( { uri : url , type : 'link' } ) ;
30
+ export const getUriTypesLink = ( { url } ) =>
31
+ new UriTypes ( ) . push ( { uri : url , type : 'link' } ) ;
32
32
33
33
/**
34
34
* Retrieves URI from a given `Image` node and returns an instance of `UriTypes`.
35
35
* @param {TxtImageNode } node `Image` type node.
36
36
* @return {UriTypes }
37
37
*/
38
- const getUriTypesImage = ( { url } ) => new UriTypes ( ) . push ( { uri : url , type : 'image' } ) ;
38
+ export const getUriTypesImage = ( { url } ) =>
39
+ new UriTypes ( ) . push ( { uri : url , type : 'image' } ) ;
39
40
40
41
/**
41
42
* Retrieves URI from a given `Definition` node and returns an instance of `UriTypes`.
42
43
* @param {TxtDefinitionNode } node `Definition` type node.
43
44
* @return {Promise<UriTypes> }
44
45
* @async
45
46
*/
46
- const getUriTypesDefinition = async ( { url } ) => {
47
+ export const getUriTypesDefinition = async ( { url } ) => {
47
48
const type = await getDefinitionNodeUriType ( url ) ;
48
49
49
50
return type === 'link' || type === 'image'
@@ -56,7 +57,7 @@ const getUriTypesDefinition = async ({ url }) => {
56
57
* @param {TxtHtmlNode } node `Html` type node.
57
58
* @return {UriTypes }
58
59
*/
59
- const getUriTypesHtml = ( { value } ) => {
60
+ export const getUriTypesHtml = ( { value } ) => {
60
61
const uriTypes = new UriTypes ( ) ;
61
62
const $ = cheerio . load ( value ) ;
62
63
@@ -78,14 +79,3 @@ const getUriTypesHtml = ({ value }) => {
78
79
79
80
return uriTypes ;
80
81
} ;
81
-
82
- // --------------------------------------------------------------------------------
83
- // Exports
84
- // --------------------------------------------------------------------------------
85
-
86
- module . exports = {
87
- getUriTypesLink,
88
- getUriTypesImage,
89
- getUriTypesDefinition,
90
- getUriTypesHtml,
91
- } ;
0 commit comments