-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
index.d.ts
62 lines (55 loc) · 1.76 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import type {Reporter} from './lib/index.js'
/**
* This is the same as `Buffer` if node types are included, `never` otherwise.
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
// @ts-ignore It’s important to preserve this ignore statement. This makes sure
// it works both with and without node types.
// eslint-disable-next-line node/prefer-global/buffer
type MaybeBuffer = any extends Buffer ? never : Buffer
/**
* Contents of the file.
* Can either be text, or a Buffer like structure.
* This does not directly use type `Buffer`, because it can also be used in a
* browser context.
* Instead this leverages `Uint8Array` which is the base type for `Buffer`,
* and a native JavaScript construct.
*/
export type Value = string | MaybeBuffer
/**
* This map registers the type of the `data` key of a `VFile`.
*
* This type can be augmented to register custom `data` types.
*
* @example
* declare module 'vfile' {
* interface DataMap {
* // `file.data.name` is typed as `string`
* name: string
* }
* }
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DataMap {}
/**
* Place to store custom information.
*
* Known attributes can be added to @see {@link DataMap}
*/
export type Data = Record<string, unknown> & Partial<DataMap>
// Deprecated names (w/ prefix):
export type {Data as VFileData, DataMap as VFileDataMap, Value as VFileValue}
export {VFile} from './lib/index.js'
export type {
BufferEncoding,
Map,
Compatible,
Options,
Reporter,
ReporterSettings,
// Deprecated names (w/ prefix):
Compatible as VFileCompatible,
Options as VFileOptions,
Reporter as VFileReporter,
ReporterSettings as VFileReporterSettings
} from './lib/index.js'