{"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":{"integrity":"sha512-G7GTcera93GkIIt5iM57ITilyMR1nSlGKjwSEifhP7F8I2QtOsHbokoRulAgHW2V5JxLS5Tg/7ToX2YHkPjlFA==","shasum":"cdc7727b4864bda90c9359090f6d1c5ffa9c39f1","tarball":"http://registry-npm.ywwl.com/p-tap/download/p-tap-4.0.0.tgz","fileCount":5,"unpackedSize":5407,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgb0+8CRA9TVsSAnZWagAAEWAP/Rsimk6IuKWI8jzA4e7E\nKPpeJqXWCPR28TiiWG3uWRdwlm6GEKSufgPKLxXOP6V79Pt6BKS4PgLv+mjI\npKYAP3/NezgsOEWwc0lDQfXfjkGxoV0KZzdeHyiTlPaOaqnRe5g+h8q4xMc4\nPoaCXewsMxFKCRQp3671347h7Sot3EECkJTJIfwuUA6YpdhpTWNKhdil9SU9\nNl/BSzfjgo+2yACU9oNoi7ZHAK7F1PapFUV1+4HI+Ggk5jj/1KeB9ky+0Dg0\nB9q9RkgDT5VR/AQrPnbXDYC4colCigdYv3v3GD1BU5sEKrpaKfqgSXjdq3k2\nNdiPe0otUh9y8KSbEziInEsbu5OrdY9vXmLYMx5i/XtulwA9bzwA8OFCmfJB\n2mGUFttHou9qfi20I1r5Zo8JAQ5DpFObU6bN9nXDkWMDySP2R5rpnRQA0uGc\n0jTTLcMybQNG5+wIE00cviTJUcwzj9Psuh95LqZE2Al/3Lb3xPu2JKOxFZaw\naql5epUAvH3dDBzLsyEO8RjFS9YdLL134nCEFXzq3foAHUMNZJEBEhqmyUVg\nxGrTxg9od0phdv5LX9Q+DsGlCY1eRiGzLydlRofEBnp/tYhUWzi3GmQlSzlS\n7GJ0BzkuIZLx2eCcEHfDP/hRSBS2hQwP3//pxL4vt0PKjhfXHSbtLZvWcy6P\n31ud\r\n=Ge6y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDNR3V6kmgegwriI0hlfLjRmd3EMEtE5mexj0QWYnrcCAIgKfkqgHgZAGR3sRzyrjrKm+VctLxgvP42cpfDmqWEIVY="}],"size":2140,"noattachment":false,"key":"/p-tap/-/p-tap-4.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-tap_4.0.0_1617907644332_0.5185303739400176"},"_hasShrinkwrap":false,"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","publish_time":1617907644489,"_cnpm_publish_time":1617907644489,"dist-tags":{"latest":"4.0.0"}}