Learn about our RFC process, Open RFC meetings & more.Join in the discussion! ¬Ľ

@vangware/window-open-promise

4.0.7¬†‚Äʬ†Public¬†‚Äʬ†Published

@vangware/window-open-promise logo

Build Status Coverage License NPM Version Open Issues Size

ūü™ü Promised Window.open();.

Usage

ūüď¶ Node

import { windowOpenPromise } from "@vangware/window-open-promise";
 
const windowOpen = windowOpenPromise(window);
 
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 { windowOpenPromise } from "https://cdn.skypack.dev/@vangware/window-open-promise";
 
const windowOpen = windowOpenPromise(window);
 
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.");
}

Documentation

Documentation can be found HERE. It is auto-generated with typedoc based on the JSDocs and the types in the source. Shouldn't be necessary to read this, code editors like VSCode integrate the documentation in the UI.

Changelog

Changelog can be found HERE.

Test coverage

Test coverage can be found HERE.

Install

npm i @vangware/window-open-promise

DownloadsWeekly Downloads

146

Version

4.0.7

License

MIT

Unpacked Size

22.7 kB

Total Files

28

Last publish

Collaborators

  • avatar