- vuegister
The require hook for load SFC (single-file component or *.vue) files.
- Location
Class for calculation of the line numbers.
The require hook for load SFC (single-file component or *.vue) files.
- vuegister
- extract(buf, tags) ⇒
array
⏏ - load(buf, [file], [cfg]) ⇒
string
⏏ - register([options]) ⇒
boolean
⏏ - unregister() ⇒
array
⏏
- extract(buf, tags) ⇒
Extracts SCF sections (inner text and all tag attributes) specified by tags argument, low level API.
Parameters
- buf:
string
- Content of the SFC file. - tags:
array
- List of sections to be extracted.
Returns: array
- Returns extracted sections, each section is an object of
the following format:
{
tag: string, // name of the tag
text: string, // inner text, content of the tag
attrs: object, // key-value pairs, attributes of the tag
offset: number, // line number where the tag begins in the SCF minus
// one or zero for external file
}
Parses SFC, high level API.
Parameters
- buf:
string
- Content of the SFC file. - [file]:
string
- Full path to the SFC. - [cfg]:
object
- Options, an object of the following format:
{
maps: boolean, // false, provide source map
lang: object, // {}, default language for tag without lang attribute,
// for example:
// {
// {script: 'js'}
// }
plugins: object, // {}, user configuration for the plugins, for example:
// {
// babel: {
// babelrc: true,
// },
// }
}
Returns: string
- Returns ready-to-use JavaScript with injected template.
Kind: Exported function
Setups hook on require *.vue extension.
Parameters
- [options]:
object
- Available options are:
{
maps: boolean, // false, provide source map
lang: object, // {}, default language for tag without lang attribute,
// for example:
// {
// {script: 'js'}
// }
plugins: object, // {}, user configuration for the plugins, for example:
// {
// babel: {
// babelrc: true,
// },
// }
}
Returns: boolean
- Returns true on success.
Kind: Exported function
Removes requre hook.
Returns: array
- Returns list of unloaded modules.
Kind: Exported function
Class for calculation of the line numbers.
Kind: global class
- Location
- new Location(buf)
- .getLine(index) ⇒
number
Create class instance.
Parameters
- buf:
string
- Raw text.
Example
let data = fs.readFileSync(file, 'utf8');
let loc = new Location(data);
Get line number.
Parameters
- index:
number
- the 0-based index.
Returns: number
- Returns 0-based line number for given index.
Kind: instance method of Location