@@ -37,7 +37,6 @@ metadata about files (such as its `path` and `value`) and lint
3737 * [ ` VFile#info(reason[, options]) ` ] ( #vfileinforeason-options )
3838 * [ ` VFile#message(reason[, options]) ` ] ( #vfilemessagereason-options )
3939 * [ ` VFile#toString(encoding?) ` ] ( #vfiletostringencoding )
40- * [ ` BufferEncoding ` ] ( #bufferencoding )
4140 * [ ` Compatible ` ] ( #compatible )
4241 * [ ` Data ` ] ( #data )
4342 * [ ` DataMap ` ] ( #datamap )
@@ -170,7 +169,7 @@ Create a new virtual file.
170169
171170` options ` is treated as:
172171
173- * ` string ` or [ ` Buffer ` ] [ buffer ] — ` {value: options} `
172+ * ` string ` or [ ` Uint8Array ` ] [ mdn-uint8-array ] — ` {value: options} `
174173* ` URL ` — ` {path: options} `
175174* ` VFile ` — shallow copies its data over to the new file
176175* ` object ` — all fields are shallow copied over to the new file
@@ -196,7 +195,7 @@ New instance (`VFile`).
196195``` js
197196new VFile ()
198197new VFile (' console.log("alpha");' )
199- new VFile (Buffer . from ( ' exit 1 ' ))
198+ new VFile (new Uint8Array ([ 0x65 , 0x78 , 0x69 , 0x74 , 0x20 , 0x31 ] ))
200199new VFile ({path: path .join (' path' , ' to' , ' readme.md' )})
201200new VFile ({stem: ' readme' , extname: ' .md' , dirname: path .join (' path' , ' to' )})
202201new VFile ({other: ' properties' , are: ' copied' , ov: {e: ' r' }})
@@ -226,7 +225,7 @@ List of messages associated with the file
226225
227226### ` file.value `
228227
229- Raw value ([ ` Buffer ` ] [ buffer ] , ` string ` , ` undefined ` ).
228+ Raw value ([ ` Uint8Array ` ] [ mdn-uint8-array ] , ` string ` , ` undefined ` ).
230229
231230### ` file.basename `
232231
@@ -337,39 +336,20 @@ Message ([`VFileMessage`][vmessage]).
337336
338337Serialize the file.
339338
339+ > ** Note** : which encodings are supported depends on the engine.
340+ > For info on Node.js, see:
341+ > < https://nodejs.org/api/util.html#whatwg-supported-encodings > .
342+
340343###### Parameters
341344
342- * ` encoding ` ([ ` BufferEncoding ` ] [ api-buffer-encoding ] , default: ` 'utf8' ` )
345+ * ` encoding ` (` string ` , default: ` 'utf8' ` )
343346 — character encoding to understand ` value ` as when it’s a
344- [ ` Buffer ` ] [ buffer ]
347+ [ ` Uint8Array ` ] [ mdn-uint8-array ]
345348
346349###### Returns
347350
348351Serialized file (` string ` ).
349352
350- ### ` BufferEncoding `
351-
352- [ Encodings] [ encoding ] supported by the [ buffer] [ ] class (TypeScript type).
353-
354- This is a copy of the types from Node.
355-
356- ###### Type
357-
358- ``` ts
359- type BufferEncoding =
360- | ' ascii'
361- | ' base64'
362- | ' base64url'
363- | ' binary'
364- | ' hex'
365- | ' latin1'
366- | ' ucs-2'
367- | ' ucs2'
368- | ' utf-8'
369- | ' utf16le'
370- | ' utf8'
371- ` ` `
372-
373353### ` Compatible `
374354
375355Things that can be passed to the constructor (TypeScript type).
@@ -497,12 +477,12 @@ type ReporterSettings = Record<string, unknown>
497477
498478Contents of the file (TypeScript type).
499479
500- Can either be text or a ` Buffer ` structure.
480+ Can either be text or a [ ` Uint8Array ` ][mdn-uint8-array] structure.
501481
502482###### Type
503483
504484` ` ` ts
505- type Value = Buffer | string
485+ type Value = Uint8Array | string
506486` ` `
507487
508488### Well-known
@@ -586,7 +566,6 @@ There are also well-known fields on messages, see
586566
587567This package is fully typed with [TypeScript][].
588568It exports the additional types
589- [ ` BufferEncoding ` ][api-buffer-encoding],
590569[ ` Compatible ` ][api-compatible],
591570[ ` Data ` ][api-data],
592571[ ` DataMap ` ][api-data-map],
@@ -773,9 +752,7 @@ for contributing commits since!
773752
774753[vfile-message-options]: https://github.com/vfile/vfile-message#options
775754
776- [encoding]: https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
777-
778- [buffer]: https://nodejs.org/api/buffer.html
755+ [mdn-uint8-array]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
779756
780757[source-map]: https://github.com/mozilla/source-map/blob/58819f0/source-map.d.ts#L15-L23
781758
@@ -789,8 +766,6 @@ for contributing commits since!
789766
790767[api-vfile]: #vfileoptions
791768
792- [api-buffer-encoding]: #bufferencoding
793-
794769[api-compatible]: #compatible
795770
796771[api-data]: #data
0 commit comments