{"_id":"@aercolino/wrap-promise","_rev":"2-2a88d041e63aba365d537a4985bc7d1b","name":"@aercolino/wrap-promise","description":"Wrap a promise within before and after callbacks.","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@aercolino/wrap-promise","version":"0.1.0","description":"Wrap a promise within before and after callbacks.","repository":{"type":"git","url":"git+https://github.com/aercolino/wrap-promise.git"},"engines":{"node":">=6.10.3"},"main":"src/index.js","scripts":{"test":"nyc mocha tests/**/*.test.js","coveralls":"npm test && nyc report --reporter=text-lcov | coveralls"},"keywords":["test","wrap","promise","before","after"],"author":{"name":"Andrea Ercolino","email":"andowebsit.es@gmail.com","url":"http://andowebsit.es"},"license":"ISC","devDependencies":{"chai":"^4.1.2","chai-as-promised":"^7.1.1","coveralls":"^2.13.1","istanbul":"^0.4.5","mocha":"^3.5.3","nyc":"^11.2.1","sinon":"^3.2.1","sinon-chai":"^2.13.0","sinon-test":"^2.1.0"},"dependencies":{},"gitHead":"4b25d7fb7695a62bfe557973efee2a2a72e00c67","bugs":{"url":"https://github.com/aercolino/wrap-promise/issues"},"homepage":"https://github.com/aercolino/wrap-promise#readme","_id":"@aercolino/wrap-promise@0.1.0","_npmVersion":"5.4.2","_nodeVersion":"8.5.0","_npmUser":{"name":"aercolino","email":"andowebsit.es@gmail.com"},"dist":{"integrity":"sha512-5WcdbSH7hwAUgX1OMwd0Lj/WSbGV1Vf/Pcr2C+aRPejKGUBF2sZGPCwFboEa8Xy/VBgOIebbW78aV5hE5Oicjg==","shasum":"1487654b945d0e1592109907d9efc8a4b025edfe","tarball":"https://registry.npmjs.org/@aercolino/wrap-promise/-/wrap-promise-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDd3saSzBNYDAKVgMQebxHVr7ZoceE0Nn6mfkq+cRuxagIgLAAIFmvZO9oP2iwXfE/AQFhs4Vr0S4OQUWTZ4nW5WJ0="}]},"maintainers":[{"name":"aercolino","email":"andowebsit.es@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wrap-promise-0.1.0.tgz_1506241278907_0.16273706988431513"}},"0.1.1":{"name":"@aercolino/wrap-promise","version":"0.1.1","description":"Wrap a promise within before and after callbacks.","repository":{"type":"git","url":"git+https://github.com/aercolino/wrap-promise.git"},"engines":{"node":">=6.10.3"},"main":"src/index.js","scripts":{"test":"nyc mocha tests/**/*.test.js","coveralls":"npm test && nyc report --reporter=text-lcov | coveralls"},"keywords":["test","wrap","promise","before","after"],"author":{"name":"Andrea Ercolino","email":"andowebsit.es@gmail.com","url":"http://andowebsit.es"},"license":"ISC","devDependencies":{"chai":"^4.1.2","chai-as-promised":"^7.1.1","coveralls":"^2.13.1","istanbul":"^0.4.5","mocha":"^3.5.3","nyc":"^11.2.1","sinon":"^3.2.1","sinon-chai":"^2.13.0","sinon-test":"^2.1.0"},"dependencies":{},"gitHead":"757b604db52c826388a620dc8007085b8b0281f4","bugs":{"url":"https://github.com/aercolino/wrap-promise/issues"},"homepage":"https://github.com/aercolino/wrap-promise#readme","_id":"@aercolino/wrap-promise@0.1.1","_npmVersion":"5.4.2","_nodeVersion":"8.5.0","_npmUser":{"name":"aercolino","email":"andowebsit.es@gmail.com"},"dist":{"integrity":"sha512-bWOUpY0KFLWeZw96LECVY1r7FzkSuyAiUcRWUH8wfo8iToqfsfyu4Ba59eTAVo6/YXdXY0SlUd5EvY5vUr6bbQ==","shasum":"ef7347073776b8a90e6c640408ac14f7d7e31515","tarball":"https://registry.npmjs.org/@aercolino/wrap-promise/-/wrap-promise-0.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICXOCJ0X/yVAV+GTadMtSItcNNXEYMlVcxUaJ2qF+cNiAiEA5IL87a/IoeApOwyu1JxFlzyrtXZSnYCuy8BxxFDP/i8="}]},"maintainers":[{"name":"aercolino","email":"andowebsit.es@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wrap-promise-0.1.1.tgz_1506274430741_0.6170956939458847"}}},"readme":"# Wrap Promise [![Build Status](https://travis-ci.org/aercolino/wrap-promise.svg?branch=master)](https://travis-ci.org/aercolino/wrap-promise) [![Coverage Status](https://coveralls.io/repos/github/aercolino/wrap-promise/badge.svg?branch=master)](https://coveralls.io/github/aercolino/wrap-promise?branch=master)\n\n\nWrap a promise within before and after callbacks.\n\n\n\n\n## Installation\n\n```bash\n$ npm install @aercolino/wrap-promise\n```\n\nThis is not related to [wrap-promise](https://github.com/shinnn/wrap-promise).\n\n\n\n## Usage\n\n```js\nconst { $wrapPromise } = require('@aercolino/wrap-promise');\n\nconst regular = $wrapPromise($promise, before, after);\n\nconst special = $wrapPromise($promise, before, afterFulfillment, afterRejection);\n```\n\n+ `$promise` and `before` are called with no arguments.\n\n+ In the **regular** case:\n\n    + `after` is called with the fulfillment `{ value }` or the rejection `{ reason }`.\n    \n    + no matter whether executing the fulfillment line or the rejection line, `after` is called in both cases, without changing line, without changing the fulfillment value nor the rejection reason. (i.e. `after` return value is discarded)\n\n+ In the **special** case:\n\n    + `afterFulfillment` is called with the fulfillment `{ value }`.\n    \n    + `afterRejection` is called with the rejection `{ reason }`.\n    \n    + `afterFulfillment` is called only if executing the fulfillment line, without changing line, without changing the fulfillment value.\n    \n    + `afterRejection` is called only if executing the rejection line, *by default* changing to the fulfillment line (i.e. swallowing the rejection) and making `afterRejection` return value the new fullfilment value.\n    \n        If you prefer to stay on the rejection line, just `throw` from inside `afterRejection`, as usual.\n\n\n### Example\n\n```js\n// test.js\nrequire('console.mute');\nconst { $wrapPromise } = require('@aercolino/wrap-promise');\n\nfunction muted($fn, ...args) {\n    return $wrapPromise(\n        () => $fn(...args),\n        () => {\n            console.mute();\n        },\n        () => {\n            console.resume();\n        },\n    );\n}\n\n...\nit('should be quiet when calling this'\n    ...\nit('should quietly run that noisy function too', function() {\n    return muted(noisy, 'bye bye', 'clutter')\n        .then(() => {\n            expect(that).to.have.been.called;\n        });\n});\nit('should be quiet when calling that'\n    ...\n...\n```\n```\n// console\n$ npm test\n\n    ...\n    ✓ should be quiet when calling this\n    ✓ should quietly run that noisy function too\n    ✓ should be quiet when calling that\n    ...\n\n5 passing (64ms)\n```\n\n\n\n\n## Tests\n\n```\n$ npm test\n```\n","maintainers":[{"name":"aercolino","email":"andowebsit.es@gmail.com"}],"time":{"modified":"2022-04-04T11:48:13.892Z","created":"2017-09-24T08:21:20.228Z","0.1.0":"2017-09-24T08:21:20.228Z","0.1.1":"2017-09-24T17:33:51.731Z"},"homepage":"https://github.com/aercolino/wrap-promise#readme","keywords":["test","wrap","promise","before","after"],"repository":{"type":"git","url":"git+https://github.com/aercolino/wrap-promise.git"},"author":{"name":"Andrea Ercolino","email":"andowebsit.es@gmail.com","url":"http://andowebsit.es"},"bugs":{"url":"https://github.com/aercolino/wrap-promise/issues"},"license":"ISC","readmeFilename":"README.md"}