npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parser-cache

v0.4.6

Published

Cache and load parsers, similiar to consolidate.js engines.

Downloads

22

Readme

parser-cache NPM version

Cache and load parsers, similiar to consolidate.js engines.

Install

Install with npm

npm i parser-cache --save

Usage

var parsers = require('parser-cache');

API

Parsers

  • options {Object}: Default options to use.
var Parsers = require('parser-cache');
var parsers = new 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}: or options
  • returns {Object} parsers: to enable chaining.
// Push the parser into the default stack
parsers.register(require('parser-front-matter'));

// Or push the parser into the `foo` stack
parsers.register('foo', require('parser-front-matter'));

.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}: Normalize file object.
var str = fs.readFileSync('some-file.md', 'utf8');
parsers.parse({ext: '.md', content: str}, function (err, file) {
  console.log(file);
});

Or, explicitly pass an array of parser functions as a section argument.

parsers.parse(file, [a, b, c], function (err, file) {
  console.log(file);
});

.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}: Normalize file object.
var str = fs.readFileSync('some-file.md', 'utf8');
parsers.parseSync({ext: '.md', content: str});

Or, explicitly pass an array of parser functions as a section argument.

parsers.parseSync(file, [a, b, c]);

.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.src('path/to/files/*.md')
  .pipe(parsers.parseStream({ext: '.md'}))
  .pipe(gulp.dest('dist'));

Or, explicitly pass an array of parser functions as a section argument.

gulp.src('path/to/files/*.md')
  .pipe(parsers.parseStream([a, b, c], {ext: '.md'}))
  .pipe(gulp.dest('dist'));

.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.get('md')
// => { 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:

parsers.clear()

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.