{"name":"@cloudcmd/stub","version":"2.3.2","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":"madrun test","watch:test":"madrun watch:test","lint":"madrun lint","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report"},"dependencies":{"chalk":"^2.4.1","jest-diff":"^24.9.0","strip-ansi":"^5.0.0"},"keywords":["sinon","stub","async","promise","calledWith","diff","tape"],"devDependencies":{"coveralls":"^3.0.0","eslint":"^6.2.2","eslint-plugin-node":"^9.1.0","eslint-plugin-putout":"^2.0.0","madrun":"^2.5.0","mock-require":"^3.0.2","nodemon":"^1.14.12","nyc":"^14.1.1","putout":"^5.8.0","redrun":"^7.0.2","supertape":"^1.2.3","try-catch":"^2.0.0","try-to-catch":"^1.1.1"},"license":"MIT","engines":{"node":">=8.3.0"},"publishConfig":{"access":"public"},"gitHead":"d2876e712d4eafac50beb6ddcd3fffb5c624dd71","bugs":{"url":"https://github.com/cloudcmd/stub/issues"},"_id":"@cloudcmd/stub@2.3.2","_nodeVersion":"12.9.0","_npmVersion":"6.10.0","dist":{"integrity":"sha512-sccRxO5duh9iBvAPcKf691M0VlU1UVV/QvQLjSX4/lgj8Xfy4nRfgAwUOH0mxdkj+xJm4EGUrQjbx4r5gkrcnQ==","shasum":"16b1c51ef21fcdd219fe270c551531ac403b48d5","tarball":"http://registry-npm.ywwl.com/@cloudcmd/stub/download/@cloudcmd/stub-2.3.2.tgz","fileCount":6,"unpackedSize":6937,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdZCh/CRA9TVsSAnZWagAAvdMP/1T12xiOWIFZW0K+Voy7\n+ZVU/J8PWNuXx/UlamUpZvQAGdVPVBGMkAQzrikqgsgVk+DcMexRDQ5i1M5K\nzEkcwMHiw9s4F5QChA7S6shHEZ8/0a1mvtjRR91r7/aF7thTOyKAc32ztMAD\nYCvX7Ji+9GnczVb8wYKz2qsaWkrjgq4T16AWiw0mbuFixUXJ/8Wl/E/sqDLb\n02zQfNdlapA2sSIJmHxGf6q9k6APtn4yls6SoXS8+X/tcno0H93qoWEFpeZ7\ndB9KaXRjUQV/rcmKZUuii//L/XsQnM+vtdfxouUQivX6HAreJaJdzLP+J/qW\nuJo7E8ikWgNzUaz3IppOQITCy5Orv7Rlzxqzvc3p3eXkx7oIxt8g8gAfVnzA\nW0riZudiU/SoRxjbR/49EsqHARPgD/0J+tMG/OsyngDmgT/kHQRMtXbFOXSe\naZ2kQhfPfkWoD997JfIaUqJ13NH9cCVLExFfgiFOc3Q7rZILlTSv7rIJonmj\n7yza/6rvbsHmE2M63C4TP9beRY7tP3byrptcDEu/MlDvpBOoslwSEiTjJsU+\nuLUHJ3yrt4iRck0I+L14U+Qcnnb0Unx9kfXlYkH8Esg/9EGlNimVJ0/Y/r9j\nH3H3PRjQtMxNQeT+GWbeAXs+079q2jhKkPu/iCwFULQ5Um7sLSbynxN1JDfM\nBDCM\r\n=qjMI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDgrT864rX/SreUpwQvWW54e3ZCrz0GB4NpkouoNW32nwIgbFPxmLGgVQUhiBvtwQ6xYaxB6Oci0XyCmPavXCkFEWY="}],"size":2851,"noattachment":false,"key":"/@cloudcmd/stub/-/@cloudcmd/stub-2.3.2.tgz"},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stub_2.3.2_1566845054528_0.09555446181761074"},"_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":1566845054749,"_cnpm_publish_time":1566845054749,"dist-tags":{"latest":"5.1.0"}}