@sybz-components/utils 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/base.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  require('vue');
4
4
  require('consola');
5
5
  require('es-toolkit');
6
- const format = require('./shared/utils.aC91nrkh.cjs');
6
+ const format = require('./shared/utils.q3_d_9Nx.cjs');
7
7
  require('element-plus');
8
8
  require('./is.cjs');
9
9
 
package/dist/base.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'vue';
2
2
  import 'consola';
3
3
  import 'es-toolkit';
4
- export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.BEyMaMZg.mjs';
4
+ export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.C6HkWKyE.mjs';
5
5
  import 'element-plus';
6
6
  import './is.mjs';
package/dist/format.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.aC91nrkh.cjs');
3
+ const format = require('./shared/utils.q3_d_9Nx.cjs');
4
4
  require('./is.cjs');
5
5
  require('consola');
6
6
  require('vue');
@@ -12,7 +12,6 @@ require('element-plus');
12
12
  exports.formatBytes = format.formatBytes;
13
13
  exports.formatBytesConvert = format.formatBytesConvert;
14
14
  exports.formatDurationTime = format.formatDurationTime;
15
- exports.formatImg = format.formatImg;
16
15
  exports.formatTextToHtml = format.formatTextToHtml;
17
16
  exports.formatThousands = format.formatThousands;
18
17
  exports.formatTime = format.formatTime;
package/dist/format.d.cts CHANGED
@@ -36,15 +36,6 @@ interface FormatBytesConvertOptions {
36
36
  */
37
37
  digit?: number;
38
38
  }
39
- /**
40
- * `formatImg` 的配置项。
41
- */
42
- interface FormatImgOptions {
43
- /**
44
- * 静态资源根目录,默认 `assets/images`。
45
- */
46
- basePath?: string;
47
- }
48
39
  /**
49
40
  * `formatToFixed` 的配置项。
50
41
  */
@@ -160,21 +151,6 @@ declare function formatTime(time?: FormatTimeInput, cFormat?: string, fallback?:
160
151
  * // => '05分00秒'
161
152
  */
162
153
  declare function formatDurationTime(timestamp: number, cFormat?: string): string;
163
- /**
164
- * 获取 `assets` 目录下的静态资源地址。
165
- *
166
- * @param photoName 文件名;未带后缀时会自动补 `.png`。
167
- * @param addPath 额外子目录,例如 `menu`。
168
- * @param options 配置项。
169
- * @returns 静态资源的完整 URL;如果本身已是 `http/https` 地址,则原样返回。
170
- *
171
- * @example
172
- * formatImg('logo')
173
- *
174
- * @example
175
- * formatImg('avatar.png', 'user')
176
- */
177
- declare function formatImg(photoName: string, addPath?: string, { basePath }?: FormatImgOptions): string;
178
154
  /**
179
155
  * 按指定小数位格式化数字,并可附带前后缀、单位和千分位。
180
156
  *
@@ -204,5 +180,5 @@ declare function formatToFixed(value: unknown, options?: FormatToFixedOptions |
204
180
  declare function formatTextToHtml(str: string): string;
205
181
  declare function formatTextToHtml<T>(str: T): T;
206
182
 
207
- export { formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed };
208
- export type { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
183
+ export { formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed };
184
+ export type { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
package/dist/format.d.mts CHANGED
@@ -36,15 +36,6 @@ interface FormatBytesConvertOptions {
36
36
  */
37
37
  digit?: number;
38
38
  }
39
- /**
40
- * `formatImg` 的配置项。
41
- */
42
- interface FormatImgOptions {
43
- /**
44
- * 静态资源根目录,默认 `assets/images`。
45
- */
46
- basePath?: string;
47
- }
48
39
  /**
49
40
  * `formatToFixed` 的配置项。
50
41
  */
@@ -160,21 +151,6 @@ declare function formatTime(time?: FormatTimeInput, cFormat?: string, fallback?:
160
151
  * // => '05分00秒'
161
152
  */
162
153
  declare function formatDurationTime(timestamp: number, cFormat?: string): string;
163
- /**
164
- * 获取 `assets` 目录下的静态资源地址。
165
- *
166
- * @param photoName 文件名;未带后缀时会自动补 `.png`。
167
- * @param addPath 额外子目录,例如 `menu`。
168
- * @param options 配置项。
169
- * @returns 静态资源的完整 URL;如果本身已是 `http/https` 地址,则原样返回。
170
- *
171
- * @example
172
- * formatImg('logo')
173
- *
174
- * @example
175
- * formatImg('avatar.png', 'user')
176
- */
177
- declare function formatImg(photoName: string, addPath?: string, { basePath }?: FormatImgOptions): string;
178
154
  /**
179
155
  * 按指定小数位格式化数字,并可附带前后缀、单位和千分位。
180
156
  *
@@ -204,5 +180,5 @@ declare function formatToFixed(value: unknown, options?: FormatToFixedOptions |
204
180
  declare function formatTextToHtml(str: string): string;
205
181
  declare function formatTextToHtml<T>(str: T): T;
206
182
 
207
- export { formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed };
208
- export type { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
183
+ export { formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed };
184
+ export type { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
package/dist/format.d.ts CHANGED
@@ -36,15 +36,6 @@ interface FormatBytesConvertOptions {
36
36
  */
37
37
  digit?: number;
38
38
  }
39
- /**
40
- * `formatImg` 的配置项。
41
- */
42
- interface FormatImgOptions {
43
- /**
44
- * 静态资源根目录,默认 `assets/images`。
45
- */
46
- basePath?: string;
47
- }
48
39
  /**
49
40
  * `formatToFixed` 的配置项。
50
41
  */
@@ -160,21 +151,6 @@ declare function formatTime(time?: FormatTimeInput, cFormat?: string, fallback?:
160
151
  * // => '05分00秒'
161
152
  */
162
153
  declare function formatDurationTime(timestamp: number, cFormat?: string): string;
163
- /**
164
- * 获取 `assets` 目录下的静态资源地址。
165
- *
166
- * @param photoName 文件名;未带后缀时会自动补 `.png`。
167
- * @param addPath 额外子目录,例如 `menu`。
168
- * @param options 配置项。
169
- * @returns 静态资源的完整 URL;如果本身已是 `http/https` 地址,则原样返回。
170
- *
171
- * @example
172
- * formatImg('logo')
173
- *
174
- * @example
175
- * formatImg('avatar.png', 'user')
176
- */
177
- declare function formatImg(photoName: string, addPath?: string, { basePath }?: FormatImgOptions): string;
178
154
  /**
179
155
  * 按指定小数位格式化数字,并可附带前后缀、单位和千分位。
180
156
  *
@@ -204,5 +180,5 @@ declare function formatToFixed(value: unknown, options?: FormatToFixedOptions |
204
180
  declare function formatTextToHtml(str: string): string;
205
181
  declare function formatTextToHtml<T>(str: T): T;
206
182
 
207
- export { formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed };
208
- export type { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
183
+ export { formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed };
184
+ export type { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
package/dist/format.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.BEyMaMZg.mjs';
1
+ export { y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatTextToHtml, C as formatThousands, D as formatTime, E as formatToFixed } from './shared/utils.C6HkWKyE.mjs';
2
2
  import './is.mjs';
3
3
  import 'consola';
4
4
  import 'vue';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.aC91nrkh.cjs');
3
+ const format = require('./shared/utils.q3_d_9Nx.cjs');
4
4
  const is = require('./is.cjs');
5
5
  require('vue');
6
6
  require('consola');
@@ -19,7 +19,6 @@ exports.delay = format.delay;
19
19
  exports.formatBytes = format.formatBytes;
20
20
  exports.formatBytesConvert = format.formatBytesConvert;
21
21
  exports.formatDurationTime = format.formatDurationTime;
22
- exports.formatImg = format.formatImg;
23
22
  exports.formatTextToHtml = format.formatTextToHtml;
24
23
  exports.formatThousands = format.formatThousands;
25
24
  exports.formatTime = format.formatTime;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateOnSubmit } from './base.cjs';
2
2
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.cjs';
3
- export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.cjs';
3
+ export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.cjs';
4
4
  import 'element-plus';
5
5
  import 'vue';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateOnSubmit } from './base.mjs';
2
2
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
3
- export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.mjs';
3
+ export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.mjs';
4
4
  import 'element-plus';
5
5
  import 'vue';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateOnSubmit } from './base.js';
2
2
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.js';
3
- export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.js';
3
+ export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.js';
4
4
  import 'element-plus';
5
5
  import 'vue';
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.BEyMaMZg.mjs';
1
+ export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatTextToHtml, C as formatThousands, D as formatTime, E as formatToFixed, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.C6HkWKyE.mjs';
2
2
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
3
3
  import 'vue';
4
4
  import 'consola';
@@ -177,18 +177,6 @@ function formatDurationTime(timestamp, cFormat = "{d}\u5929{h}\u65F6{i}\u5206{s}
177
177
  return String(value || "00");
178
178
  });
179
179
  }
180
- function formatImg(photoName, addPath = "", { basePath = "assets/images" } = {}) {
181
- if (photoName.startsWith("http") || photoName.startsWith("https")) {
182
- return photoName;
183
- }
184
- if (photoName.indexOf(".") === -1) {
185
- photoName = photoName + ".png";
186
- }
187
- const addLastSlash = addPath.endsWith("/") || !addPath ? addPath : `${addPath}/`;
188
- const addLastBasePathSlash = basePath.endsWith("/") || !basePath ? basePath : `${basePath}/`;
189
- const mergeSrc = `${addLastSlash}${photoName}`;
190
- return new URL(`../${addLastBasePathSlash}${mergeSrc}`, import.meta.url).href;
191
- }
192
180
  function formatToFixed(value, options) {
193
181
  if (typeof options === "number") {
194
182
  options = { digit: options };
@@ -847,8 +835,9 @@ function throttle(fn, delay2 = 1e3, options = {}, resultCallback) {
847
835
  const context = lastThis;
848
836
  lastArgs = void 0;
849
837
  lastThis = void 0;
850
- result = fn.apply(context, args);
851
- resultCallback?.(result);
838
+ const nextResult = fn.apply(context, args);
839
+ result = nextResult;
840
+ resultCallback?.(nextResult);
852
841
  return result;
853
842
  };
854
843
  const flush = () => {
@@ -1044,11 +1033,11 @@ function getVariable(propertyName, fallback = "") {
1044
1033
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1045
1034
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1046
1035
  {
1047
- return "2026-07-08 15:30:00";
1036
+ return "2026-07-10 15:30:17";
1048
1037
  }
1049
1038
  }
1050
1039
  function test() {
1051
1040
  return `build time: ${getUtilsBuildTime()}`;
1052
1041
  }
1053
1042
 
1054
- export { $toast as $, formatDurationTime as A, formatImg as B, formatTextToHtml as C, formatThousands as D, formatTime as E, formatToFixed as F, clone as a, confirm as b, clearStorage as c, copy as d, debounce as e, delay as f, getStorage as g, getType as h, getUtilsBuildTime as i, getVariable as j, isEmpty as k, log as l, merge as m, mockValue as n, throttle as o, processWidth as p, toLine as q, random as r, setStorage as s, test as t, tryCatch as u, validate as v, validateForm as w, validateOnSubmit as x, formatBytes as y, formatBytesConvert as z };
1043
+ export { $toast as $, formatDurationTime as A, formatTextToHtml as B, formatThousands as C, formatTime as D, formatToFixed as E, clone as a, confirm as b, clearStorage as c, copy as d, debounce as e, delay as f, getStorage as g, getType as h, getUtilsBuildTime as i, getVariable as j, isEmpty as k, log as l, merge as m, mockValue as n, throttle as o, processWidth as p, toLine as q, random as r, setStorage as s, test as t, tryCatch as u, validate as v, validateForm as w, validateOnSubmit as x, formatBytes as y, formatBytesConvert as z };
@@ -6,7 +6,6 @@ const esToolkit = require('es-toolkit');
6
6
  const elementPlus = require('element-plus');
7
7
  const is = require('../is.cjs');
8
8
 
9
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
9
  function formatBytes(bytes, options = {}) {
11
10
  let { digit = 2, thousands = false, prefix = "", suffix = "", roundType = "floor" } = options;
12
11
  if (is.isStringNumber(bytes) || is.isNumber(bytes)) {
@@ -180,18 +179,6 @@ function formatDurationTime(timestamp, cFormat = "{d}\u5929{h}\u65F6{i}\u5206{s}
180
179
  return String(value || "00");
181
180
  });
182
181
  }
183
- function formatImg(photoName, addPath = "", { basePath = "assets/images" } = {}) {
184
- if (photoName.startsWith("http") || photoName.startsWith("https")) {
185
- return photoName;
186
- }
187
- if (photoName.indexOf(".") === -1) {
188
- photoName = photoName + ".png";
189
- }
190
- const addLastSlash = addPath.endsWith("/") || !addPath ? addPath : `${addPath}/`;
191
- const addLastBasePathSlash = basePath.endsWith("/") || !basePath ? basePath : `${basePath}/`;
192
- const mergeSrc = `${addLastSlash}${photoName}`;
193
- return new URL(`../${addLastBasePathSlash}${mergeSrc}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/utils.aC91nrkh.cjs', document.baseURI).href))).href;
194
- }
195
182
  function formatToFixed(value, options) {
196
183
  if (typeof options === "number") {
197
184
  options = { digit: options };
@@ -850,8 +837,9 @@ function throttle(fn, delay2 = 1e3, options = {}, resultCallback) {
850
837
  const context = lastThis;
851
838
  lastArgs = void 0;
852
839
  lastThis = void 0;
853
- result = fn.apply(context, args);
854
- resultCallback?.(result);
840
+ const nextResult = fn.apply(context, args);
841
+ result = nextResult;
842
+ resultCallback?.(nextResult);
855
843
  return result;
856
844
  };
857
845
  const flush = () => {
@@ -1047,7 +1035,7 @@ function getVariable(propertyName, fallback = "") {
1047
1035
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1048
1036
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1049
1037
  {
1050
- return "2026-07-08 15:30:00";
1038
+ return "2026-07-10 15:30:17";
1051
1039
  }
1052
1040
  }
1053
1041
  function test() {
@@ -1064,7 +1052,6 @@ exports.delay = delay;
1064
1052
  exports.formatBytes = formatBytes;
1065
1053
  exports.formatBytesConvert = formatBytesConvert;
1066
1054
  exports.formatDurationTime = formatDurationTime;
1067
- exports.formatImg = formatImg;
1068
1055
  exports.formatTextToHtml = formatTextToHtml;
1069
1056
  exports.formatThousands = formatThousands;
1070
1057
  exports.formatTime = formatTime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybz-components/utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "utils of sybz-components",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -16,10 +16,11 @@
16
16
  },
17
17
  "scripts": {
18
18
  "build": "npx unbuild",
19
+ "typecheck": "tsc --noEmit -p tsconfig.json",
20
+ "test": "vitest run --root ../.. packages/utils/src",
19
21
  "stub": "npx unbuild --stub",
20
22
  "releaseOld": "npx unbuild && npm version patch && git add . && git commit -m \"chore: release @sybz-components/utils v$(npm pkg get version | sed 's/\"//g')\" && git push origin && npm publish",
21
- "release": "node ./scripts/release.mjs",
22
- "release:skip": "node ./scripts/release.mjs --skip-version-bump"
23
+ "release": "node ./scripts/release.mjs"
23
24
  },
24
25
  "author": "",
25
26
  "dependencies": {