Skip to content

therockstorm/utils

Repository files navigation

utils

npm Build Status license

Tiny utility functions

Installing

npm install @therockstorm/utils --save

API Reference

log

Calls console.log

utils.log('My message')

debug

Calls console.debug with [debug] prefix

utils.debug('My message')

info

Calls console.info with [info] prefix

utils.info('My message')

warn

Calls console.warn with [warn] prefix

utils.warn('My message')

error

Calls console.error with [error] prefix

utils.error('My message')

envVar

Returns argument from process.env or throws if undefined

const value = utils.envVar('MY_KEY')

required

Returns first argument or throws using second argument as error message if undefined

const value = utils.required(process.argv[1], 'myOption')

thrw

Throws an exception, can be used in locations throw cannot

myVal ? doSomething() : thrw('error')

Developing

# Install dependencies
nvm install && nvm use && npm install

# Run tests
npm test

License

MIT © Rocky Warren