{"name":"@cloudcmd/stub","version":"2.3.0","access":"public","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"simplest sinon.stub alternative with diff support","homepage":"http://github.com/coderaiser/cloudcmd/stub","main":"lib/stub.js","repository":{"type":"git","url":"git://github.com/cloudcmd/stub.git"},"scripts":{"test":"tape 'test/*.js'","watch:test":"nodemon -w lib -w test -x \"npm test\"","lint":"eslint lib test","coverage":"nyc npm test","report":"nyc report --reporter=text-lcov | coveralls"},"dependencies":{"chalk":"^2.4.1","jest-diff":"^23.6.0","strip-ansi":"^5.0.0"},"keywords":["sinon","stub","async","promise","calledWith","diff","tape"],"devDependencies":{"coveralls":"^3.0.0","eslint":"^5.6.0","eslint-plugin-node":"^8.0.0","mock-require":"^3.0.2","nodemon":"^1.14.12","nyc":"^13.0.1","redrun":"^7.0.2","sinon":"^7.1.1","sinon-called-with-diff":"^3.0.0","tape":"^4.8.0","try-catch":"^2.0.0","try-to-catch":"^1.1.1"},"license":"MIT","engines":{"node":">=8.3.0"},"publishConfig":{"access":"public"},"gitHead":"fc1145b186bd4c18c6c1f0579213fada610a5117","bugs":{"url":"https://github.com/cloudcmd/stub/issues"},"_id":"@cloudcmd/stub@2.3.0","_npmVersion":"6.4.1","_nodeVersion":"11.1.0","_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"dist":{"integrity":"sha512-CV/viY7YrB3mgj0vBNDrb+3qr14wLg5Y+Yj7Al73DD6Arm/VPxLP1BOcPi7df32suqTKIPp5ZjpKGVbCpbiXFA==","shasum":"f61f27db467e83d429cd55a4bcbc4c1fcea877a8","tarball":"http://registry-npm.ywwl.com/@cloudcmd/stub/download/@cloudcmd/stub-2.3.0.tgz","fileCount":6,"unpackedSize":6733,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb/oV/CRA9TVsSAnZWagAAu2EP/1Sv3+J0/O53HOhhPTPq\n7tNc7NRaeD2NECvHzkR1YWph9sULWEA6iDVB1VbsJf39u7ijzy9aFG2ijI23\n9Yj5FueoZbLYYPxJSQ0D2LrHz811NC0D/llupsTNQvs5JEauX8lRDdW89JDr\n9y0AOtKaoXiHF5dERrUI8x/RVbtQppitx5a/R4VHftuTQDwepCuQHQ4Qu8Ya\n8BwXCXv64GfTNHVc9n//T1AR9czy7r7mYbf1/g6/lDof7ABzjIrVIC4twLFX\nFH+4G+dbb4yUj7PxcyVhyeZp3H7n3HtsLbQFgg5oHH6yeOyYpFDvKayHF/db\nc/1a/h52VrftWpZf5w9gLpOzblysWbT6d4h//pxipTwocbb/VGJwV2Y7GZQF\n1PRb22DCXVoKwwCs/Xh3wQMoN+N5+bxwjQbCccPCYRO/Uqvkoyj9VWSJ0r+O\nqqFYPr6NJB8zBGLDKbLOyTm/vcX3+0OYuvUhZ61PgPcKckexWxG61Y7edVTl\npj/hEJuAGpymYLRJhscdyFZNDUp7rndJx8xLQGHYFrnlr0ipER3cKSv9d8j+\nSBUT4ECWpxqj0/OGCgJX7pGYDPtkJHUoWLWasslw+75LbtKYO/0tAIhq3rRt\nD2mtP8etJRgpWg/RGrGvtZWMxHddjt/GG+gAh1rPshp1OzyzU/wOARNTM1Sp\nHXvP\r\n=duaq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC4lRmiYFo9YPcf8+V3/B34/9FjO0B5m7QUYaTtO1w4YwIhAIjy1IZiAVnaVCCAl9XZtqtyxqOHl03+FDr9J6MWfY9T"}],"size":2811,"noattachment":false,"key":"/@cloudcmd/stub/-/@cloudcmd/stub-2.3.0.tgz"},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stub_2.3.0_1543406974873_0.7061505939603234"},"_hasShrinkwrap":false,"readme":"# Stub [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@cloudcmd/stub.svg?style=flat&longCache=true\n[BuildStatusURL]: https://github.com/coderaiser/putout/actions?query=workflow%3A%22Node+CI%22 \"Build Status\"\n[BuildStatusIMGURL]: https://github.com/coderaiser/putout/workflows/Node%20CI/badge.svg\n[NPMURL]: https://npmjs.org/package/@cloudcmd/stub \"npm\"\n[CoverageURL]: https://coveralls.io/github/cloudcmd/stub?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/cloudcmd/stub/badge.svg?branch=master&service=github\n\nSimplest [sinon.stub()](https://sinonjs.org/) alternative. With support of showing diff on `calleddWith`.\n\n## Install\n\n```\nnpm i @cloudcmd/stub\n```\n\n## API\n\n### stub([impl])\n\n- `impl` - stub implementation\n\n```js\nconst stub = require('@cloudcmd/stub');\nconst fn = stub();\n// fn contains stubbed function\n\nconst asyncFn = stub(async () => {\n    throw Error('hi');\n});\n\n// asyncFn contains stub async function\n```\n\n### stub().returns([value])\n\n```js\nconst fn = stub().returns('hello');\nfn();\n// returns\n'hello';\n```\n\n### stub().throws([error])\n\n```js\nconst fn = stub().throws(Error('hello'));\nfn();\n// throws\nError('hello');\n```\n\n### stub().rejects([error])\n\n```js\nconst fn = stub().rejects(Error('hello'));\nawait fn();\n// rejects\nError('hello');\n```\n\n### stub().resolves([values])\n\n```js\nconst fn = stub().resolves('hello');\nawait fn();\n// resolves\n'hello';\n```\n\n### stub().calledWith([args])\n\n```js\nconst fn = stub();\n\nfn('hello', 'world');\n\nfn.calledWith('hello', 'world');\n// returns true\n```\n\n### stub().calledWithNew()\n\n```js\nconst fn = stub();\n\nnew fn();\n\nfn.calledWithNew();\n// returns\ntrue;\n```\n\n### stub().calledBefore(fn)\n\n```js\nconst fn1 = stub();\nconst fn2 = stub();\n\nfn1();\nfn2();\n\nfn1.calledBefore(fn2);\n// returns\ntrue;\n```\n\n### stub().calledAfter(fn)\n\n```js\nconst fn1 = stub();\nconst fn2 = stub();\n\nfn1();\nfn2();\n\nfn2.calledAfter(fn1);\n// returns\ntrue;\n```\n\n### stub().called\n\n```js\nconst fn = stub();\n\nfn.called;\n// returns\nfalse;\n\nfn();\n\nfn.called;\n// returns\ntrue;\n```\n\n### stub().callCount\n\n```js\nconst fn = stub();\n\nfn.callCount;\n// returns\n0;\n\nfn();\n\nfn.callCount;\n// returns\n1;\n```\n\n### stub().args\n\n```js\nconst fn = stub();\n\nfn.args;\n// returns\n[];\n\nfn(1);\n\nfn.args;\n// returns\n[[1]];\n```\n\n### stub().callId\n\nEach `stub` has it `callId`, which can be used to determine order of `stub` calls:\n\n```js\nconst fn1 = stub();\nconst fn2 = stub();\n\nfn1();\nfn2();\n\nfn1.callId;\n// returns\n1;\n\nfn2.callId;\n// returns\n2;\n```\n\n### isStub(fn)\n\nCheck if provided function is stub.\n\n```js\nconst {stub, isStub} = require('@cloudcmd/stub');\nconst fn = stub();\n\nisStub(fn);\n// returns\ntrue;\n\nisStub(() => {});\n// returns\nfalse;\n```\n\n## Related\n\n- [sinon-called-with-diff](https://github.com/coderaiser/sinon-called-with-diff) - sinon `calledWith` diff\n- [try-to-tape](https://github.com/coderaiser/try-to-tape) - `try catch` for async tape tests\n- [try-catch](https://github.com/coderaiser/try-catch \"TryCatch\") - functional try-catch wrapper.\n- [try-to-catch](https://github.com/coderaiser/try-to-catch \"TryToCatch\") - functional try-catch wrapper for promises.\n\n## License\n\nMIT\n","publish_time":1543406975009,"_cnpm_publish_time":1543406975009,"dist-tags":{"latest":"5.1.0"}}