This package has been deprecated

Author message:

🚚 @vangware/window-open-promise is now window-open-promise

@vangware/window-open-promise
TypeScript icon, indicating that this package has built-in type declarations

5.1.51Β β€’Β PublicΒ β€’Β Published

Coverage License NPM Version Open Issues Size

πŸͺŸ Promised Window.open();.

Usage

πŸ“¦ Node

Install @vangware/window-open-promise as a dependency:

pnpm add @vangware/window-open-promise
# or
npm install @vangware/window-open-promise
# or
yarn add @vangware/window-open-promise

Import it and use it:

import { windowOpenPromise } from "@vangware/window-open-promise";

const windowOpen = windowOpenPromise(globalThis);

windowOpen({
	url: "https://example.com", // URL is not required, you can open a blank window
	top: 10,
	left: 10,
})
	.then(newWindow => {
		newWindow.console.log("This will log in the new window.");
		newWindow.addEventListener("beforeunload", _event => {
			console.log("This will log when the new window is closed.");
		});
	})
	.catch(_error => {
		console.error("This will log if the new window can't be opened.");
	});

πŸ¦• Deno

Import @vangware/window-open-promise using the npm: prefix, and use it directly:

import { windowOpenPromise } from "npm:@vangware/window-open-promise";

const windowOpen = windowOpenPromise(globalThis);

try {
	const newWindow = await windowOpen({
		url: "https://example.com", // URL is not required, you can open a blank window
		top: 10,
		left: 10,
	});
	newWindow.console.log("This will log in the new window.");
	newWindow.addEventListener("beforeunload", _event => {
		console.log("This will log when the new window is closed.");
	});
} catch (_error) {
	console.error("This will log if the new window can't be opened.");
}

🌎 Browser

Import @vangware/window-open-promise using esm.sh, and use it directly:

<script type="module">
	import { windowOpenPromise } from "https://esm.sh/@vangware/window-open-promise";

	const windowOpen = windowOpenPromise(globalThis);

	try {
		const newWindow = await windowOpen({
			url: "https://example.com", // URL is not required, you can open a blank window
			top: 10,
			left: 10,
		});
		newWindow.console.log("This will log in the new window.");
		newWindow.addEventListener("beforeunload", _event => {
			console.log("This will log when the new window is closed.");
		});
	} catch (_error) {
		console.error("This will log if the new window can't be opened.");
	}
</script>

Package Sidebar

Install

npm i @vangware/window-open-promise

Weekly Downloads

7

Version

5.1.51

License

MIT

Unpacked Size

15 kB

Total Files

19

Last publish

Collaborators

  • loucyx