{"name":"@octetstream/invariant","description":"Declarative errors throwing for Node.js","version":"1.0.2","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":">=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":"cc02811e6e546ff2d67e78361d623884c1dd7713","homepage":"https://github.com/octet-stream/invariant#readme","_id":"@octetstream/invariant@1.0.2","_shasum":"d45ed5f0d532cf46cee2fd10d520584678b15fe1","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.1","_npmUser":{"name":"octetstream","email":"nick.kruchinin@gmail.com"},"dist":{"shasum":"d45ed5f0d532cf46cee2fd10d520584678b15fe1","tarball":"http://registry-npm.ywwl.com/@octetstream/invariant/download/@octetstream/invariant-1.0.2.tgz","integrity":"sha512-YPHdZgXMHMttlffBLIqUVKMf/FWv3+7p4g3Ukj5D3r/zbZ4eyBDA0mxOP/BqCBVTOFAuL6rjKKwdTS/RupO0lA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBwRDBspnRBo3AIMkXcCqlrTXEnbfUvKCEF62/IoSLnMAiEAwurBMg3NmnDqoEIOajP2TAAxslfUCgq9AqFYJAHMeNU="}],"size":40646,"noattachment":false,"key":"/@octetstream/invariant/-/@octetstream/invariant-1.0.2.tgz"},"maintainers":[{"name":"octetstream","email":"nick.kruchinin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/invariant-1.0.2.tgz_1503596744325_0.4757091295905411"},"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":1503596746412,"_cnpm_publish_time":1503596746412,"dist-tags":{"latest":"1.2.0"}}