@yqg/beetle
Advanced tools
| function e(t) { | ||
| return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; | ||
| } | ||
| export { | ||
| e as getDefaultExportFromCjs | ||
| }; |
| import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.mjs"; | ||
| import { __require as o } from "../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/dayjs.min.mjs"; | ||
| var t = o(); | ||
| const s = /* @__PURE__ */ r(t); | ||
| export { | ||
| s as default | ||
| }; |
| var a = { exports: {} }; | ||
| export { | ||
| a as __module | ||
| }; |
| import { __module as C } from "../../../../../_virtual/dayjs.min2.mjs"; | ||
| var G = C.exports, V; | ||
| function tt() { | ||
| return V ? C.exports : (V = 1, function(B, K) { | ||
| (function(A, k) { | ||
| B.exports = k(); | ||
| })(G, function() { | ||
| var A = 1e3, k = 6e4, q = 36e5, I = "millisecond", S = "second", w = "minute", _ = "hour", M = "day", T = "week", m = "month", F = "quarter", y = "year", O = "date", J = "Invalid Date", E = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, P = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, Q = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(i) { | ||
| var n = ["th", "st", "nd", "rd"], t = i % 100; | ||
| return "[" + i + (n[(t - 20) % 10] || n[t] || n[0]) + "]"; | ||
| } }, N = function(i, n, t) { | ||
| var r = String(i); | ||
| return !r || r.length >= n ? i : "" + Array(n + 1 - r.length).join(t) + i; | ||
| }, R = { s: N, z: function(i) { | ||
| var n = -i.utcOffset(), t = Math.abs(n), r = Math.floor(t / 60), e = t % 60; | ||
| return (n <= 0 ? "+" : "-") + N(r, 2, "0") + ":" + N(e, 2, "0"); | ||
| }, m: function i(n, t) { | ||
| if (n.date() < t.date()) return -i(t, n); | ||
| var r = 12 * (t.year() - n.year()) + (t.month() - n.month()), e = n.clone().add(r, m), s = t - e < 0, u = n.clone().add(r + (s ? -1 : 1), m); | ||
| return +(-(r + (t - e) / (s ? e - u : u - e)) || 0); | ||
| }, a: function(i) { | ||
| return i < 0 ? Math.ceil(i) || 0 : Math.floor(i); | ||
| }, p: function(i) { | ||
| return { M: m, y, w: T, d: M, D: O, h: _, m: w, s: S, ms: I, Q: F }[i] || String(i || "").toLowerCase().replace(/s$/, ""); | ||
| }, u: function(i) { | ||
| return i === void 0; | ||
| } }, x = "en", D = {}; | ||
| D[x] = Q; | ||
| var Z = "$isDayjsObject", U = function(i) { | ||
| return i instanceof L || !(!i || !i[Z]); | ||
| }, j = function i(n, t, r) { | ||
| var e; | ||
| if (!n) return x; | ||
| if (typeof n == "string") { | ||
| var s = n.toLowerCase(); | ||
| D[s] && (e = s), t && (D[s] = t, e = s); | ||
| var u = n.split("-"); | ||
| if (!e && u.length > 1) return i(u[0]); | ||
| } else { | ||
| var o = n.name; | ||
| D[o] = n, e = o; | ||
| } | ||
| return !r && e && (x = e), e || !r && x; | ||
| }, f = function(i, n) { | ||
| if (U(i)) return i.clone(); | ||
| var t = typeof n == "object" ? n : {}; | ||
| return t.date = i, t.args = arguments, new L(t); | ||
| }, a = R; | ||
| a.l = j, a.i = U, a.w = function(i, n) { | ||
| return f(i, { locale: n.$L, utc: n.$u, x: n.$x, $offset: n.$offset }); | ||
| }; | ||
| var L = function() { | ||
| function i(t) { | ||
| this.$L = j(t.locale, null, !0), this.parse(t), this.$x = this.$x || t.x || {}, this[Z] = !0; | ||
| } | ||
| var n = i.prototype; | ||
| return n.parse = function(t) { | ||
| this.$d = function(r) { | ||
| var e = r.date, s = r.utc; | ||
| if (e === null) return /* @__PURE__ */ new Date(NaN); | ||
| if (a.u(e)) return /* @__PURE__ */ new Date(); | ||
| if (e instanceof Date) return new Date(e); | ||
| if (typeof e == "string" && !/Z$/i.test(e)) { | ||
| var u = e.match(E); | ||
| if (u) { | ||
| var o = u[2] - 1 || 0, c = (u[7] || "0").substring(0, 3); | ||
| return s ? new Date(Date.UTC(u[1], o, u[3] || 1, u[4] || 0, u[5] || 0, u[6] || 0, c)) : new Date(u[1], o, u[3] || 1, u[4] || 0, u[5] || 0, u[6] || 0, c); | ||
| } | ||
| } | ||
| return new Date(e); | ||
| }(t), this.init(); | ||
| }, n.init = function() { | ||
| var t = this.$d; | ||
| this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds(); | ||
| }, n.$utils = function() { | ||
| return a; | ||
| }, n.isValid = function() { | ||
| return this.$d.toString() !== J; | ||
| }, n.isSame = function(t, r) { | ||
| var e = f(t); | ||
| return this.startOf(r) <= e && e <= this.endOf(r); | ||
| }, n.isAfter = function(t, r) { | ||
| return f(t) < this.startOf(r); | ||
| }, n.isBefore = function(t, r) { | ||
| return this.endOf(r) < f(t); | ||
| }, n.$g = function(t, r, e) { | ||
| return a.u(t) ? this[r] : this.set(e, t); | ||
| }, n.unix = function() { | ||
| return Math.floor(this.valueOf() / 1e3); | ||
| }, n.valueOf = function() { | ||
| return this.$d.getTime(); | ||
| }, n.startOf = function(t, r) { | ||
| var e = this, s = !!a.u(r) || r, u = a.p(t), o = function(p, $) { | ||
| var v = a.w(e.$u ? Date.UTC(e.$y, $, p) : new Date(e.$y, $, p), e); | ||
| return s ? v : v.endOf(M); | ||
| }, c = function(p, $) { | ||
| return a.w(e.toDate()[p].apply(e.toDate("s"), (s ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice($)), e); | ||
| }, h = this.$W, d = this.$M, l = this.$D, b = "set" + (this.$u ? "UTC" : ""); | ||
| switch (u) { | ||
| case y: | ||
| return s ? o(1, 0) : o(31, 11); | ||
| case m: | ||
| return s ? o(1, d) : o(0, d + 1); | ||
| case T: | ||
| var g = this.$locale().weekStart || 0, Y = (h < g ? h + 7 : h) - g; | ||
| return o(s ? l - Y : l + (6 - Y), d); | ||
| case M: | ||
| case O: | ||
| return c(b + "Hours", 0); | ||
| case _: | ||
| return c(b + "Minutes", 1); | ||
| case w: | ||
| return c(b + "Seconds", 2); | ||
| case S: | ||
| return c(b + "Milliseconds", 3); | ||
| default: | ||
| return this.clone(); | ||
| } | ||
| }, n.endOf = function(t) { | ||
| return this.startOf(t, !1); | ||
| }, n.$set = function(t, r) { | ||
| var e, s = a.p(t), u = "set" + (this.$u ? "UTC" : ""), o = (e = {}, e[M] = u + "Date", e[O] = u + "Date", e[m] = u + "Month", e[y] = u + "FullYear", e[_] = u + "Hours", e[w] = u + "Minutes", e[S] = u + "Seconds", e[I] = u + "Milliseconds", e)[s], c = s === M ? this.$D + (r - this.$W) : r; | ||
| if (s === m || s === y) { | ||
| var h = this.clone().set(O, 1); | ||
| h.$d[o](c), h.init(), this.$d = h.set(O, Math.min(this.$D, h.daysInMonth())).$d; | ||
| } else o && this.$d[o](c); | ||
| return this.init(), this; | ||
| }, n.set = function(t, r) { | ||
| return this.clone().$set(t, r); | ||
| }, n.get = function(t) { | ||
| return this[a.p(t)](); | ||
| }, n.add = function(t, r) { | ||
| var e, s = this; | ||
| t = Number(t); | ||
| var u = a.p(r), o = function(d) { | ||
| var l = f(s); | ||
| return a.w(l.date(l.date() + Math.round(d * t)), s); | ||
| }; | ||
| if (u === m) return this.set(m, this.$M + t); | ||
| if (u === y) return this.set(y, this.$y + t); | ||
| if (u === M) return o(1); | ||
| if (u === T) return o(7); | ||
| var c = (e = {}, e[w] = k, e[_] = q, e[S] = A, e)[u] || 1, h = this.$d.getTime() + t * c; | ||
| return a.w(h, this); | ||
| }, n.subtract = function(t, r) { | ||
| return this.add(-1 * t, r); | ||
| }, n.format = function(t) { | ||
| var r = this, e = this.$locale(); | ||
| if (!this.isValid()) return e.invalidDate || J; | ||
| var s = t || "YYYY-MM-DDTHH:mm:ssZ", u = a.z(this), o = this.$H, c = this.$m, h = this.$M, d = e.weekdays, l = e.months, b = e.meridiem, g = function($, v, H, W) { | ||
| return $ && ($[v] || $(r, s)) || H[v].slice(0, W); | ||
| }, Y = function($) { | ||
| return a.s(o % 12 || 12, $, "0"); | ||
| }, p = b || function($, v, H) { | ||
| var W = $ < 12 ? "AM" : "PM"; | ||
| return H ? W.toLowerCase() : W; | ||
| }; | ||
| return s.replace(P, function($, v) { | ||
| return v || function(H) { | ||
| switch (H) { | ||
| case "YY": | ||
| return String(r.$y).slice(-2); | ||
| case "YYYY": | ||
| return a.s(r.$y, 4, "0"); | ||
| case "M": | ||
| return h + 1; | ||
| case "MM": | ||
| return a.s(h + 1, 2, "0"); | ||
| case "MMM": | ||
| return g(e.monthsShort, h, l, 3); | ||
| case "MMMM": | ||
| return g(l, h); | ||
| case "D": | ||
| return r.$D; | ||
| case "DD": | ||
| return a.s(r.$D, 2, "0"); | ||
| case "d": | ||
| return String(r.$W); | ||
| case "dd": | ||
| return g(e.weekdaysMin, r.$W, d, 2); | ||
| case "ddd": | ||
| return g(e.weekdaysShort, r.$W, d, 3); | ||
| case "dddd": | ||
| return d[r.$W]; | ||
| case "H": | ||
| return String(o); | ||
| case "HH": | ||
| return a.s(o, 2, "0"); | ||
| case "h": | ||
| return Y(1); | ||
| case "hh": | ||
| return Y(2); | ||
| case "a": | ||
| return p(o, c, !0); | ||
| case "A": | ||
| return p(o, c, !1); | ||
| case "m": | ||
| return String(c); | ||
| case "mm": | ||
| return a.s(c, 2, "0"); | ||
| case "s": | ||
| return String(r.$s); | ||
| case "ss": | ||
| return a.s(r.$s, 2, "0"); | ||
| case "SSS": | ||
| return a.s(r.$ms, 3, "0"); | ||
| case "Z": | ||
| return u; | ||
| } | ||
| return null; | ||
| }($) || u.replace(":", ""); | ||
| }); | ||
| }, n.utcOffset = function() { | ||
| return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); | ||
| }, n.diff = function(t, r, e) { | ||
| var s, u = this, o = a.p(r), c = f(t), h = (c.utcOffset() - this.utcOffset()) * k, d = this - c, l = function() { | ||
| return a.m(u, c); | ||
| }; | ||
| switch (o) { | ||
| case y: | ||
| s = l() / 12; | ||
| break; | ||
| case m: | ||
| s = l(); | ||
| break; | ||
| case F: | ||
| s = l() / 3; | ||
| break; | ||
| case T: | ||
| s = (d - h) / 6048e5; | ||
| break; | ||
| case M: | ||
| s = (d - h) / 864e5; | ||
| break; | ||
| case _: | ||
| s = d / q; | ||
| break; | ||
| case w: | ||
| s = d / k; | ||
| break; | ||
| case S: | ||
| s = d / A; | ||
| break; | ||
| default: | ||
| s = d; | ||
| } | ||
| return e ? s : a.a(s); | ||
| }, n.daysInMonth = function() { | ||
| return this.endOf(m).$D; | ||
| }, n.$locale = function() { | ||
| return D[this.$L]; | ||
| }, n.locale = function(t, r) { | ||
| if (!t) return this.$L; | ||
| var e = this.clone(), s = j(t, r, !0); | ||
| return s && (e.$L = s), e; | ||
| }, n.clone = function() { | ||
| return a.w(this.$d, this); | ||
| }, n.toDate = function() { | ||
| return new Date(this.valueOf()); | ||
| }, n.toJSON = function() { | ||
| return this.isValid() ? this.toISOString() : null; | ||
| }, n.toISOString = function() { | ||
| return this.$d.toISOString(); | ||
| }, n.toString = function() { | ||
| return this.$d.toUTCString(); | ||
| }, i; | ||
| }(), z = L.prototype; | ||
| return f.prototype = z, [["$ms", I], ["$s", S], ["$m", w], ["$H", _], ["$W", M], ["$M", m], ["$y", y], ["$D", O]].forEach(function(i) { | ||
| z[i[1]] = function(n) { | ||
| return this.$g(n, i[0], i[1]); | ||
| }; | ||
| }), f.extend = function(i, n) { | ||
| return i.$i || (i(n, L, f), i.$i = !0), f; | ||
| }, f.locale = j, f.isDayjs = U, f.unix = function(i) { | ||
| return f(1e3 * i); | ||
| }, f.en = D[x], f.Ls = D, f.p = {}, f; | ||
| }); | ||
| }(C), C.exports); | ||
| } | ||
| export { | ||
| tt as __require | ||
| }; |
| /** | ||
| * 导出 dayjs | ||
| * | ||
| * 插件需要用户自行引入和注册,例如: | ||
| * import { dayjs } from '@yqg/beetle'; | ||
| * import utc from 'dayjs/plugin/utc'; | ||
| * import timezone from 'dayjs/plugin/timezone'; | ||
| * | ||
| * dayjs.extend(utc); | ||
| * dayjs.extend(timezone); | ||
| */ | ||
| export { default } from 'dayjs'; |
+18
-16
@@ -13,4 +13,4 @@ import r from "./data/arrayToTree/index.mjs"; | ||
| import g from "./url/removeQueryParam/index.mjs"; | ||
| import n from "./validate/isValidMobile/index.mjs"; | ||
| import y from "./validate/isValidPhone/index.mjs"; | ||
| import y from "./validate/isValidMobile/index.mjs"; | ||
| import n from "./validate/isValidPhone/index.mjs"; | ||
| import d from "./format/formatFileSize/index.mjs"; | ||
@@ -40,8 +40,9 @@ import T from "./format/maskNumber/index.mjs"; | ||
| import U from "./util/getUUID/index.mjs"; | ||
| import w from "./file/downloadFile/index.mjs"; | ||
| import z from "./file/getFileType/index.mjs"; | ||
| import B from "./util/operateEnv/index.mjs"; | ||
| import J from "./package.json.mjs"; | ||
| import * as M from "lodash-es"; | ||
| const Rr = { | ||
| import j from "./file/downloadFile/index.mjs"; | ||
| import w from "./file/getFileType/index.mjs"; | ||
| import z from "./util/operateEnv/index.mjs"; | ||
| import B from "./package.json.mjs"; | ||
| import * as J from "lodash-es"; | ||
| import M from "./_virtual/dayjs.min.mjs"; | ||
| const Fr = { | ||
| arrayToTree: r, | ||
@@ -58,4 +59,4 @@ treeToArray: o, | ||
| removeQueryParam: g, | ||
| isValidMobile: n, | ||
| isValidPhone: y, | ||
| isValidMobile: y, | ||
| isValidPhone: n, | ||
| formatFileSize: d, | ||
@@ -85,11 +86,12 @@ maskNumber: T, | ||
| getUUID: U, | ||
| downloadFile: w, | ||
| getFileType: z, | ||
| downloadFile: j, | ||
| getFileType: w, | ||
| isDeepEqual: p, | ||
| operateEnv: B, | ||
| ...M, | ||
| VERSION: J.version | ||
| operateEnv: z, | ||
| dayjs: M, | ||
| ...J, | ||
| VERSION: B.version | ||
| }; | ||
| export { | ||
| Rr as default | ||
| Fr as default | ||
| }; |
+14
-12
@@ -5,3 +5,3 @@ export * from "lodash-es"; | ||
| import { default as s } from "./data/traverseDeep/index.mjs"; | ||
| import { default as p } from "./data/mergeDeep/index.mjs"; | ||
| import { default as d } from "./data/mergeDeep/index.mjs"; | ||
| import { default as u } from "./data/parseJSON/index.mjs"; | ||
@@ -20,6 +20,6 @@ import { default as i } from "./data/stringifyJSON/index.mjs"; | ||
| import { default as R } from "./format/formatPercentage/index.mjs"; | ||
| import { default as w } from "./format/formatNumber/index.mjs"; | ||
| import { default as B } from "./format/formatCurrency/index.mjs"; | ||
| import { default as J } from "./util/copyToClipboard/index.mjs"; | ||
| import { default as j } from "./util/hexToRGB/index.mjs"; | ||
| import { default as j } from "./format/formatNumber/index.mjs"; | ||
| import { default as z } from "./format/formatCurrency/index.mjs"; | ||
| import { default as I } from "./util/copyToClipboard/index.mjs"; | ||
| import { default as M } from "./util/hexToRGB/index.mjs"; | ||
| import { default as G } from "./util/rgbToHex/index.mjs"; | ||
@@ -34,3 +34,3 @@ import { default as W } from "./util/imageToBase64/index.mjs"; | ||
| import { default as se } from "./date/formatSeconds/index.mjs"; | ||
| import { default as pe } from "./date/getDaysDiff/index.mjs"; | ||
| import { default as de } from "./date/getDaysDiff/index.mjs"; | ||
| import { default as ue } from "./date/getWeekDay/index.mjs"; | ||
@@ -47,10 +47,12 @@ import { default as ie } from "./date/getDaysInMonth/index.mjs"; | ||
| import { default as Fe } from "./beetle.mjs"; | ||
| import { default as Oe } from "./_virtual/dayjs.min.mjs"; | ||
| export { | ||
| o as arrayToTree, | ||
| J as copyToClipboard, | ||
| I as copyToClipboard, | ||
| Oe as dayjs, | ||
| Fe as default, | ||
| he as downloadFile, | ||
| B as formatCurrency, | ||
| z as formatCurrency, | ||
| F as formatFileSize, | ||
| w as formatNumber, | ||
| j as formatNumber, | ||
| R as formatPercentage, | ||
@@ -60,3 +62,3 @@ se as formatSeconds, | ||
| oe as getCookie, | ||
| pe as getDaysDiff, | ||
| de as getDaysDiff, | ||
| ie as getDaysInMonth, | ||
@@ -69,3 +71,3 @@ Ce as getFileType, | ||
| ue as getWeekDay, | ||
| j as hexToRGB, | ||
| M as hexToRGB, | ||
| W as imageToBase64, | ||
@@ -80,3 +82,3 @@ T as isDeepEqual, | ||
| O as maskNumber, | ||
| p as mergeDeep, | ||
| d as mergeDeep, | ||
| ve as operateEnv, | ||
@@ -83,0 +85,0 @@ u as parseJSON, |
@@ -1,2 +0,2 @@ | ||
| const e = "1.0.6", t = { | ||
| const e = "1.0.8-beta.0", t = { | ||
| version: e | ||
@@ -3,0 +3,0 @@ }; |
@@ -41,2 +41,3 @@ import { default as arrayToTree } from './data/arrayToTree/index'; | ||
| import { default as getFileType } from './file/getFileType/index'; | ||
| import { default as dayjs } from './builtin/dayjs/index'; | ||
| import * as lodash from 'lodash-es'; | ||
@@ -84,2 +85,3 @@ type BeetleExports = { | ||
| isDeepEqual: typeof isDeepEqual; | ||
| dayjs: typeof dayjs; | ||
| VERSION: string; | ||
@@ -86,0 +88,0 @@ }; |
@@ -9,2 +9,3 @@ /** | ||
| export * from 'lodash-es'; | ||
| export { default as dayjs } from './builtin/dayjs/index'; | ||
| export { default as arrayToTree } from './data/arrayToTree/index'; | ||
@@ -11,0 +12,0 @@ export { default as treeToArray } from './data/treeToArray/index'; |
@@ -1,10 +0,13 @@ | ||
| function c(n) { | ||
| function a(r) { | ||
| let t = !1; | ||
| return function(...r) { | ||
| return function(...l) { | ||
| if (t) return; | ||
| t = !0; | ||
| const e = n.apply(this, r); | ||
| return e.catch((l) => { | ||
| throw l; | ||
| }).finally(() => { | ||
| let e; | ||
| try { | ||
| e = r.apply(this, l); | ||
| } catch (n) { | ||
| throw t = !1, n; | ||
| } | ||
| return e.finally(() => { | ||
| t = !1; | ||
@@ -15,3 +18,3 @@ }), e; | ||
| export { | ||
| c as default | ||
| a as default | ||
| }; |
+5
-4
| { | ||
| "name": "@yqg/beetle", | ||
| "version": "1.0.7", | ||
| "version": "1.0.8-beta.0", | ||
| "type": "module", | ||
@@ -83,5 +83,6 @@ "types": "./dist-utils/types/index.d.ts", | ||
| "dependencies": { | ||
| "lodash-es": "^4.17.21", | ||
| "@types/lodash-es": "^4.17.12" | ||
| "@types/lodash-es": "^4.17.12", | ||
| "dayjs": "^1.11.19", | ||
| "lodash-es": "^4.17.21" | ||
| } | ||
| } | ||
| } |
+31
-3
| # 什么是 beetle | ||
| **beetle** 是一款现代化的前端函数工具库,旨在提升日常开发效率与项目一致性。它不仅内置了完整的 lodash-es 工具集,还结合了实际业务场景,集成多种高频使用的函数方法,帮助团队在高质量代码开发中减少重复造轮子。 | ||
| **beetle** 是一款现代化的前端函数工具库,旨在提升日常开发效率与项目一致性。它不仅内置了完整的 lodash-es、dayjs 工具集,还结合了实际业务场景,集成多种高频使用的函数方法,帮助团队在高质量代码开发中减少重复造轮子。 | ||
@@ -13,2 +13,5 @@ ## 特性 | ||
| - 📅 **内置 dayjs 日期处理库** | ||
| 轻量级日期处理库(仅 2KB),支持时区转换、相对时间、多语言等插件扩展,API 与 Moment.js 保持一致。 | ||
| - ⚙️ **融合业务场景的定制函数** | ||
@@ -72,4 +75,6 @@ 集成多个结合公司业务特点封装的高频函数,提升复用率,统一项目函数风格,减少重复工作。 | ||
| > **类型定义说明**: | ||
| > - **TypeScript 项目**:`@types/lodash-es` 已包含在 `@yqg/beetle` 的依赖中,安装 `@yqg/beetle` 时会自动安装,无需单独安装。可以直接使用所有 lodash 方法并获得完整的类型推断(如 `debounce`、`throttle`、`cloneDeep` 等)。 | ||
| > - **JavaScript 项目**:虽然 `@types/lodash-es` 会被安装,但不会影响运行时功能,可以直接使用所有 lodash 方法。 | ||
| > - **TypeScript 项目**: | ||
| > - `@types/lodash-es` 已包含在 `@yqg/beetle` 的依赖中,安装时会自动安装,无需单独安装。可以直接使用所有 lodash 方法并获得完整的类型推断。 | ||
| > - `dayjs` 自带 TypeScript 类型定义,无需额外安装。 | ||
| > - **JavaScript 项目**:可以直接使用所有 lodash 和 dayjs 方法。 | ||
@@ -96,3 +101,26 @@ ## 使用 | ||
| ### dayjs 使用 | ||
| ```ts | ||
| // 基础使用 | ||
| import { dayjs } from '@yqg/beetle'; | ||
| dayjs().format('YYYY-MM-DD HH:mm:ss'); | ||
| dayjs('2024-01-01').add(7, 'day').format('YYYY-MM-DD'); | ||
| // 使用插件(需自行引入) | ||
| import { dayjs } from '@yqg/beetle'; | ||
| import utc from 'dayjs/plugin/utc'; | ||
| import timezone from 'dayjs/plugin/timezone'; | ||
| import 'dayjs/locale/zh-cn'; | ||
| dayjs.extend(utc); | ||
| dayjs.extend(timezone); | ||
| dayjs.locale('zh-cn'); | ||
| // 时区转换 | ||
| dayjs().tz('America/New_York').format('YYYY-MM-DD HH:mm:ss'); | ||
| ``` | ||
| ## 问题反馈 | ||
| 在使用过程中发现任何问题、或者有改善建议,欢迎在 GitLub Issues 进行反馈:https://gitlab.yangqianguan.com/web/yqg-beetle/-/issues |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
78782
20.79%94
5.62%2072
18.47%124
29.17%3
50%2
100%+ Added
+ Added