File tree Expand file tree Collapse file tree 1 file changed +4
-24
lines changed Expand file tree Collapse file tree 1 file changed +4
-24
lines changed Original file line number Diff line number Diff line change 22
22
23
23
import { location } from 'vfile-location'
24
24
25
- const search = / \r ? \n | \r / g
26
-
27
25
/**
28
26
* Get the source of a node or at a position.
29
27
*
@@ -49,27 +47,9 @@ export function source(file, value) {
49
47
}
50
48
51
49
const endOffset = loc . toOffset ( position . end )
52
- let startOffset = loc . toOffset ( position . start )
53
-
54
- if ( endOffset === undefined || startOffset === undefined ) {
55
- return undefined
56
- }
57
-
58
- /** @type {Array<string> } */
59
- const results = [ ]
60
-
61
- while ( startOffset < endOffset ) {
62
- search . lastIndex = startOffset
63
- const match = search . exec ( doc )
64
- const end = match && match . index < endOffset ? match . index : endOffset
65
- results . push ( doc . slice ( startOffset , end ) )
66
- startOffset = end
67
-
68
- if ( match && match . index < endOffset ) {
69
- startOffset += match [ 0 ] . length
70
- results . push ( match [ 0 ] )
71
- }
72
- }
50
+ const startOffset = loc . toOffset ( position . start )
73
51
74
- return results . join ( '' )
52
+ return endOffset === undefined || startOffset === undefined
53
+ ? undefined
54
+ : doc . slice ( startOffset , endOffset )
75
55
}
You can’t perform that action at this time.
0 commit comments