Wondering what’s next for npm?Check out our public roadmap! »

@bemoje/assert-args

1.0.2 • Public • Published

@bemoje/assert-args

Assert that the passed arguments are defined.

Version

NPM version

Travis CI

dependencies

Dependencies

dependencies

Stats

NPM downloads Forks

Donate

Buy Me A Beer donate button PayPal donate button

Installation

npm install @bemoje/assert-args
npm install --save @bemoje/assert-args
npm install --save-dev @bemoje/assert-args

Usage

 
import assertArgs from '@bemoje/assert-args'
 
/**
 * Adds a and b and throws Error if any parameters are missing
 */
function add(a, b) {
  assertArgs(a, b)
  return a + b
}
 
/**
 * Calls the callback and returns true if the callback throws an error and false otherwise.
 */
function didItThrow(callback) {
  try {
    callback()
    return false
  } catch (e) {
    return true
  }
}
 
didItThrow(() => add(1, 4))
//=> false
 
didItThrow(() => add(1))
//=> true
 

Tests

Uses Jest to test module functionality. Run tests to get coverage details.

npm run test

API

Table of Contents

assertArgs

Assert that the passed arguments are defined.

Parameters
  • args ...any arguments array

  • Throws Error If any passed argument is undefined.

Returns void

Install

npm i @bemoje/assert-args

DownloadsWeekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

7.91 kB

Total Files

5

Last publish

Collaborators

  • avatar