unified
Advanced tools
Comparing version 8.3.1 to 8.3.2
{ | ||
"name": "unified", | ||
"version": "8.3.1", | ||
"version": "8.3.2", | ||
"description": "Interface for processing text using syntax trees", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -81,3 +81,3 @@ // TypeScript Version: 3.4 | ||
*/ | ||
Parser: ParserFunction | typeof Parser | ||
Parser: ParserConstructor | ParserFunction | ||
@@ -102,3 +102,3 @@ /** | ||
*/ | ||
Compiler: CompilerFunction | typeof Compiler | ||
Compiler: CompilerConstructor | CompilerFunction | ||
@@ -323,16 +323,33 @@ /** | ||
*/ | ||
class Parser { | ||
interface Parser { | ||
/** | ||
* Transform file contents into an AST | ||
* | ||
* @param file File to transform into AST node(s) | ||
* @returns Parsed AST node/tree | ||
*/ | ||
parse(file: VFileCompatible): Node | ||
parse(): Node | ||
} | ||
/** | ||
* A constructor function (a function with keys in its `prototype`) or class that implements a | ||
* `parse` method. | ||
*/ | ||
interface ParserConstructor { | ||
/** | ||
* Creates a Parser | ||
* | ||
* @param text Text to transform into AST node(s) | ||
* @param file File associated with text | ||
*/ | ||
new (text: string, file: VFile): Parser | ||
} | ||
/** | ||
* Transform file contents into an AST | ||
* @param file File to transform into AST node(s) | ||
* | ||
* @param text Text to transform into AST node(s) | ||
* @param file File associated with text | ||
* @returns Parsed AST node/tree | ||
*/ | ||
type ParserFunction = (file: VFileCompatible) => Node | ||
type ParserFunction = (text: string, file: VFile) => Node | ||
@@ -342,11 +359,23 @@ /** | ||
*/ | ||
class Compiler { | ||
interface Compiler { | ||
/** | ||
* Transform an AST node/tree into text | ||
* | ||
* @param node Node to be stringified | ||
* @returns Compiled text | ||
*/ | ||
compile(): string | ||
} | ||
/** | ||
* A constructor function (a function with keys in its `prototype`) or class that implements a | ||
* `compile` method. | ||
*/ | ||
interface CompilerConstructor { | ||
/** | ||
* Creates a Compiler | ||
* | ||
* @param node Node/tree to be stringified | ||
* @param file File associated with node | ||
* @returns transformed text | ||
*/ | ||
compile(node: Node, file?: VFileCompatible): string | ||
new (node: Node, file: VFile): Compiler | ||
} | ||
@@ -357,7 +386,7 @@ | ||
* | ||
* @param node Node to be stringified | ||
* @param node Node/tree to be stringified | ||
* @param file File associated with node | ||
* @returns transformed text | ||
* @returns Compiled text | ||
*/ | ||
type CompilerFunction = (node: Node, file?: VFileCompatible) => string | ||
type CompilerFunction = (node: Node, file: VFile) => string | ||
@@ -364,0 +393,0 @@ /** |
65299
749