UNPKG

@bizjs/biz-utils

Version:

The biz utils for web develpoment.

58 lines (56 loc) 1.94 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/_internalUtils.ts var internalUtils_exports = {}; __export(internalUtils_exports, { _ensureFunction: () => _ensureFunction, _isString: () => _isString, _openUrl: () => _openUrl }); module.exports = __toCommonJS(internalUtils_exports); var import_biz_utils_common = require("@bizjs/biz-utils-common"); function noop() { } function _ensureFunction(fn) { return typeof fn === "function" ? fn : noop; } function _openUrl(url, options) { const finalUrl = (0, import_biz_utils_common.updateUrl)(url, { query: (options == null ? void 0 : options.query) || {} }); const aEl = document.createElement("a"); aEl.href = finalUrl; if (options == null ? void 0 : options.newWindow) { aEl.target = "_blank"; } if (options == null ? void 0 : options.download) { aEl.download = options.download; } aEl.rel = "noopener"; aEl.style.display = "none"; document.body.appendChild(aEl); aEl.click(); document.body.removeChild(aEl); } function _isString(str) { return typeof str === "string"; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { _ensureFunction, _isString, _openUrl });