better-template-strings
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

better-template-strings

A lightweight template string util to make working with dynamic and nullish data a breeze.

Usage

Tired of seeing undefined in unguarded strings?

// Hello undefined!
`Hello ${data?.maybeNullish}!`;
// We have to guard for every argument
data?.maybeNullish ? `Hello ${data?.maybeNullish}!` : '';

The simple solution

import { f } from 'better-template-strings';

// Returns "" if any argument is nullish
f`Hello ${data?.maybeNullish}!`;

// Returns "Some Error Occured"
f('Some Error Occured')`Hello ${data?.maybeNullish}!`;

Package Sidebar

Install

npm i better-template-strings

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

8.24 kB

Total Files

27

Last publish

Collaborators

  • steve.winter