nodehotkey
Version:
Authotkey like macros for NodeJS
30 lines • 1.16 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var robot_js_1 = __importDefault(require("robot-js"));
/**
* checks if current active window's title matches the given string or regexp
* @param title title to match
* @returns {boolean} true the current active window's title matches the given argument
*/
function matchCurrentWindowTitle(title) {
var windowTitle = robot_js_1.default.Window.getActive().getTitle();
var titleRegExp;
if (typeof title === 'string') {
titleRegExp = new RegExp("^" + escapeRegExp(title) + "$");
}
else if (title instanceof RegExp) {
titleRegExp = title;
}
else {
titleRegExp = /.*/g; // make it match everything in unexpected scenario
}
return windowTitle.match(titleRegExp) !== null;
}
exports.matchCurrentWindowTitle = matchCurrentWindowTitle;
function escapeRegExp(s) {
return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
//# sourceMappingURL=Window.js.map