Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

p-tap

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-tap - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

54

index.d.ts
declare const pTap: {
/**
* Tap into a promise chain without affecting its value or state. Use this in a `.then()` method.
*
* @param tapHandler - Any return value is ignored. Exceptions thrown in `tapHandler` are relayed back to the original promise chain. If `tapHandler` returns a `Promise`, it will be awaited before passing through the original value.
* @returns A [thunk](https://en.wikipedia.org/wiki/Thunk) that returns a `Promise`.
*/
Tap into a promise chain without affecting its value or state. Use this in a `.then()` method.
@param tapHandler - Any return value is ignored. Exceptions thrown in `tapHandler` are relayed back to the original promise chain. If `tapHandler` returns a `Promise`, it will be awaited before passing through the original value.
@returns A [thunk](https://en.wikipedia.org/wiki/Thunk) that returns a `Promise`.
@example
```
import pTap = require('p-tap');
Promise.resolve('unicorn')
.then(pTap(console.log)) // Logs `unicorn`
.then(value => {
// `value` is still `unicorn`
});
getUser()
.then(pTap(user => recordStatsAsync(user))) // Stats are saved about `user` async before the chain continues
.then(user => {
// `user` is the user from getUser(), not recordStatsAsync()
});
```
*/
<ValueType = unknown>(tapHandler: (value: ValueType) => unknown): (

@@ -13,12 +30,25 @@ value: ValueType

/**
* Tap into a promise chain without affecting its value or state. Use this in a `.catch()` method.
*
* @param tapHandler - Any return value is ignored. Exceptions thrown in `tapHandler` are relayed back to the original promise chain. If `tapHandler` returns a `Promise`, it will be awaited before passing through the original value.
* @returns A [thunk](https://en.wikipedia.org/wiki/Thunk) that returns a `Promise`.
*/
Tap into a promise chain without affecting its value or state. Use this in a `.catch()` method.
@param tapHandler - Any return value is ignored. Exceptions thrown in `tapHandler` are relayed back to the original promise chain. If `tapHandler` returns a `Promise`, it will be awaited before passing through the original value.
@returns A [thunk](https://en.wikipedia.org/wiki/Thunk) that returns a `Promise`.
@example
```
import pTap = require('p-tap');
Promise.resolve(() => doSomething())
.catch(pTap.catch(console.error)) // prints any errors
.then(handleSuccess)
.catch(handleError);
```
*/
catch<ErrorType = unknown>(
tapHandler: (error: ErrorType) => unknown
): (error: ErrorType) => Promise<never>;
}
export default pTap;
// TODO: Remove this for the next major release
default: typeof pTap;
};
export = pTap;

@@ -9,2 +9,3 @@ 'use strict';

module.exports = pTap;
// TODO: Remove this for the next major release
module.exports.default = pTap;

@@ -11,0 +12,0 @@

{
"name": "p-tap",
"version": "3.0.0",
"version": "3.1.0",
"description": "Tap into a promise chain without affecting its value or state",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},

@@ -41,8 +41,8 @@ "files": [

"devDependencies": {
"ava": "^1.3.1",
"ava": "^1.4.1",
"delay": "^4.1.0",
"time-span": "^3.0.0",
"tsd-check": "^0.3.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc