{"name":"@cloudcmd/stub","version":"3.2.0","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"},"nyc":{"check-coverage":true,"all":true,"exclude":["**/*.spec.js","**/*.madrun.*","test"],"branches":100,"lines":100,"functions":100,"statements":100},"dependencies":{"chalk":"^4.0.0","jest-diff":"^26.0.1","strip-ansi":"^6.0.0"},"keywords":["sinon","stub","async","promise","calledWith","diff","tape"],"devDependencies":{"coveralls":"^3.0.0","eslint":"^7.0.0","eslint-plugin-node":"^11.0.0","eslint-plugin-putout":"^6.7.0","madrun":"^8.0.5","mock-require":"^3.0.2","nodemon":"^2.0.0","nyc":"^15.0.0","putout":"^12.7.0","supertape":"^3.9.1","try-catch":"^3.0.0","try-to-catch":"^3.0.0"},"license":"MIT","engines":{"node":">=10"},"publishConfig":{"access":"public"},"gitHead":"db5e02d8f1c6b248ad48504d8460e64547585105","bugs":{"url":"https://github.com/cloudcmd/stub/issues"},"_id":"@cloudcmd/stub@3.2.0","_nodeVersion":"15.4.0","_npmVersion":"6.14.7","dist":{"integrity":"sha512-PWncOtLQueKsX75CH+2yB/q1j/P4wAF/9LoiiAMJn+v1qR3RqYo3iWTadahy/0G2utB74QnWWOODAmQhgKxOFg==","shasum":"5dd7b4d310485308ebe1b8be926b148dddce49e5","tarball":"http://registry-npm.ywwl.com/@cloudcmd/stub/download/@cloudcmd/stub-3.2.0.tgz","fileCount":6,"unpackedSize":8467,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4esECRA9TVsSAnZWagAAVBkP+wUTuZGjH0P/tLivCuZJ\ne0wWhtp3cmg0Qe7VI3lnOot/PfQ6SsJw7RXq5gX7so8DbBLlAjQ/WNQ6QEeC\nV6JD5qfw/ARoIdNUmDbiuJl6ev0MorPFTgZG/QtcPG0TLuteaUas6w9ddQCQ\nNaiyEbEsyj48TZZf446T+QdmPu+RkUE+S7p7jPhal6zg+Z5Kwi46sYgwZV55\nwdEjGkLMTFZe2d2blypb9o6jFxDEoulWAimq/1cbt8wmgv6Tbcb8ALvB6Ohl\nbi4foEuaLwmuCsOBKez7W7PfpnZahM++75OR0CGagQ5BRy9DrOlIP0buZHW8\nodhrpnVkwKhEU6IVjbcQbK4+NmIcPvNNTlqKRbI1iLz+ma8wqZchW00G7pw3\n3sz+3bu34PNR/ZZVbdSYP+WlazuD8gg+JBKIRGDD7SRG7iEchdRSSZq6yRFf\nPvgIPsKQsYejtG2RfpwSMzcljxwLjnOzHOJw0z/Y/E5AYvmY6nT6Hvv1uRgU\nzf6W2kHPsS09azgFYYpAWKkPPvmXHkM6nr0UaDGIrVWyIz0PRU0KNdHm0dQh\nFGG+R1jX4d7mX7w7iB4w6Qw1N/TwsRl8WGJs6HIBb7qV/A65wcp79SH5vgke\nE1dAEsJhb3oSGCfoOXRO8fG58ujSY8lYdkpZsgrAFdV1kCKIxR/SfCMZzldb\n0hy2\r\n=M0es\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCVYxI6kV1YY7cboDnzYiR9IQTw0MQzmX5aGdxJYW7CwgIhANf8HPyMVHEwjp6ysDLrEr8Y1HA4hhGmJ/a0T7c6Y6GS"}],"size":3230,"noattachment":false,"key":"/@cloudcmd/stub/-/@cloudcmd/stub-3.2.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stub_3.2.0_1608641284436_0.6430987812529345"},"_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":1608641284582,"_cnpm_publish_time":1608641284582,"dist-tags":{"latest":"5.1.0"}}