New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

penpal

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

penpal - npm Package Compare versions

Comparing version 6.2.0 to 6.2.1

2

package.json
{
"name": "penpal",
"version": "6.2.0",
"version": "6.2.1",
"description": "A promise-based library for communicating with iframes via postMessage.",

@@ -5,0 +5,0 @@ "author": "Aaron Hardy <aaron@aaronhardy.com>",

@@ -219,2 +219,35 @@ [![npm version](https://badge.fury.io/js/penpal.svg)](https://badge.fury.io/js/penpal)

## TypeScript
When calling `connectToChild` or `connectToParent`, you may pass a generic type argument. This will be used to type the `child` or `parent` object that `connection.promise` is resolved with. This is better explained in code:
```typescript
import { connectToChild } from 'penpal';
// This interace could be imported from a code library
// that both the parent and child share.
interface ChildApi {
multiply(...args: number[]): number;
}
// Supply the interface as a generic argument.
const connection = connectToChild<ChildApi>({
iframe: new HTMLIFrameElement(),
});
// The resulting child object will contain properly
// typed methods.
const child = await connection.promise;
// The result variable is typed as a number.
const result = await child.multiply(1, 3);
```
The following TypeScript types are also exported as named constants for your use:
- `Connection`
- `Methods`
- `AsyncMethodReturns`
- `CallSender`
- `PenpalError`
## Supported Browsers

@@ -221,0 +254,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