🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@tailored-apps/helpers

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tailored-apps/helpers

A small library providing various utility functions used in tailored apps backends (propably not very useful for anyone else)

latest
npmnpm
Version
1.1.1
Version published
Maintainers
3
Created
Source

@tailored-apps/helpers

js-standard-style

@tailored-apps/helpers contains some helper-functions and is part of the api-skeleton-2.

Installation and Updating

npm install @tailored-apps/helpers

Functions

registerExitListeners

Registers listeners that produce output on process termination

function registerExitListeners (logger, moduleName = 'module')

getDuration

Returns the difference between two Date objects in seconds - will instantiate a new Date object if no finish parameter is provided.

function getDuration (start, finish)

replaceTokens

Replaces tokens in a string with values from the provided "replacements" object

All tokens will be replaced with the values of the corresponding property in the replacements object, if such a property exists (i.e. is not undefined). Otherwise, token literals will be returned.

Returns a string with the tokens replaced.

function replaceTokens (str, replacements, tokenStart = '{', tokenEnd = '}')

Usage

replaceTokens('this {fancyProp} will be replaced, {poorMe} will not', { fancyProp: 'strange thing' })
inputvalue
strthis {fancyProp} will be replaced, {poorMe} will not
replacements{ fancyProp: 'strange thing' }
tokenStart{
tokenEnd}

returns:
"this strange thing will be replaced, {poorMe} will not"

requireNodeEnv

The simplest of utility functions - will throw an error if NODE_ENV is not set

function requireNodeEnv (errorMessage = 'NODE_ENV environment variable is not set.')

Keywords

utility

FAQs

Package last updated on 09 Jul 2018

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