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

tvr

v2.4.13

Published

Terminal Value Resolver - power string interpolation

Readme

Terminal Value Resolver - tvr

Your #1 choice for string interpolation.

A powerful tool to have at the core of any HTML template rendering engine, or when you just want to spit out a message string without having to do concatenation. Dig deep - the surface-level simplicity may belie the underlying power of this module.

Documentation coming soon

Initialization

NodeJS:

var tvr = require('tvr')(opt);
/*
opt = optional parameters
	log: Console logger object
	env: Shared public variables object
	NS: Namespace reference to simple-guts based namespace
*/

Examples:

var guts = require('simple-guts')();
var tvr = require('tvr')({NS: guts});
...
console.log(tvr.$s('Message: ${msg}', {msg: 'Hello world!'}));

Terminal Value Resolver

For convenience and reduced typing, it is suggested to define (local or global) references to a few of the primary methods:

var tvr = require('tvr');
$r = tvr.$r;
$v = tvr.$v;
$s = tvr.$s;
$o = tvr.$o;

Powerful expression evaluator for computing dynamic values. $r – Resolves raw value $v – Resolves variable expression to terminal value $s – Resolves expression to string value

$r(string, context) - Resolve raw value

var person = {
    fname: 'John',
    lname: 'Smith',
    age: 27,
    married: false,
    hobbies: ['flying', 'scuba']
};
var name = $r('fname', person); // 'John'
var age = $r('age', person); // 27
var married = $r('married', person); // false
var hobbies = $r('hobbies', person); // ['flying', 'scuba']

$v(val, context) - Resolves variable expression to terminal value

var person = {
    fname: 'John',
    lname: 'Smith',
    age: 27,
    fullname: '${fname} ${lname}',
    capsname: function() {
        return this.fname.toUpperCase();
    },
    mixname: '${capsname} ${lname}',
    getname: function() { return this.fullname; }
};
var name = $v('${fname}', person);     // 'John'
name = $v('${fullname}', person);      // 'John Smith'
name = $v('${capsname}', person);      // 'JOHN'
name = $v('${mixname}', person);       // 'JOHN Smith'
name = $v('Name: ${getname}', person); // 'Name: John Smith'
name = $v('Hey!', person);             // 'Hey!'
var age = $v('Age: ${age}', person);   // 'Age: 27'
age = $v('${age}', person);            // 27

TODO Show Boolean, number, null, undefined, NaN, object

$s(val, context) - Resolves variable expression to string value

var age = $s('${age}', person); // '27'
var married = $s('${married}', person); // 'false'
var hobbies = $s('${hobbies}', person); // 'flying,scuba'

TODO Show Boolean, number, null, undefined, NaN, object

TODO Statics:

|Static|Description| |:--|:--| |{NS}*|Reference to top-level namespace ({NS} will be whatever is defined in $env.namespace, or "NS" by default - see simple-guts package)| |$env|Reference to global environment block| |$not(val)|Inverts a truthy/falsey/Boolean value| |$eq(val1, val2)|Compares two values for equality (==)| |$neq(val1, val2)|Compares two values for inequality (!=)| |$and(val...)|Tests all parameters to determine if all are truthy (implicit Boolean conversion)| |$or(val...)|Tests all parameters to determine if at least one is truthy (implicit Boolean conversion)| |$xor(val...)|Tests all parameters to see if not all are the same| |$nand(val...)|Tests all parameters to determine if at lease one is falsey (implicit Boolean conversion)| |$nor(val...)|Tests all parameters to determine if all are falsey (implicit Boolean conversion)| |$bit(val, num)|Checks a specified bit in a value to determine if that bit is set (num = bit number)| |$bits(val, mask)|Selects bits based on specified bit mask to determine if any are set (returns actual bits for truthy/falsey check)| |$nobit(val, num)|Checks a specified bit in a value to determine if that bit is clear (not set)| |$nobits(val, mask)|Selects bits based on specified bit mask to determine if all are clear (not set)| |$bool(val)|Resolve truthy/falsey value to Boolean| |$plural(label, n, suffix)|Returns the plural version of a label (English assumed) if n != 1 by appending suffix (if "ies", it will replace "y" if found at the end of label)| |$fixed(num, decimals)|Returns a numeric value as a string, rounded to the nearest specified decimal places|

Configuration

Configuration properties are picked up from $env.

  • $env.fixValues - DEPRECATED - Akin to noTerminal in old code
  • $env.noTerminal - If true, values like "true", "false" and numeric strings are not converted to their respective data types (they remain as strings). So $v('${x}', {x: 'false'}) would be 'false' not false.

Resolver configuration can be changed, programmatically, via:

  • Kjs.resolver.cfg.fixValues - See above
  • Kjs.resolver.cfg.noTerminal - See above
  • Kjs.resolver.cfg.deadTag - Key value to match to remove a property in a call to derive().