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

@lang-tag/presets

v0.0.3

Published

Optional, ready-made presets and helpers for [`lang-tag`](https://github.com/TheTonsOfCode/lang-tag).

Downloads

609

Readme

@lang-tag/presets

Optional, ready-made presets and helpers for lang-tag.

lang-tag stays intentionally minimal. This package bundles common add-ons so you don't have to re-implement them in every project.

Install

npm install @lang-tag/presets

lang-tag is a peer dependency — install it alongside:

npm install lang-tag

Imports

Each preset is imported from its own path:

import { withDynamicCaller } from '@lang-tag/presets/dynamic-caller';

Presets

dynamic-caller

Adds a dynamic caller property (named $ by default) to a callable translations object, so a translation can be invoked by a runtime key instead of statically.

import { withDynamicCaller } from '@lang-tag/presets/dynamic-caller';

const t = withDynamicCaller(base.server());

t.$('greeting', { name: 'Paul' }); // invoke by key + forward params
t.$('unknown'); // -> "#Missing:unknown#"

Options

| Option | Type | Default | Description | | ------------ | -------------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------- | | callerName | string | '$' | Name of the injected caller property. | | recursive | boolean | false | Also add the caller to every nested translations object. | | onMissing | (path: string) => string | #Missing:…# | Called when a key can't be resolved. With recursive, path is the full dotted path. | | typedKeys | boolean | true | Type the caller's key argument to the object's translation keys (autocomplete + rejects unknown keys). Pass false for open string keys. Type-only, no runtime effect. |

const t = withDynamicCaller(base.server(), {
    callerName: 'call',
    recursive: true,
    onMissing: (path) => `[[${path}]]`,
});

t.call('greeting');
t.user.call('name'); // caller is available on nested objects too

Typed keys

By default, the caller's key is narrowed to the actual translation keys, so the editor autocompletes them and rejects unknown keys at compile time:

const t = withDynamicCaller(base.server());

t.$('greeting'); // ok
t.$('nope'); // compile-time error

Pass typedKeys: false when you need an open string key (e.g. fully dynamic runtime paths):

const t = withDynamicCaller(base.server(), { typedKeys: false });
t.$('any-runtime-key'); // ok

react/placeholders

Replaces {{ name }} placeholders with values that may be React nodes. When a placeholder resolves to a React element the result is a React fragment tree, otherwise a plain string is returned. Wire it into a tag's transform:

import { processPlaceholders } from '@lang-tag/presets/react/placeholders';

createCallableTranslations(translations, config, {
    transform: ({ value, params }) => processPlaceholders(value, params),
});

Prefer a different placeholder syntax? Pass a custom pattern (the placeholder name must be the first capture group; the global flag is added if missing):

// `${ name }` instead of `{{ name }}`
processPlaceholders(value, params, { pattern: /\$\{(.*?)\}/g });

react is an optional peer dependency (>=18) — install it only if you use this module:

npm install react

License

MIT