{"name":"@octetstream/invariant","description":"Declarative errors throwing for Node.js","version":"1.1.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"},"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":">=6"},"dependencies":{"sprintf-js":"1.1.1"},"devDependencies":{"@octetstream/eslint-config":"2.0.2","ava":"0.22.0","codecov":"2.3.0","eslint":"4.7.1","husky":"0.14.3","nyc":"11.2.1"},"gitHead":"d5b7b913ff8e314b71ecbbfc6192841036cc4ba9","bugs":{"url":"https://github.com/octet-stream/invariant/issues"},"homepage":"https://github.com/octet-stream/invariant#readme","_id":"@octetstream/invariant@1.1.0","_npmVersion":"5.4.2","_nodeVersion":"8.5.0","_npmUser":{"name":"octetstream","email":"nick.kruchinin@gmail.com"},"dist":{"integrity":"sha512-0f1weVwdDvsBm0Pu0eliSI1ZZmGgDsek0f2mJAlwOWdqVQ9+/uHEV0JtS1QujLd60NNmNv2sTX1VhNt94CsNDA==","shasum":"652d73b6cb9a5f0cc6acb758843c4203d3104e84","tarball":"http://registry-npm.ywwl.com/@octetstream/invariant/download/@octetstream/invariant-1.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCakWL2IxA6jGayBNE/LbJW3YQoNZ4IVNlRIuMJZn/WeQIgZA+K4f/O8DZVWe5/Sd0hWRYN9THBAHdIRCjfKpINnBQ="}],"size":38403,"noattachment":false,"key":"/@octetstream/invariant/-/@octetstream/invariant-1.1.0.tgz"},"maintainers":[{"name":"octetstream","email":"nick.kruchinin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/invariant-1.1.0.tgz_1506274012103_0.5275045197922736"},"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":1506274013124,"_cnpm_publish_time":1506274013124,"dist-tags":{"latest":"1.2.0"}}