Socket
Book a DemoInstallSign in
Socket

bowhead-js

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bowhead-js

Tiny string interpolation library

latest
Source
npmnpm
Version
6.0.2
Version published
Maintainers
1
Created
Source

bowhead-js

Build Status MEAN Module npm version Node.js Version

Tiny string interpolation library, written in TypeScript.

Installation

yarn add bowhead-js

Usage

import format from 'bowhead-js';

// Index-based arguments.
format('{1} {0} {1}', 1, 'haha'); // 'haha 1 haha'

// Custom functions.
format('{0|uppercase}', 'haha'); // 'HAHA'

// Plurals.
format('{0} {0|countable|fish|fishes}', '1'); // '1 fish';
format('{0} {0|countable|fish|fishes}', '2'); // '2 fishes'
format('{0} {0|countable|fish|fishes}', '0'); // '0 fishes'
// "deer" is both singular and plural.
format('{0} {0|countable|deer}', '1'); // '1 deer'
format('{0} {0|countable|deer}', '2'); // '2 deer'

Functions available

  • uppercase to uppercase
  • lowercase to lowercase
  • capitalized capitalizes first letter
  • countable handles plurals

Error handling

By default, bowhead-js mutes index-out-of-range errors being thrown and returns error messages in resulting strings, you can disable this behavior by calling muteExceptions:

import { muteExceptions } from 'bowhead-js';

format('{1} {7}', 23, 'haha'))
// Prints 'haha <7 is out of range>'

muteExceptions(false);
format('{1} {7}', 23, 'haha'))
// Error thrown.

Keywords

string interpolation

FAQs

Package last updated on 02 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.