sculp-js 1.19.1 → 1.19.3
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/cjs/array.cjs +1 -1
- package/dist/cjs/async.cjs +1 -1
- package/dist/cjs/base64.cjs +157 -71
- package/dist/cjs/clipboard.cjs +1 -1
- package/dist/cjs/cloneDeep.cjs +1 -1
- package/dist/cjs/cookie.cjs +1 -1
- package/dist/cjs/date.cjs +130 -70
- package/dist/cjs/dom.cjs +1 -1
- package/dist/cjs/download.cjs +1 -1
- package/dist/cjs/file.cjs +1 -1
- package/dist/cjs/func.cjs +1 -1
- package/dist/cjs/index.cjs +11 -3
- package/dist/cjs/isEqual.cjs +1 -1
- package/dist/cjs/math.cjs +1 -1
- package/dist/cjs/number.cjs +1 -1
- package/dist/cjs/object.cjs +1 -1
- package/dist/cjs/path.cjs +1 -1
- package/dist/cjs/qs.cjs +1 -1
- package/dist/cjs/random.cjs +1 -1
- package/dist/cjs/string.cjs +1 -1
- package/dist/cjs/tooltip.cjs +1 -1
- package/dist/cjs/tree.cjs +1 -1
- package/dist/cjs/type.cjs +71 -3
- package/dist/cjs/unicodeToolkit.cjs +19 -19
- package/dist/cjs/unique.cjs +1 -1
- package/dist/cjs/url.cjs +1 -1
- package/dist/cjs/validator.cjs +1 -1
- package/dist/cjs/variable.cjs +1 -1
- package/dist/cjs/watermark.cjs +1 -1
- package/dist/esm/array.mjs +1 -1
- package/dist/esm/async.mjs +1 -1
- package/dist/esm/base64.mjs +157 -71
- package/dist/esm/clipboard.mjs +1 -1
- package/dist/esm/cloneDeep.mjs +1 -1
- package/dist/esm/cookie.mjs +1 -1
- package/dist/esm/date.mjs +130 -78
- package/dist/esm/dom.mjs +1 -1
- package/dist/esm/download.mjs +1 -1
- package/dist/esm/file.mjs +1 -1
- package/dist/esm/func.mjs +1 -1
- package/dist/esm/index.mjs +11 -10
- package/dist/esm/isEqual.mjs +1 -1
- package/dist/esm/math.mjs +1 -1
- package/dist/esm/number.mjs +1 -1
- package/dist/esm/object.mjs +1 -1
- package/dist/esm/path.mjs +1 -1
- package/dist/esm/qs.mjs +1 -1
- package/dist/esm/random.mjs +1 -1
- package/dist/esm/string.mjs +1 -1
- package/dist/esm/tooltip.mjs +1 -1
- package/dist/esm/tree.mjs +1 -1
- package/dist/esm/type.mjs +71 -3
- package/dist/esm/unicodeToolkit.mjs +19 -19
- package/dist/esm/unique.mjs +1 -1
- package/dist/esm/url.mjs +1 -1
- package/dist/esm/validator.mjs +1 -1
- package/dist/esm/variable.mjs +1 -1
- package/dist/esm/watermark.mjs +1 -1
- package/dist/types/base64.d.ts +6 -6
- package/dist/types/date.d.ts +124 -28
- package/dist/types/type.d.ts +86 -3
- package/dist/umd/index.min.js +2 -2
- package/package.json +1 -1
package/dist/esm/date.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.19.
|
|
2
|
+
* sculp-js v1.19.3
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -111,19 +111,25 @@ function dateToEnd(value) {
|
|
|
111
111
|
return dateParse(d.getTime() - 1);
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
* 格式化为日期对象(带自定义格式化模板)
|
|
114
|
+
* 格式化为日期对象 (带自定义格式化模板)
|
|
115
115
|
* @param {Date} value - 可以是数值、字符串或 Date 对象
|
|
116
116
|
* @param {string} [format] - 模板,默认是 YYYY-MM-DD HH:mm:ss,模板字符:
|
|
117
|
-
* - YYYY:年
|
|
118
|
-
* -
|
|
119
|
-
* -
|
|
120
|
-
* - DD
|
|
121
|
-
* -
|
|
122
|
-
* - HH:时(24
|
|
123
|
-
* -
|
|
124
|
-
* -
|
|
125
|
-
* -
|
|
126
|
-
* -
|
|
117
|
+
* - YYYY/yyyy:年
|
|
118
|
+
* - MM:月(补零)
|
|
119
|
+
* - M:月(不补零)
|
|
120
|
+
* - DD/dd:日(补零)
|
|
121
|
+
* - D/d:日(不补零)
|
|
122
|
+
* - HH:时(24 小时制,补零)
|
|
123
|
+
* - H:时(24 小时制,不补零)
|
|
124
|
+
* - mm:分(补零)
|
|
125
|
+
* - m:分(不补零)
|
|
126
|
+
* - ss:秒(补零)
|
|
127
|
+
* - s:秒(不补零)
|
|
128
|
+
* - SSS:毫秒(3 位)
|
|
129
|
+
* - SS:毫秒(2 位)
|
|
130
|
+
* - S:毫秒(1 位)
|
|
131
|
+
* - ww:中文完整星期(如:周日)
|
|
132
|
+
* - w:中文星期(如:周日)
|
|
127
133
|
* @returns {string} 格式化后的日期字符串
|
|
128
134
|
*/
|
|
129
135
|
function formatDate(value, format = 'YYYY-MM-DD HH:mm:ss') {
|
|
@@ -152,61 +158,113 @@ function formatDate(value, format = 'YYYY-MM-DD HH:mm:ss') {
|
|
|
152
158
|
return fmt;
|
|
153
159
|
}
|
|
154
160
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @param {DateValue} originDate -
|
|
157
|
-
* @param {
|
|
158
|
-
* @
|
|
159
|
-
* @
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
161
|
+
* 调整日期(增加或减少特定时间单位)
|
|
162
|
+
* @param {DateValue} originDate - 参考日期,可以是 Date 对象、时间戳或日期字符串
|
|
163
|
+
* @param {CalculateDateOptions} options - 配置项,支持多种时间单位
|
|
164
|
+
* @returns {string | Date} 计算后的日期/日期时间字符串或 Date 对象
|
|
165
|
+
* @example
|
|
166
|
+
* // 基础用法(向后 2 天)
|
|
167
|
+
* adjustDate('2024-01-01', { days: 2 }) // '2024-01-03'
|
|
168
|
+
*
|
|
169
|
+
* // 向前 2 天
|
|
170
|
+
* adjustDate('2024-01-01', { days: -2 }) // '2023-12-30'
|
|
171
|
+
*
|
|
172
|
+
* // 向后 1 年 2 个月 3 天
|
|
173
|
+
* adjustDate('2024-01-01', { years: 1, months: 2, days: 3 }) // '2025-03-04'
|
|
174
|
+
*
|
|
175
|
+
* // 向后 2 周
|
|
176
|
+
* adjustDate('2024-01-01', { weeks: 2 }) // '2024-01-15'
|
|
177
|
+
*
|
|
178
|
+
* // 包含时间(向后 2 天 3 小时 30 分钟)
|
|
179
|
+
* adjustDate('2024-01-01 10:30:00', { days: 2, hours: 3, minutes: 30 }) // '2024-01-03 14:00'
|
|
180
|
+
*
|
|
181
|
+
* // 自定义格式
|
|
182
|
+
* adjustDate('2024-01-01', { days: 2, format: 'YYYY/MM/DD' }) // '2024/01/03'
|
|
183
|
+
* adjustDate('2024-01-01', { days: 2, format: 'YYYY 年 MM 月 DD 日' }) // '2024 年 01 月 03 日'
|
|
184
|
+
*
|
|
185
|
+
* // 时间戳输入
|
|
186
|
+
* adjustDate(1717330884896, { days: 2 }) // '2024-06-04'
|
|
187
|
+
*
|
|
188
|
+
* // 精确到毫秒
|
|
189
|
+
* adjustDate('2024-01-01 10:30:00', { hours: 1, minutes: 30, seconds: 45, milliseconds: 500 })
|
|
190
|
+
*
|
|
191
|
+
* // 返回 Date 对象
|
|
192
|
+
* adjustDate('2024-01-01', { days: 2, returnDate: true }) // Date 对象
|
|
182
193
|
*/
|
|
183
|
-
function
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
194
|
+
function adjustDate(originDate, options = {}) {
|
|
195
|
+
const {
|
|
196
|
+
format,
|
|
197
|
+
returnDate = false,
|
|
198
|
+
years = 0,
|
|
199
|
+
months = 0,
|
|
200
|
+
weeks = 0,
|
|
201
|
+
days = 0,
|
|
202
|
+
hours = 0,
|
|
203
|
+
minutes = 0,
|
|
204
|
+
seconds = 0,
|
|
205
|
+
milliseconds = 0
|
|
206
|
+
} = options;
|
|
207
|
+
const date = dateParse(originDate);
|
|
208
|
+
const targetDate = new Date(date);
|
|
209
|
+
// 保存原始日期以便处理月末边界
|
|
210
|
+
const originalDay = date.getDate();
|
|
211
|
+
const originalMonthDays = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
|
212
|
+
const isEndOfMonth = originalDay === originalMonthDays;
|
|
213
|
+
targetDate.setFullYear(targetDate.getFullYear() + years);
|
|
214
|
+
// 处理月末边界:如果原始日期是月末,需要特殊处理
|
|
215
|
+
if (months !== 0) {
|
|
216
|
+
const targetMonthIndex = targetDate.getMonth() + months;
|
|
217
|
+
const targetMonthDays = new Date(targetDate.getFullYear(), targetMonthIndex + 1, 0).getDate();
|
|
218
|
+
// 先将日期设为 1 号,避免 setMonth 时因日期过大而自动进位
|
|
219
|
+
targetDate.setDate(1);
|
|
220
|
+
targetDate.setMonth(targetMonthIndex);
|
|
221
|
+
// 如果原始日期是月末,则调整为目标月份的月末
|
|
222
|
+
if (isEndOfMonth) {
|
|
223
|
+
targetDate.setDate(targetMonthDays);
|
|
224
|
+
} else if (originalDay > targetMonthDays) {
|
|
225
|
+
// 如果原始日期大于目标月份的最大天数,也调整为目标月份的月末
|
|
226
|
+
targetDate.setDate(targetMonthDays);
|
|
227
|
+
} else {
|
|
228
|
+
// 否则保持原始日期
|
|
229
|
+
targetDate.setDate(originalDay);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// 处理天数(不包括月份变化)
|
|
233
|
+
if (days !== 0 || weeks !== 0) {
|
|
234
|
+
targetDate.setDate(targetDate.getDate() + days + weeks * 7);
|
|
235
|
+
}
|
|
236
|
+
targetDate.setHours(targetDate.getHours() + hours);
|
|
237
|
+
targetDate.setMinutes(targetDate.getMinutes() + minutes);
|
|
238
|
+
targetDate.setSeconds(targetDate.getSeconds() + seconds);
|
|
239
|
+
targetDate.setMilliseconds(targetDate.getMilliseconds() + milliseconds);
|
|
240
|
+
if (returnDate) {
|
|
241
|
+
return targetDate;
|
|
242
|
+
}
|
|
243
|
+
if (format) {
|
|
244
|
+
return formatDate(targetDate, format);
|
|
245
|
+
}
|
|
246
|
+
const year = targetDate.getFullYear();
|
|
247
|
+
const month = String(targetDate.getMonth() + 1).padStart(2, '0');
|
|
248
|
+
const day = String(targetDate.getDate()).padStart(2, '0');
|
|
249
|
+
const hoursStr = String(targetDate.getHours()).padStart(2, '0');
|
|
250
|
+
const minutesStr = String(targetDate.getMinutes()).padStart(2, '0');
|
|
251
|
+
const secondsStr = String(targetDate.getSeconds()).padStart(2, '0');
|
|
252
|
+
const hasTimeParam =
|
|
253
|
+
options.hasOwnProperty('hours') ||
|
|
254
|
+
options.hasOwnProperty('minutes') ||
|
|
255
|
+
options.hasOwnProperty('seconds') ||
|
|
256
|
+
options.hasOwnProperty('milliseconds');
|
|
257
|
+
if (hasTimeParam) {
|
|
258
|
+
if (options.hasOwnProperty('milliseconds')) {
|
|
259
|
+
const msStr = String(targetDate.getMilliseconds()).padStart(3, '0');
|
|
260
|
+
return `${year}-${month}-${day} ${hoursStr}:${minutesStr}:${secondsStr}.${msStr}`;
|
|
261
|
+
}
|
|
262
|
+
if (options.hasOwnProperty('seconds')) {
|
|
263
|
+
return `${year}-${month}-${day} ${hoursStr}:${minutesStr}:${secondsStr}`;
|
|
264
|
+
}
|
|
265
|
+
return `${year}-${month}-${day} ${hoursStr}:${minutesStr}`;
|
|
266
|
+
}
|
|
267
|
+
return `${year}-${month}-${day}`;
|
|
210
268
|
}
|
|
211
269
|
var date = {
|
|
212
270
|
isValidDate,
|
|
@@ -214,17 +272,11 @@ var date = {
|
|
|
214
272
|
dateToStart,
|
|
215
273
|
dateToEnd,
|
|
216
274
|
formatDate,
|
|
217
|
-
|
|
218
|
-
|
|
275
|
+
adjustDate,
|
|
276
|
+
/**
|
|
277
|
+
* @deprecated 已废弃,请使用 adjustDate
|
|
278
|
+
*/
|
|
279
|
+
calculateDate: adjustDate
|
|
219
280
|
};
|
|
220
281
|
|
|
221
|
-
export {
|
|
222
|
-
calculateDate,
|
|
223
|
-
calculateDateTime,
|
|
224
|
-
dateParse,
|
|
225
|
-
dateToEnd,
|
|
226
|
-
dateToStart,
|
|
227
|
-
date as default,
|
|
228
|
-
formatDate,
|
|
229
|
-
isValidDate
|
|
230
|
-
};
|
|
282
|
+
export { adjustDate, dateParse, dateToEnd, dateToStart, date as default, formatDate, isValidDate };
|
package/dist/esm/dom.mjs
CHANGED
package/dist/esm/download.mjs
CHANGED
package/dist/esm/file.mjs
CHANGED
package/dist/esm/func.mjs
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.19.
|
|
2
|
+
* sculp-js v1.19.3
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -11,15 +11,7 @@ export { copyText, fallbackCopyText } from './clipboard.mjs';
|
|
|
11
11
|
import * as cookie from './cookie.mjs';
|
|
12
12
|
export { cookieDel, cookieGet, cookieSet } from './cookie.mjs';
|
|
13
13
|
import * as date from './date.mjs';
|
|
14
|
-
export {
|
|
15
|
-
calculateDate,
|
|
16
|
-
calculateDateTime,
|
|
17
|
-
dateParse,
|
|
18
|
-
dateToEnd,
|
|
19
|
-
dateToStart,
|
|
20
|
-
formatDate,
|
|
21
|
-
isValidDate
|
|
22
|
-
} from './date.mjs';
|
|
14
|
+
export { adjustDate, dateParse, dateToEnd, dateToStart, formatDate, isValidDate } from './date.mjs';
|
|
23
15
|
import * as dom from './dom.mjs';
|
|
24
16
|
export {
|
|
25
17
|
addClass,
|
|
@@ -66,14 +58,20 @@ export {
|
|
|
66
58
|
import * as type from './type.mjs';
|
|
67
59
|
export {
|
|
68
60
|
arrayLike,
|
|
61
|
+
is,
|
|
62
|
+
isArguments,
|
|
69
63
|
isArray,
|
|
64
|
+
isArrayBuffer,
|
|
65
|
+
isAsyncFunction,
|
|
70
66
|
isBigInt,
|
|
71
67
|
isBoolean,
|
|
68
|
+
isDataView,
|
|
72
69
|
isDate,
|
|
73
70
|
isEmpty,
|
|
74
71
|
isError,
|
|
75
72
|
isFunction,
|
|
76
73
|
isJsonString,
|
|
74
|
+
isMap,
|
|
77
75
|
isNaN,
|
|
78
76
|
isNodeList,
|
|
79
77
|
isNull,
|
|
@@ -82,9 +80,12 @@ export {
|
|
|
82
80
|
isNumber,
|
|
83
81
|
isObject,
|
|
84
82
|
isPrimitive,
|
|
83
|
+
isPromise,
|
|
85
84
|
isRegExp,
|
|
85
|
+
isSet,
|
|
86
86
|
isString,
|
|
87
87
|
isSymbol,
|
|
88
|
+
isTypedArray,
|
|
88
89
|
isUndefined,
|
|
89
90
|
objectHas,
|
|
90
91
|
typeIs
|
package/dist/esm/isEqual.mjs
CHANGED
package/dist/esm/math.mjs
CHANGED
package/dist/esm/number.mjs
CHANGED
package/dist/esm/object.mjs
CHANGED
package/dist/esm/path.mjs
CHANGED
package/dist/esm/qs.mjs
CHANGED
package/dist/esm/random.mjs
CHANGED
package/dist/esm/string.mjs
CHANGED
package/dist/esm/tooltip.mjs
CHANGED
package/dist/esm/tree.mjs
CHANGED
package/dist/esm/type.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.19.
|
|
2
|
+
* sculp-js v1.19.3
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -28,17 +28,37 @@ function arrayLike(any) {
|
|
|
28
28
|
return objectHas(any, 'length');
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* 判断任意值的数据类型,检查非对象时不如typeof、instanceof的性能高
|
|
31
|
+
* 判断任意值的数据类型,检查非对象时不如 typeof、instanceof 的性能高
|
|
32
32
|
*
|
|
33
33
|
* 当检查类对象时是不可靠的,对象可以通过定义 Symbol.toStringTag 属性来更改检查结果
|
|
34
34
|
*
|
|
35
35
|
* 详见:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
|
|
36
36
|
* @param {unknown} any
|
|
37
|
-
* @returns
|
|
37
|
+
* @returns {TypeTag} 类型标签字符串
|
|
38
38
|
*/
|
|
39
39
|
function typeIs(any) {
|
|
40
40
|
return toString.call(any).slice(8, -1);
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* 判断值是否为指定类型(带类型守卫)
|
|
44
|
+
* @param {unknown} value - 要检查的值
|
|
45
|
+
* @param {TypeTag} type - 期望的类型
|
|
46
|
+
* @returns {boolean} 如果值是指定类型则返回 true
|
|
47
|
+
* @example
|
|
48
|
+
* is(value, 'String')
|
|
49
|
+
* is(value, 'Array')
|
|
50
|
+
* is(value, 'Date')
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // 使用类型守卫
|
|
54
|
+
* if (is(value, 'String')) {
|
|
55
|
+
* // value 在这里被推断为 string 类型
|
|
56
|
+
* console.log(value.toUpperCase());
|
|
57
|
+
* }
|
|
58
|
+
*/
|
|
59
|
+
function is(value, type) {
|
|
60
|
+
return typeIs(value) === type;
|
|
61
|
+
}
|
|
42
62
|
// 基本数据类型判断
|
|
43
63
|
const isString = any => typeof any === 'string';
|
|
44
64
|
const isBoolean = any => typeof any === 'boolean';
|
|
@@ -65,6 +85,34 @@ const isNaN = any => Number.isNaN(any);
|
|
|
65
85
|
const isDate = any => typeIs(any) === 'Date';
|
|
66
86
|
const isError = any => typeIs(any) === 'Error';
|
|
67
87
|
const isRegExp = any => typeIs(any) === 'RegExp';
|
|
88
|
+
const isPromise = any => typeIs(any) === 'Promise';
|
|
89
|
+
const isMap = any => typeIs(any) === 'Map';
|
|
90
|
+
const isSet = any => typeIs(any) === 'Set';
|
|
91
|
+
/**
|
|
92
|
+
* 判断是否为 TypedArray
|
|
93
|
+
* @param {unknown} any
|
|
94
|
+
* @returns {boolean}
|
|
95
|
+
*/
|
|
96
|
+
const isTypedArray = any => {
|
|
97
|
+
const tag = typeIs(any);
|
|
98
|
+
return (
|
|
99
|
+
tag === 'Int8Array' ||
|
|
100
|
+
tag === 'Uint8Array' ||
|
|
101
|
+
tag === 'Uint8ClampedArray' ||
|
|
102
|
+
tag === 'Int16Array' ||
|
|
103
|
+
tag === 'Uint16Array' ||
|
|
104
|
+
tag === 'Int32Array' ||
|
|
105
|
+
tag === 'Uint32Array' ||
|
|
106
|
+
tag === 'Float32Array' ||
|
|
107
|
+
tag === 'Float64Array' ||
|
|
108
|
+
tag === 'BigInt64Array' ||
|
|
109
|
+
tag === 'BigUint64Array'
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
const isDataView = any => typeIs(any) === 'DataView';
|
|
113
|
+
const isArrayBuffer = any => typeIs(any) === 'ArrayBuffer';
|
|
114
|
+
const isArguments = any => typeIs(any) === 'Arguments';
|
|
115
|
+
const isAsyncFunction = any => typeIs(any) === 'AsyncFunction';
|
|
68
116
|
/**
|
|
69
117
|
* 判断一个字符串是否为有效的 JSON, 若有效则返回有效的JSON对象,否则false
|
|
70
118
|
* @param {string} str
|
|
@@ -128,6 +176,9 @@ function isNodeList(value) {
|
|
|
128
176
|
}
|
|
129
177
|
var type = {
|
|
130
178
|
typeIs,
|
|
179
|
+
is,
|
|
180
|
+
TypeMapping: undefined,
|
|
181
|
+
TypeTag: undefined,
|
|
131
182
|
objectHas,
|
|
132
183
|
arrayLike,
|
|
133
184
|
isString,
|
|
@@ -147,6 +198,14 @@ var type = {
|
|
|
147
198
|
isDate,
|
|
148
199
|
isError,
|
|
149
200
|
isRegExp,
|
|
201
|
+
isPromise,
|
|
202
|
+
isMap,
|
|
203
|
+
isSet,
|
|
204
|
+
isTypedArray,
|
|
205
|
+
isDataView,
|
|
206
|
+
isArrayBuffer,
|
|
207
|
+
isArguments,
|
|
208
|
+
isAsyncFunction,
|
|
150
209
|
isJsonString,
|
|
151
210
|
isEmpty,
|
|
152
211
|
isNodeList
|
|
@@ -155,14 +214,20 @@ var type = {
|
|
|
155
214
|
export {
|
|
156
215
|
arrayLike,
|
|
157
216
|
type as default,
|
|
217
|
+
is,
|
|
218
|
+
isArguments,
|
|
158
219
|
isArray,
|
|
220
|
+
isArrayBuffer,
|
|
221
|
+
isAsyncFunction,
|
|
159
222
|
isBigInt,
|
|
160
223
|
isBoolean,
|
|
224
|
+
isDataView,
|
|
161
225
|
isDate,
|
|
162
226
|
isEmpty,
|
|
163
227
|
isError,
|
|
164
228
|
isFunction,
|
|
165
229
|
isJsonString,
|
|
230
|
+
isMap,
|
|
166
231
|
isNaN,
|
|
167
232
|
isNodeList,
|
|
168
233
|
isNull,
|
|
@@ -171,9 +236,12 @@ export {
|
|
|
171
236
|
isNumber,
|
|
172
237
|
isObject,
|
|
173
238
|
isPrimitive,
|
|
239
|
+
isPromise,
|
|
174
240
|
isRegExp,
|
|
241
|
+
isSet,
|
|
175
242
|
isString,
|
|
176
243
|
isSymbol,
|
|
244
|
+
isTypedArray,
|
|
177
245
|
isUndefined,
|
|
178
246
|
objectHas,
|
|
179
247
|
typeIs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* sculp-js v1.19.
|
|
2
|
+
* sculp-js v1.19.3
|
|
3
3
|
* (c) 2023-present chandq
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -8,24 +8,6 @@
|
|
|
8
8
|
* 增强型 Unicode/HTML/UTF-8 编码解码工具
|
|
9
9
|
*/
|
|
10
10
|
class UnicodeToolkit {
|
|
11
|
-
// 基础 HTML 实体映射
|
|
12
|
-
static ENTITY_MAP = {
|
|
13
|
-
'&': '&',
|
|
14
|
-
'<': '<',
|
|
15
|
-
'>': '>',
|
|
16
|
-
'"': '"',
|
|
17
|
-
"'": '''
|
|
18
|
-
};
|
|
19
|
-
static NAMED_ENTITIES = {
|
|
20
|
-
'"': '"',
|
|
21
|
-
'&': '&',
|
|
22
|
-
'<': '<',
|
|
23
|
-
'>': '>',
|
|
24
|
-
' ': '\u00A0',
|
|
25
|
-
'©': '©',
|
|
26
|
-
'™': '™',
|
|
27
|
-
'®': '®'
|
|
28
|
-
};
|
|
29
11
|
/**
|
|
30
12
|
* 编码函数
|
|
31
13
|
* @param {string} str 原始字符串
|
|
@@ -113,6 +95,24 @@ class UnicodeToolkit {
|
|
|
113
95
|
return decoded;
|
|
114
96
|
}
|
|
115
97
|
}
|
|
98
|
+
// 基础 HTML 实体映射
|
|
99
|
+
UnicodeToolkit.ENTITY_MAP = {
|
|
100
|
+
'&': '&',
|
|
101
|
+
'<': '<',
|
|
102
|
+
'>': '>',
|
|
103
|
+
'"': '"',
|
|
104
|
+
"'": '''
|
|
105
|
+
};
|
|
106
|
+
UnicodeToolkit.NAMED_ENTITIES = {
|
|
107
|
+
'"': '"',
|
|
108
|
+
'&': '&',
|
|
109
|
+
'<': '<',
|
|
110
|
+
'>': '>',
|
|
111
|
+
' ': '\u00A0',
|
|
112
|
+
'©': '©',
|
|
113
|
+
'™': '™',
|
|
114
|
+
'®': '®'
|
|
115
|
+
};
|
|
116
116
|
var unicodeToolkit = {
|
|
117
117
|
UnicodeToolkit
|
|
118
118
|
};
|
package/dist/esm/unique.mjs
CHANGED
package/dist/esm/url.mjs
CHANGED
package/dist/esm/validator.mjs
CHANGED
package/dist/esm/variable.mjs
CHANGED
package/dist/esm/watermark.mjs
CHANGED
package/dist/types/base64.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 字符串编码成Base64
|
|
2
|
+
* 字符串编码成 Base64(适用于任何环境,包括小程序)
|
|
3
3
|
* @param {string} string
|
|
4
4
|
* @returns {string}
|
|
5
5
|
*/
|
|
6
6
|
export declare function weBtoa(string: string): string;
|
|
7
7
|
/**
|
|
8
|
-
* Base64
|
|
8
|
+
* Base64 解码为原始字符串(适用于任何环境,包括小程序)
|
|
9
9
|
* @param {string} string
|
|
10
10
|
* @returns {string}
|
|
11
11
|
*/
|
|
12
12
|
export declare function weAtob(string: string): string;
|
|
13
13
|
/**
|
|
14
|
-
* 将base64编码的字符串转换为原始字符串,包括对中文内容的处理(高性能,且支持Web、Node、小程序等任意平台)
|
|
15
|
-
* @param base64 base64编码的字符串
|
|
14
|
+
* 将 base64 编码的字符串转换为原始字符串,包括对中文内容的处理 (高性能,且支持 Web、Node、小程序等任意平台)
|
|
15
|
+
* @param base64 base64 编码的字符串
|
|
16
16
|
* @returns 原始字符串,包括中文内容
|
|
17
17
|
*/
|
|
18
18
|
export declare function b64decode(base64: string): string;
|
|
19
19
|
/**
|
|
20
|
-
* 将原始字符串,包括中文内容,转换为base64编码的字符串(高性能,且支持Web、Node、小程序等任意平台)
|
|
20
|
+
* 将原始字符串,包括中文内容,转换为 base64 编码的字符串 (高性能,且支持 Web、Node、小程序等任意平台)
|
|
21
21
|
* @param rawStr 原始字符串,包括中文内容
|
|
22
|
-
* @returns base64编码的字符串
|
|
22
|
+
* @returns base64 编码的字符串
|
|
23
23
|
*/
|
|
24
24
|
export declare function b64encode(rawStr: string): string;
|
|
25
25
|
declare const _default: {
|