🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@yqg/beetle

Package Overview
Dependencies
Maintainers
29
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yqg/beetle - npm Package Compare versions

Comparing version
1.0.3
to
1.0.4-beta.1
+25
dist-utils/types/util/operateEnv/index.d.ts
type EnvStage = 'prod' | 'test' | 'dev' | 'indo' | 'mex' | 'phi' | 'eu' | 'cn';
interface OperateEnvOptions {
useUrlParam?: boolean;
urlParamKey?: string;
envAlias?: string;
}
/**
* 操作环境的工具函数
* 通过 env 方法设置当前环境
* @param {string} stage - 当前的stage
* @param {object} options - 配置项,包含额外判定条件
* @returns {object} - 返回可以获取当前环境的 isXXX 方法
*/
declare const operateEnv: {
env: (stage: EnvStage) => void;
isProd: (options?: OperateEnvOptions) => boolean;
isDev: (options?: OperateEnvOptions) => boolean;
isTest: (options?: OperateEnvOptions) => boolean;
isCn: (options?: OperateEnvOptions) => boolean;
isIndo: (options?: OperateEnvOptions) => boolean;
isMex: (options?: OperateEnvOptions) => boolean;
isPhi: (options?: OperateEnvOptions) => boolean;
isEu: (options?: OperateEnvOptions) => boolean;
};
export default operateEnv;
const l = /* @__PURE__ */ function() {
let t = null;
const c = (e) => {
t = e;
}, r = (e, n) => {
const a = (n == null ? void 0 : n.envAlias) || e;
if (n != null && n.useUrlParam && new URLSearchParams(window.location.search).get(n.urlParamKey || "env") === a)
return !0;
if (a === "cn")
return (t == null ? void 0 : t.indexOf("-")) === -1;
const u = location.hostname, s = new RegExp(a);
return ["dev", "test", "prod"].includes(e) ? s.test(t || "") : s.test(t || "") || s.test(u);
};
return {
env: c,
// 用于设置当前的环境
isProd: (e) => r("prod", e),
// 判断是否是生产环境
isDev: (e) => r("dev", e),
// 判断是否是开发环境
isTest: (e) => r("test", e),
// 判断是否是测试环境
isCn: (e) => r("cn", e),
// 判断是否是中国环境
isIndo: (e) => r("indo", e),
// 判断是否是印尼环境
isMex: (e) => r("mex", e),
// 判断是否是墨西哥环境
isPhi: (e) => r("phi", e),
// 判断是否是菲律宾环境
isEu: (e) => r("eu", e)
// 判断是否是波兰环境
};
}();
export {
l as default
};
+32
-30
import r from "./data/arrayToTree/index.mjs";
import o from "./data/treeToArray/index.mjs";
import m from "./data/traverseDeep/index.mjs";
import i from "./data/mergeDeep/index.mjs";
import e from "./data/parseJSON/index.mjs";
import e from "./data/mergeDeep/index.mjs";
import i from "./data/parseJSON/index.mjs";
import t from "./data/stringifyJSON/index.mjs";
import f from "./data/formatStrToArray/index.mjs";
import p from "./data/isDeepEqual/index.mjs";
import p from "./data/formatStrToArray/index.mjs";
import f from "./data/isDeepEqual/index.mjs";
import { serializeParams as a } from "./url/serializeParams/index.mjs";

@@ -14,4 +14,4 @@ import s from "./url/setQueryParam/index.mjs";

import y from "./validate/isValidMobile/index.mjs";
import d from "./validate/isValidPhone/index.mjs";
import n from "./format/formatFileSize/index.mjs";
import n from "./validate/isValidPhone/index.mjs";
import d from "./format/formatFileSize/index.mjs";
import T from "./format/maskNumber/index.mjs";

@@ -28,8 +28,8 @@ import D from "./format/formatPercentage/index.mjs";

import h from "./cookie/getCookie/index.mjs";
import C from "./date/getTimeAgo/index.mjs";
import R from "./date/getDaysDiff/index.mjs";
import v from "./date/getWeekDay/index.mjs";
import x from "./date/getDaysInMonth/index.mjs";
import A from "./date/isLeapYear/index.mjs";
import E from "./validate/isValidURL/index.mjs";
import v from "./date/getTimeAgo/index.mjs";
import C from "./date/getDaysDiff/index.mjs";
import E from "./date/getWeekDay/index.mjs";
import R from "./date/getDaysInMonth/index.mjs";
import x from "./date/isLeapYear/index.mjs";
import A from "./validate/isValidURL/index.mjs";
import F from "./validate/isValidEmail/index.mjs";

@@ -40,12 +40,13 @@ import I from "./util/getRandomString/index.mjs";

import U from "./file/getFileType/index.mjs";
import z from "./package.json.mjs";
import * as B from "lodash-es";
const kr = {
import z from "./util/operateEnv/index.mjs";
import B from "./package.json.mjs";
import * as J from "lodash-es";
const hr = {
arrayToTree: r,
treeToArray: o,
traverseDeep: m,
mergeDeep: i,
parseJSON: e,
mergeDeep: e,
parseJSON: i,
stringifyJSON: t,
formatStrToArray: f,
formatStrToArray: p,
serializeParams: a,

@@ -56,4 +57,4 @@ setQueryParam: s,

isValidMobile: y,
isValidPhone: d,
formatFileSize: n,
isValidPhone: n,
formatFileSize: d,
maskNumber: T,

@@ -70,8 +71,8 @@ formatPercentage: D,

getCookie: h,
getTimeAgo: C,
getDaysDiff: R,
getWeekDay: v,
getDaysInMonth: x,
isLeapYear: A,
isValidURL: E,
getTimeAgo: v,
getDaysDiff: C,
getWeekDay: E,
getDaysInMonth: R,
isLeapYear: x,
isValidURL: A,
isValidEmail: F,

@@ -82,8 +83,9 @@ getRandomString: I,

getFileType: U,
isDeepEqual: p,
...B,
VERSION: z.version
isDeepEqual: f,
operateEnv: z,
...J,
VERSION: B.version
};
export {
kr as default
hr as default
};

@@ -15,7 +15,7 @@ export * from "lodash-es";

import { default as C } from "./validate/isValidMobile/index.mjs";
import { default as F } from "./validate/isValidPhone/index.mjs";
import { default as Q } from "./format/formatFileSize/index.mjs";
import { default as U } from "./format/maskNumber/index.mjs";
import { default as w } from "./format/formatPercentage/index.mjs";
import { default as B } from "./format/formatNumber/index.mjs";
import { default as v } from "./validate/isValidPhone/index.mjs";
import { default as F } from "./format/formatFileSize/index.mjs";
import { default as Q } from "./format/maskNumber/index.mjs";
import { default as U } from "./format/formatPercentage/index.mjs";
import { default as z } from "./format/formatNumber/index.mjs";
import { default as I } from "./format/formatCurrency/index.mjs";

@@ -41,12 +41,13 @@ import { default as M } from "./util/copyToClipboard/index.mjs";

import { default as Se } from "./file/getFileType/index.mjs";
import { default as he } from "./beetle.mjs";
import { default as he } from "./util/operateEnv/index.mjs";
import { default as Ce } from "./beetle.mjs";
export {
o as arrayToTree,
M as copyToClipboard,
he as default,
Ce as default,
ce as downloadFile,
I as formatCurrency,
Q as formatFileSize,
B as formatNumber,
w as formatPercentage,
F as formatFileSize,
z as formatNumber,
U as formatPercentage,
y as formatStrToArray,

@@ -69,6 +70,7 @@ re as getCookie,

C as isValidMobile,
F as isValidPhone,
v as isValidPhone,
ie as isValidURL,
U as maskNumber,
Q as maskNumber,
p as mergeDeep,
he as operateEnv,
u as parseJSON,

@@ -75,0 +77,0 @@ h as removeQueryParam,

@@ -1,2 +0,2 @@

const e = "1.0.3", t = {
const e = "1.0.4-beta.1", t = {
version: e

@@ -3,0 +3,0 @@ };

@@ -40,2 +40,3 @@ export * from 'lodash-es';

export { default as getFileType } from './file/getFileType/index';
export { default as operateEnv } from './util/operateEnv/index';
export { default } from './beetle';

@@ -6,3 +6,3 @@ /**

*/
declare function withAsyncLock<T extends (...args: any[]) => Promise<any>>(fn: T): (...args: Parameters<T>) => void;
declare function withAsyncLock<T extends (...args: any[]) => Promise<any>>(fn: T): (...args: Parameters<T>) => ReturnType<T> | undefined;
export default withAsyncLock;

@@ -1,20 +0,20 @@

function i(c, a = {}) {
const { onSuccess: t, onError: o } = a;
if (typeof c != "string")
function r(a, i = {}) {
const { onSuccess: o, onError: e } = i;
if (typeof a != "string")
throw new Error("Invalid content value");
if (navigator.clipboard)
navigator.clipboard.writeText(c).then(() => {
t && t();
}).catch((e) => {
o && o(e);
navigator.clipboard.writeText(a).then(() => {
o && o();
}).catch((t) => {
e && e(t);
});
else {
const e = document.createElement("textarea");
e.value = c, e.style.position = "fixed", document.body.appendChild(e), e.select();
const t = document.createElement("textarea");
t.value = a, t.style.position = "fixed", document.body.appendChild(t), t.select();
try {
document.execCommand("copy") && t ? t() : o && o(new Error("Failed to copy content"));
} catch (r) {
o && o(r);
document.execCommand("copy") ? o == null || o() : e == null || e(new Error("Failed to copy content"));
} catch (c) {
e && e(c);
} finally {
document.body.removeChild(e);
document.body.removeChild(t);
}

@@ -24,3 +24,3 @@ }

export {
i as default
r as default
};

@@ -1,13 +0,16 @@

function a(e) {
function c(n) {
let t = !1;
return (...l) => {
t || (t = !0, e(...l).finally(() => {
return function(...r) {
if (t) return;
t = !0;
const e = n.apply(this, r);
return e.catch((l) => {
throw l;
}).finally(() => {
t = !1;
}).catch((r) => {
throw r;
}));
}), e;
};
}
export {
a as default
c as default
};
{
"name": "@yqg/beetle",
"version": "1.0.3",
"version": "1.0.4-beta.1",
"type": "module",

@@ -69,2 +69,3 @@ "types": "./dist-utils/types/index.d.ts",

"husky": "^9.1.7",
"jsdom": "^26.1.0",
"lint-staged": "^15.4.3",

@@ -81,4 +82,3 @@ "playwright": "^1.51.0",

"vue": "^3.5.13",
"vue-tsc": "^2.2.0",
"@yqg/beetle": "workspace:*"
"vue-tsc": "^2.2.0"
},

@@ -85,0 +85,0 @@ "dependencies": {