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

composerx

v0.0.16

Published

[![codecov](https://codecov.io/gh/fedeghe/composerx/graph/badge.svg?token=WWXU4IU4WT)](https://codecov.io/gh/fedeghe/composerx)

Downloads

239

Readme

codecov

GitHub top language Static Badge npm package minimized gzipped size

track

composerx 0.0.16

Never write the same regexp again, ...ok, ...almost!

In less than 1KB composerx aims to help to:

  1. define a specific RegExp (once)
  2. reuse defined ones to define another RegExp
  3. go back to 1 or 2
const crx = require('composerx');

crx.add('1-31', /^(([1-9])|([1-2]\d)|(3[01]))$/);
crx.add('3letters',  /^([a-z]{3})$/i);
crx.compose(
    'myComposedRx',
    'cx(1-31)|cx(3letters)',
);


const res1 = crx.match('myComposedRx', '3'),
    res2 = crx.match('myComposedRx', 'abf');

console.log(crx.get('myComposedRx').source)


console.log({
    res1,
    // ['3', '3', '3', '3', undefined, ...]
    
    res2 
    // ['abf', undefined, undefined, undefined, undefined, 'abf', ....]
    
    myComposedRx: crx.get('myComposedRx').source
    // (^(([1-9])|([1-2]\d)|(3[01]))$|^([a-z]{3})$)
});

API

All methods are static, thus no need for instances.
All chainable methods show a 🔗

composerx.add(String name, RegExp rx)

Adds a named element to the set of the reusable ones.

  • throws
    when name is not a truthy string
    when rx is not a RegExp
  • overrides
    in case an element with that name exists already

returns: 🔗


composerx.get(String name)

Retrives an element when existing, null otherwise.

  • throws
    when name is not a truthy string.

returns: the named element if it exists, undefined otherwise


composerx.remove(String name)

Removes an existing element

  • throws
    when name is not a string or is an empty string.
  • no effect
    when the element is not found.

returns: 🔗


composerx.compose(String name, String tpl)

Creates a new the elements named name (or overrides an existing one) using the template passed to create the new RegExp using previously added elements.
To use an existing element add for it a placeholder inside the tpl parameter (see the example above).
The placeholder for element named myRx1 is cx(myRx1).

  • throws
    when name or tpl is not a string or is empty string.

returns: 🔗


composerx.match(String name, String search, {definedOnly = false})

Run a match of the search against the elements named name

  • throws
    when name is not a string or is empty string.
    when search is not string.

  • options.definedOnly: when passed as true all undefined will be filtered out from the resulting array

returns: the rx match output or undefined when the element does not exists


composerx.test(String name, String search, {definedOnly = false})

Run a test of the search against the elements named name

  • throws
    when name is not a string or is empty string.
    when search is not string.

returns: Boolean


composerx.clear()

Removes all stored elements.

returns: 🔗