Push notifications template

Created this file using the Push.js to allow simple push notifications in JavaScript like this

Notify.info({ title: this.title, message: "No changes to undo." });

with an import like this

import * as Notify from "../utilities/notify";

That references this file with the following contents.

import * as Push from "push";

function allowed() {
 if (Push.Permission.has()) {
	return true;
 }
 return false;
};

function display(options) {
	 Push.create(options.title,
	 {
		 body: options.message,
		 icon: { x16: "images/notify/icon-x16.png", x32: "images/notify/icon-x32.png" },
		 timeout: options.timeout || 1000,
		 onClick: () => {
		 window.focus();
		 this.close();
	 }
 });
}

function displayMessage(options, altTitle) {
 if (!allowed()) {
	return;
 }
 if (!options.hasOwnProperty("message")) {
	return;
 }
 try {
	 let newOptions = Object.assign({}, options);
	 newOptions.title = newOptions.title || altTitle;
	 display(Object.freeze(Object.assign({}, newOptions)));
 }
 catch (err) {
	console.log(err);
 } 
}

export function warning(options) {
 options.timeout = options.timeout || 2500;
 displayMessage(options, "Warning");
};

export function info(options) {
 options.timeout = options.timeout || 1000;
 displayMessage(options, "Information");
};