utools-utils
Version:
Common utilities for uTools
29 lines (27 loc) • 599 B
JavaScript
// src/common.ts
function isUTools() {
return Reflect.has(window, "utools");
}
function isBrowser() {
return !isUTools();
}
function hideAndOutPlugin() {
utools.hideMainWindow();
utools.outPlugin();
}
function toMap(arr, keyFn, valFn) {
if (valFn) {
const map2 = /* @__PURE__ */ new Map();
arr.forEach((item, index) => map2.set(keyFn(item, index), valFn(item, index)));
return map2;
}
const map = /* @__PURE__ */ new Map();
arr.forEach((item, index) => map.set(keyFn(item, index), item));
return map;
}
export {
isUTools,
isBrowser,
hideAndOutPlugin,
toMap
};