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

@davidcal/ptl

v1.1.0

Published

A simple templating library for generating plain-text legal documents with first-class support for user-supplied value substitution.

Readme

Ptl (Plain Text Legal)

Latest version: v1.1.0

Install

npm install @davidcal/ptl
pnpm add @davidcal/ptl
yarn add @davidcal/ptl

Overview

Ptl is a simple templating library for generating legal documents (like contracts, terms of service, and so on), with first-class support for substituting user-supplied values.

It concerns itself only with plaintext (UTF-8) templates, which is absolutely acceptable for the vast majority of legal documents.

Reliability and consistency is considered a greater concern than stylishness.

It's recommended to render the final Ptl output as monospace in a PDF/HTML document or similar.

Usage

import { ptl } from "@davidcal/ptl";

const output = ptl.fillTemplate({
	template: `
This Agreement is entered into on $$AGREEMENT_DATE$$ between:

1. SELLER: $$SELLER_NAME::L2 r60 i3 Fh$$, $$SELLER_ADDRESS::L4 r60 i3 Fh$$ ("the Seller")
2. BUYER:  $$BUYER_NAME::L2 r60 i3 Fh$$, $$BUYER_ADDRESS::L4 r60 i3 Fh$$ ("the Buyer")

Each individually a "Party" and collectively 
"the Parties."
`,
	replacements: {
		AGREEMENT_DATE: "23 July 2026",
		SELLER_NAME: "John Doe",
		SELLER_ADDRESS: "123 Main St,\nTownville.",
		BUYER_NAME: "Jane Dumpling",
		BUYER_ADDRESS: "456 Elm St,\nViltownne.",
	},
});

Options

Token substitution syntax: $$TOKEN_NAME::<options>$$

The options are space-separated:

| Option | Example | Description | |--------|---------|-------------| | l<n> | l2 | Minimum number of lines to output (padded with blank lines or filler). Defaults to 1. | | L<n> | L4 | Maximum number of lines allowed. Overflows throw an error. Defaults to l value when no wrapping, or unlimited when r is set. | | r<n> | r60 | Wrap the value so no output line exceeds n characters in total width (including any leading text before the token). | | w<n> | w60 | Width used for filler padding. Defaults to the r value if set, otherwise 40. Note that filler will break limits set by r. | | i<n> | i3 | Indent override for continuation lines (in spaces). Defaults to the column position of the token in the template. | | f<c> | f_ | Filler character to pad each line out to w characters. If omitted, lines are not padded. | | F<flags> | Fw | One or more single-character flags (see below). Multiple flags may be combined in any order (e.g. Fwh). |

Flags (used with F<flags>):

| Flag | Description | |------|-------------| | h | Hyphenated wrapping. Each wrapped line is shortened by one character and a - is appended. If the last character of the line is already -, the line is wrapped at the normal width without adding an extra hyphen. | | w | Todo: Word-aware wrapping (not yet implemented). |

Inline tokens ($$TOKEN_NAME$$, no options) substitute the value directly in-place with no wrapping or padding.

Escape sequences ($$\uXXXX$$ or $$\UXXXXXXXX$$) insert a Unicode character by code point.

Future plans

  • Currently you must prevalidate lengths for user input and make sure the template is conservative. In future I would like to have a way to generate individual validation functions from a template, depending on how tokens are used.
  • Currently only character-wrapping is supported. I would like to add a word-wrapping option that can be enabled via Fw flag.

Contributing

See CONTRIBUTING.md.