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

composable-tags

v1.0.2

Published

ES2015 template tags that compose

Readme

composable-tags

Small and dependency free library for ES2015 template string tags that compose well.

  npm install composable-tags

Usage

function t(TerminatingTag, ...Tags)

Call the t function with one terminating tag and any number of composable tags. They are applied from right to left.

import {t, stripCommonIndent, id, render} from 'composable-tags'

const name = 'you';
const tag = t(render, stripCommonIndent({newLine: '\n'}), id);
console.log(tag`
    Hallo ${name},

    I just wanted to tell you that
    1+1 = ${1+1}.

    Sincerely yours.
`);
/* prints:
Hallo you,

I just wanted to tell you that
1+1 = 2.

Sincerely yours.
*/

Composable Tags

Combine these as you want. Or create your own: they all are a function of the form {parts: [String], values: [Any]} -> {parts: [String], values: [Any]}

id

const id // Tag

Does nothing. I.e. this identity holds:

t(...someTagsLeft, id, ...someTagsRight) == t(...someTagsLeft,...someTagsRight)

stripCommonIndent

function stripCommonIndent({newLine = '\n', indentation = " "} = {}) // Tag

Strips common ident on all lines except the first.

stripEmptyLines

function stripEmptyLines({ newLine = "\n", leading = true, within = false, trailing = true, trailingNewLine = true} = {}) // Tag

Strips empty lines. If trailingNewLine is true one trailing newline at the end will be enforced. If within is true all empty lines between first and last non-empty line will be removed as well.

Terminating Tags

You can use one terminating tag at the end of the list of tags. You must not use any other tags left of a terminating one - otherweise things will explode.

render

const render // TerminatingTag

Terminates the sequence of tags and renders it as string

t(render)`abc` === `abc`

box

function box(foreignTag) // TerminatingTag

Use any tag from other libraies as the terminating tag.

Useful Examples

Source Code Syntax Highligthing

You want to leverage syntax highlighting for your, e.g. GraphQL, template string in your editor without changing the semantics? Just do the following:

import {t, render} from 'composable-tags'

const gql = t(render) // equivalent to not use any tags.
// if you want to strip indentaion as well just use
// const gql = t(render, stripCommonIndent()) instead

const query = gql`
    query userWithSyntaxHighlighting($email: String!) {
        allUser(email: $email) {
            id
        }
    }
`

Contributions

Your more than welcome to add your own helpful tags. After all what is a composable tag system worth if it doesn't contain the tags you want to compose?