parser-cache
Cache and load parsers, similiar to consolidate.js engines.
Install
npm
Install withnpm i parser-cache --save
Usage
var parsers = ;
API
Parsers
options
{Object}: Default options to use.
var Parsers = ;var parsers = ;
.register
Register the given parser callback fn
as ext
. If ext
is not given, the parser fn
will be pushed into the default parser stack.
ext
{String}fn
{Function|Object}: oroptions
returns
{Object}parsers
: to enable chaining.
// Push the parser into the default stackparsers; // Or push the parser into the `foo` stackparsers;
.parse
Run a stack of async parsers for the given file
. If file
is an object with an ext
property, then ext
is used to get the parser stack. If ext
doesn't have a stack, the default noop
parser will be used.
file
{Object|String}: Either a string or an object.stack
{Array}: Optionally pass an array of functions to use as parsers.options
{Object}returns
{Object}: Normalizefile
object.
var str = fs;parsers;
Or, explicitly pass an array of parser functions as a section argument.
parsers;
.parseSync
Run a stack of sync parsers for the given file
. If file
is an object with an ext
property, then ext
is used to get the parser stack. If ext
doesn't have a stack, the default noop
parser will be used.
file
{Object|String}: Either a string or an object.stack
{Array}: Optionally pass an array of functions to use as parsers.options
{Object}returns
{Object}: Normalizefile
object.
var str = fs;parsers;
Or, explicitly pass an array of parser functions as a section argument.
parsers;
.parseStream
Run a stack of stream parsers for input files
.
stack
{Array}: Optionally pass an array of functions to use as parsers.options
{Object}returns
{Stream}: Stream pipeline used to parse files in a stream.
gulp ;
Or, explicitly pass an array of parser functions as a section argument.
gulp ;
.get
Return the parser stored by ext
. If no ext
is passed, the entire parsers is returned.
ext
{String}: The parser to get.returns
{Object}: The specified parser.
parser// => { parse[function]}
.clear
Remove the parser stack for the given ext
, or if no value is specified the entire parsers object is clear.
ext
{String}: The stack to remove.
Example:
parsersclear
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on October 14, 2014.