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 🙏

© 2026 – Pkg Stats / Ryan Hefner

square-parameters

v1.0.3

Published

Embed frontmatter-like config at the beginning of a string

Readme

square-parameters Build Status npm version Dependency Status

Embed frontmatter-like config at the beginning of a string

Introduction

For my gulp-markdown-equations module, I need a very quick and easy way to embed config at the beginning of an inline string. It needs to be kinda like a query string, not as verbose or flexible as JSON, sorta like frontmatter... but not quite any of those. Specifically it needs to satisfy these criteria:

  1. Requires no encoding
  2. Requires minimal escaping
  3. Is easy to separate from content
  4. Is very concise
  5. Takes like three seconds to comprehend everything
  6. Is not easily confused with any well-known format so people don't make incorrect assumptions about which syntax it does/doesn't support and so I'm not on the hook for supporting a specific format.

And so we get square-parameters. Perhaps not worthy of its own module, but I felt weird to hard-code it into another. Let me know if you have a better idea.

Examples

var sp = require('square-parameters')

// Pretty straightforward:
sp("[foo=bar][baz=bop]sample string")
  // => { content: "sample string", params: {foo: "bar", baz: "bop"} }

// Whitespace is fine
sp("[a parameter=some value]sample string")
  // => { content: "sample string", params: {"a parameter": "some value"} }

// Leading whitespace not allowed:
sp(" [foo=bar]sample string")
  // => { content: " [foo=bar]sample string", params: {} }

API

require('square-parameters')( string )

Extracts config from a string and returns two parts: content and params. content is a string with the parameters chopped off, and params is an object containing key/value pairs.

Returns: Content and parameters, i.e. {content: "...", params: {...}}

Credits

(c) 2015 Ricky Reusser. MIT License