Nine Pedestrians Mesmerized
Have ideas to improve npm?Join in the discussion! »

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

4.0.10 • 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?dts";

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

28

Version

4.0.10

License

MIT

Unpacked Size

23 kB

Total Files

28

Last publish

Collaborators

  • avatar