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

strip-outer-parens

v0.1.2

Published

Strip pairs of outermost brackets (custom, round, curly, angle, braces, parens, chevrons).

Downloads

17

Readme

strip-outer-parens

Strip pairs of outermost brackets (custom, round, curly, angle, braces, parens, chevrons).

The definition of "pair" is that there's an opening bracket at the start of the text, and its corresponding closing bracket at the end of the text.

Usage

var stripOuterParens = require('strip-outer-parens'),
  input = '{(<[[ ++ ]>)}',
  stripped = stripOuterParens(input, { keepOuter: 2 });
console.log(stripped);

stripOuterParens(text[, options])

These properties are supported in the options object:

  • keepOuter: non-negative interger, default: 0 How many outer layers of brackets to preserve.
  • pairs: array or string, default: '(){}[]<>' The bracket pairs catalog, as an array of bracket pairs (or string, see below). Each pair can be either an array or a string.
    • If a pair is an array, use its first element as the opeing bracket and the second element as the closing bracket.
    • If a pair is a string, use its first and second character.
    • If the catalog is given as just a string, use its even-indexed characters (first character = index 0 = even) as the opening brackets and its odd-indexed characters as closing brackets. If the catalog is of odd length, the last character will have no corresponding closing bracket, and is ignored because it's not a pair.

Caveats

  • As a result of the "pair" definition, no attempt is made to guess the meaning of inner brackets, whether they may be plain text (potentially escaped), or might correspond to the brackets at the start and end of the text. To account for that, you'll need a parser that knows which language the text is meant to contain.
  • Make sure you understand the test results.

License

ISC