File tree Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Expand file tree Collapse file tree 3 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ import {location} from 'vfile-location'
2424
2525const search = / \r ? \n | \r / g
2626
27- // To do: return `undefined`.
2827// To do: change parameter order, to allow `value` to be missing.
2928/**
3029 * Get the source of a node or at a position.
@@ -33,7 +32,7 @@ const search = /\r?\n|\r/g
3332 * Value to get.
3433 * @param {VFile | VFileValue } file
3534 * File in which `value` exists.
36- * @returns {string | null }
35+ * @returns {string | undefined }
3736 * Source of `value` in `doc`, if available.
3837 */
3938export function source ( value , file ) {
@@ -47,14 +46,14 @@ export function source(value, file) {
4746 : undefined
4847
4948 if ( ! position ) {
50- return null
49+ return undefined
5150 }
5251
5352 const endOffset = loc . toOffset ( position . end )
5453 let startOffset = loc . toOffset ( position . start )
5554
5655 if ( endOffset === undefined || startOffset === undefined ) {
57- return null
56+ return undefined
5857 }
5958
6059 /** @type {Array<string> } */
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ Get the source of a node or at a position.
102102
103103###### Returns
104104
105- Source of ` value ` in ` doc ` , if available (` string ` or ` null ` ).
105+ Source of ` value ` in ` doc ` , if available (` string ` or ` undefined ` ).
106106
107107## Types
108108
Original file line number Diff line number Diff line change @@ -70,16 +70,16 @@ test('source', async function (t) {
7070 value : 'qwe' ,
7171 position : { start : { line : 0 , column : 0 } , end : { line : 0 , column : 0 } }
7272 }
73- assert . equal ( source ( text , file ) , null )
73+ assert . equal ( source ( text , file ) , undefined )
7474 } )
7575
7676 await t . test ( 'should support a generated node' , async function ( ) {
7777 const text = { type : 'text' , value : 'qwe' }
78- assert . equal ( source ( text , file ) , null )
78+ assert . equal ( source ( text , file ) , undefined )
7979 } )
8080
8181 await t . test ( 'should support a nullish node' , async function ( ) {
82- assert . equal ( source ( null , file ) , null )
82+ assert . equal ( source ( null , file ) , undefined )
8383 } )
8484
8585 await t . test ( 'should support cr + lf' , async function ( ) {
You can’t perform that action at this time.
0 commit comments