{"name":"@octetstream/invariant","description":"Declarative errors throwing for Node.js","version":"1.0.0","main":"invariant.js","author":{"name":"Nick K."},"license":"MIT","keywords":["invariant","test","errors"],"repository":{"type":"git","url":"git+https://github.com/octet-stream/invariant.git"},"bugs":{"url":"https://github.com/octet-stream/invariant/issues"},"scripts":{"lint":"eslint test.js invariant.js","test":"ava test.js","codecov":"codecov","coverage":"nyc yarn test","report":"yarn coverage && node_modules/.bin/nyc report --reporter=html yarn test","report:ci":"nyc report --reporter=lcov yarn test","ci":"yarn coverage && yarn report:ci && yarn codecov","precommit":"yarn lint","prepush":"yarn report"},"engines":{"node":">=7.6"},"dependencies":{"lodash.isfunction":"3.0.8","lodash.isstring":"4.0.1","sprintf-js":"1.1.1"},"devDependencies":{"@octetstream/eslint-config":"1.0.1","ava":"0.21.0","codecov":"2.2.0","eslint":"3.19.x","husky":"0.14.3","nyc":"11.0.3"},"gitHead":"2d3fe30a084e4d84840f13cc1f7099322d88561d","homepage":"https://github.com/octet-stream/invariant#readme","_id":"@octetstream/invariant@1.0.0","_npmVersion":"5.3.0","_nodeVersion":"8.2.1","_npmUser":{"name":"octetstream","email":"nick.kruchinin@gmail.com"},"dist":{"integrity":"sha512-kaSxzqq9NiYTGs+sbiQ0/cn+CdZz3DO7kkKSk+gQPOFpEqM5M2JK6jkX33FW0/pbcSUR3H8VVA6KogKUlLz7Fg==","shasum":"1bcc4785331f66d4bf11666d8d4e036e1780aa8d","tarball":"http://registry-npm.ywwl.com/@octetstream/invariant/download/@octetstream/invariant-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCQH3KUN8Oegxn3tDbq4Xd4eR4P8nwwcDds/TkFUpZuAAIgOaG5EwLoFiF/XxY9YXDcgLMjY3GALlkctlKMjmXapsQ="}],"size":40608,"noattachment":false,"key":"/@octetstream/invariant/-/@octetstream/invariant-1.0.0.tgz"},"maintainers":[{"name":"octetstream","email":"nick.kruchinin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/invariant-1.0.0.tgz_1501279884626_0.3504832196049392"},"directories":{},"readme":"# @octetstream/invariant\n\nDeclarative errors throwing for Node.js\n\n[![dependencies Status](https://david-dm.org/octet-stream/invariant/status.svg)](https://david-dm.org/octet-stream/invariant)\n[![devDependencies Status](https://david-dm.org/octet-stream/invariant/dev-status.svg)](https://david-dm.org/octet-stream/invariant?type=dev)\n[![Build Status](https://travis-ci.org/octet-stream/invariant.svg?branch=master)](https://travis-ci.org/octet-stream/invariant)\n[![Code Coverage](https://codecov.io/github/octet-stream/invariant/coverage.svg?branch=master)](https://codecov.io/github/octet-stream/invariant?branch=master)\n\n## API\n\n### `invariant(predicate, error) -> {void}`\n  - **boolean** predicate – a result of some condition. Error will threw if predicate is `true`.\n  - **object** error – some error object\n\n### `invatiant(predicate, message[, ...format]) -> {void}`\n\n  - **boolean** predicate – a result of some condition. Error will threw if predicate is `true`.\n  - **string** message – an error message\n  - **any** format – see more about the format in a [sprintf-js documentation](https://github.com/alexei/sprintf.js)\n\n### `invariant(predicate, Error, message[, ...format]) -> {void}`\n  - **boolean** predicate – a result of some condition. Error will threw if predicate is `true`.\n  - **Function** Error – custom error class that will be used as an error constructor\n  - **string** message – an error message\n  - **any** format – see more about the format in a [sprintf-js documentation](https://github.com/alexei/sprintf.js)\n\n### `invariant.reject(predicate, message[, ...format]) -> {Promise<void>}`\n\n  Do the same things as `invariant`, but returns Promise that will be rejected when predicate is true.\n  This function have same API as `invariant`.\n\n## Example\n\n```js\n  import invariant from \"@octetstream/invariant\"\n\n  // some of your code...\n\n  // Will threw a TypeError if \"value\" is not a string\n  invariant(typeof value !== \"string\", TypeError, \"The value should be a string, but given type is: %s\", typeof value)\n\n  invariant(typeof value !== \"string\", \"The value should be a string, but given type is: %s\", typeof value)\n\n  invariant(typeof value !== \"string\", new TypeError(`The value should be a string, but given type is: ${typeof value}`))\n\n  // Will return rejected Promise instead of throw error synchronously\n  invariant.reject(typeof value !== \"string\", TypeError, \"The value should be a string, but given type is: %s\", typeof value)\n    .catch(err => console.error(err))\n```\n","publish_time":1501279885991,"_cnpm_publish_time":1501279885991,"dist-tags":{"latest":"1.2.0"}}