0.1.0 • Published 9 years ago
lodash-invariants v0.1.0
lodash-invariants
Invariants for lodash.is* methods
Made with ❤ at @outlandish
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.
0.1.0
9 years ago