{"_id":"p-tap","_rev":"202540","name":"p-tap","description":"Tap into a promise chain without affecting its value or state","dist-tags":{"latest":"4.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2023-03-21T06:29:14.000Z","created":"2016-10-21T07:11:51.074Z","4.0.0":"2021-04-08T18:47:24.489Z","3.1.0":"2019-04-04T04:58:59.272Z","3.0.0":"2019-03-12T08:16:03.834Z","2.0.0":"2018-06-09T09:48:48.470Z","1.0.0":"2016-10-21T07:11:51.074Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-tap.git"},"versions":{"4.0.0":{"name":"p-tap","version":"4.0.0","description":"Tap into a promise chain without affecting its value or state","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-tap.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","tap","debug","log","then","catch","error","chain","pipeline","thunk","function","async","await","promises","bluebird"],"devDependencies":{"ava":"^3.15.0","delay":"^5.0.0","time-span":"^4.0.0","tsd":"^0.14.0","xo":"^0.38.2"},"gitHead":"9ba6e69eaf1accbd67e1cf9d64cd47f26cce8d3c","bugs":{"url":"https://github.com/sindresorhus/p-tap/issues"},"homepage":"https://github.com/sindresorhus/p-tap#readme","_id":"p-tap@4.0.0","_nodeVersion":"15.12.0","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"cdc7727b4864bda90c9359090f6d1c5ffa9c39f1","size":2140,"noattachment":false,"key":"/p-tap/-/p-tap-4.0.0.tgz","tarball":"http://name.csiicloud.com:7001/p-tap/download/p-tap-4.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-tap_4.0.0_1617907644332_0.5185303739400176"},"_hasShrinkwrap":false,"publish_time":1617907644489,"_cnpm_publish_time":1617907644489,"_cnpmcore_publish_time":"2021-12-16T13:39:22.052Z"},"3.1.0":{"name":"p-tap","version":"3.1.0","description":"Tap into a promise chain without affecting its value or state","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-tap.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","tap","debug","log","then","catch","error","chain","pipeline","thunk","function","async","await","promises","bluebird"],"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","time-span":"^3.0.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"07e30957310ef5f1712b04d98e8b549912356f53","bugs":{"url":"https://github.com/sindresorhus/p-tap/issues"},"homepage":"https://github.com/sindresorhus/p-tap#readme","_id":"p-tap@3.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"ceea85e92164e12b1c2b1caf78b4dc2ee51c9b5f","size":2242,"noattachment":false,"key":"/p-tap/-/p-tap-3.1.0.tgz","tarball":"http://name.csiicloud.com:7001/p-tap/download/p-tap-3.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-tap_3.1.0_1554353939083_0.5701212277374763"},"_hasShrinkwrap":false,"publish_time":1554353939272,"_cnpm_publish_time":1554353939272,"_cnpmcore_publish_time":"2021-12-16T13:39:22.253Z"},"3.0.0":{"name":"p-tap","version":"3.0.0","description":"Tap into a promise chain without affecting its value or state","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-tap.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","tap","debug","log","then","catch","error","chain","pipeline","thunk","function","async","await","promises","bluebird"],"devDependencies":{"ava":"^1.3.1","delay":"^4.1.0","time-span":"^3.0.0","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"79cb193c8eaf350da81e393912726310b54314e8","bugs":{"url":"https://github.com/sindresorhus/p-tap/issues"},"homepage":"https://github.com/sindresorhus/p-tap#readme","_id":"p-tap@3.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"8e2e3c2d7eddef32aa6e3ae355de5d53e9c67411","size":2154,"noattachment":false,"key":"/p-tap/-/p-tap-3.0.0.tgz","tarball":"http://name.csiicloud.com:7001/p-tap/download/p-tap-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-tap_3.0.0_1552378563475_0.0833155467465676"},"_hasShrinkwrap":false,"publish_time":1552378563834,"_cnpm_publish_time":1552378563834,"_cnpmcore_publish_time":"2021-12-16T13:39:22.754Z"},"2.0.0":{"name":"p-tap","version":"2.0.0","description":"Tap into a promise chain without affecting its value or state","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-tap.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","tap","debug","log","then","catch","error","chain","pipeline","thunk","function","async","await","promises","bluebird"],"devDependencies":{"ava":"*","delay":"^3.0.0","time-span":"^2.0.0","xo":"*"},"gitHead":"015511ce89362eed892731f9b7e3441d9d6a4a72","bugs":{"url":"https://github.com/sindresorhus/p-tap/issues"},"homepage":"https://github.com/sindresorhus/p-tap#readme","_id":"p-tap@2.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"a1b526946a3c22e94b4bca9d22d117049ca0ee09","size":1952,"noattachment":false,"key":"/p-tap/-/p-tap-2.0.0.tgz","tarball":"http://name.csiicloud.com:7001/p-tap/download/p-tap-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-tap_2.0.0_1528537728379_0.3228461270617924"},"_hasShrinkwrap":false,"publish_time":1528537728470,"_cnpm_publish_time":1528537728470,"_cnpmcore_publish_time":"2021-12-16T13:39:22.973Z"},"1.0.0":{"name":"p-tap","version":"1.0.0","description":"Tap into a promise chain without affecting its value or state","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-tap.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","tap","debug","log","then","catch","error","chain","pipeline","thunk","function","async","await","promises","bluebird"],"devDependencies":{"ava":"*","delay":"^1.3.1","time-span":"^1.0.0","xo":"*"},"xo":{"esnext":true},"gitHead":"a6c20105b632b319688c652d29f7c8d6df35b7ab","bugs":{"url":"https://github.com/sindresorhus/p-tap/issues"},"homepage":"https://github.com/sindresorhus/p-tap#readme","_id":"p-tap@1.0.0","_shasum":"dc4fa086135e8688226f6e7dccea67d8322d08df","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"dc4fa086135e8688226f6e7dccea67d8322d08df","size":1969,"noattachment":false,"key":"/p-tap/-/p-tap-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/p-tap/download/p-tap-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-tap-1.0.0.tgz_1477033910858_0.032033002469688654"},"directories":{},"publish_time":1477033911074,"_hasShrinkwrap":false,"_cnpm_publish_time":1477033911074,"_cnpmcore_publish_time":"2021-12-16T13:39:23.206Z"}},"readme":"# p-tap\n\n> Tap into a promise chain without affecting its value or state\n\n## Install\n\n```\n$ npm install p-tap\n```\n\n## Usage\n\n```js\nimport pTap from 'p-tap';\n\nPromise.resolve('unicorn')\n\t.then(pTap(console.log)) // Logs `unicorn`\n\t.then(value => {\n\t\t// `value` is still `unicorn`\n\t});\n```\n\n```js\nimport pTap from 'p-tap';\n\ngetUser()\n\t.then(pTap(user => recordStatsAsync(user))) // Stats are saved about `user` async before the chain continues\n\t.then(user => {\n\t\t// `user` is the user from getUser(), not recordStatsAsync()\n\t});\n```\n\n```js\nimport pTap from 'p-tap';\n\nPromise.resolve(() => doSomething())\n\t.catch(pTap.catch(console.error)) // Prints any errors\n\t.then(handleSuccess)\n\t.catch(handleError);\n```\n\n## API\n\n### pTap(tapHandler)\n\nUse this in a `.then()` method.\n\nReturns a [thunk](https://en.wikipedia.org/wiki/Thunk) that returns a `Promise`.\n\n### pTap.catch(tapHandler)\n\nUse this in a `.catch()` method.\n\nReturns a [thunk](https://en.wikipedia.org/wiki/Thunk) that returns a `Promise`.\n\n#### tapHandler\n\nType: `Function`\n\nAny return value is ignored. Exceptions thrown in `tapHandler` are relayed back to the original promise chain.\n\nIf `tapHandler` returns a `Promise`, it will be awaited before passing through the original value.\n\n## Related\n\n- [p-log](https://github.com/sindresorhus/p-log) - Log the value/error of a promise\n- [p-if](https://github.com/sindresorhus/p-if) - Conditional promise chains\n- [p-catch-if](https://github.com/sindresorhus/p-catch-if) - Conditional promise catch handler\n- [More…](https://github.com/sindresorhus/promise-fun)\n","_attachments":{},"homepage":"https://github.com/sindresorhus/p-tap#readme","bugs":{"url":"https://github.com/sindresorhus/p-tap/issues"},"license":"MIT"}