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-template

v1.6.0

Published

a parser for texts by a template

Downloads

4

Readme

Parser

"Parser" is a tool designed for extracting data from plain text files.

Usage

Let's say, we have some template filled with values:

Hello, mr. Doe. How are you?

The only changable part of this template is a Name and we need to parse it. We may describe this template:

Hello, mr. <><name>. How are you?

The rest is easy:

const PARSER = require ('parser-template');
const myParser = new PARSER ('Hello, mr. <><name>. How are you?');
const data = myParser.parse (inputString)[0];
// data = {name: 'Doe'}

.

Advanced usage

Parser can process an array of templates without additional params:

Hello, mr. Doe. How are you?
Hello, mr. John. How are you?
Hello, mr. Bill. How are you?
//...
const myParser = new PARSER ('Hello, mr. <><name>. How are you?');
const data = myParser.parse (inputString);
// data = [{name: 'Doe'}, {name: 'John'}, {name: 'Bill'}]

A template may contain several multi-line fields. They are marked by symbol 'm' in the opening part of a tag:

Hello, <><name>.
This is that I think about you:
<m><text>

It's also possible to insert your data into a template string using myParser.stringify (dataObject).

Additional functions

Parser is shipped with several handy functions:

  1. removeDuplicates (arr)
  2. prettifyList (string)
  3. getRegexCaptures (string, regex, callback)
  4. stringifyVal (val)
  5. filterObject (dataObject)

An info about them will be written in future.