Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

lodash-invariants

0.1.0 • Public • Published

lodash-invariants

Invariants for lodash.is* methods

Made with ❤ at @outlandish

npm version js-standard-style

Install

import invariants from 'lodash-invariants'

Import

// ES2015
import invariants from 'lodash-invariants'
 
// CommonJS
var invariants = require('lodash-invariants')

API

invariants.is*(name, ...args)

  • name {String} Name of what is being inspected
  • ...args {*} Arguments to pass to the lodash.is* method

Throws an Invariant Exception if the lodash.is* method returns false.

Example

import invariants from 'lodash-invariants'
 
function application (options) {
  invariants.isString('options.url', options.url)
}
 
application({ url: 123 }) //=> Invariant Exception: Expecting options.url to be string, got number.

If you have your own invariants, merge lodash-invariants into them:

// ./invariants.js
import lodashInvariants from 'lodash-invariants'
 
export default Object.assign({}, {
  customInvariant: (...args) => {
    invariant(...args)
  }
}, lodashInvariants)

Contributing

All pull requests and issues welcome!

If you're not sure how, check out Kent C. Dodds' great video tutorials on egghead.io!

Author & License

lodash-invariants was created by Sam Gluck and is released under the MIT license.

install

npm i lodash-invariants

Downloadsweekly downloads

4

version

0.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability