@antsoo-lib/utils 0.0.1 → 0.1.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/index.d.ts CHANGED
@@ -84,4 +84,322 @@ declare function removeCookie(name: string, path?: string, domain?: string): voi
84
84
  */
85
85
  declare function hasCookie(name: string): boolean;
86
86
 
87
- export { addFn, computeGoodsNumFn, computeGoodsWeightFn, computeNoTaxAmount2Fn, computeNoTaxAmountFn, computeNoTaxPrice2Fn, computeNoTaxPriceFn, computePrice2Fn, computePriceFn, computeTaxAmount2Fn, computeTaxAmountFn, computeTaxFn, computeTaxRateFn, computeWeightFn, divideFn, formatNumber, getCookie, hasCookie, isSameOrAfterDay, isSameOrBeforeDay, multiplyFn, removeCookie, setCookie, subtractFn, sumBy, toThousands };
87
+ type AnyFunction = (...args: any[]) => any;
88
+ type Primitive = string | number | boolean | symbol | bigint | null | undefined;
89
+ /**
90
+ * 检查是否为数组 - 使用 lodash-es 的实现
91
+ */
92
+ declare const isArray: (value: unknown) => value is any[];
93
+ /**
94
+ * 检查是否为 ArrayBuffer
95
+ */
96
+ declare const isArrayBuffer: (value: unknown) => value is ArrayBuffer;
97
+ /**
98
+ * 检查是否为 AsyncFunction
99
+ */
100
+ declare function isAsyncFunction(value: unknown): value is AnyFunction;
101
+ /**
102
+ * 检查是否为 BigInt
103
+ */
104
+ declare function isBigInt(value: unknown): value is bigint;
105
+ /**
106
+ * 检查是否为 Blob 对象(浏览器环境)
107
+ */
108
+ declare function isBlob(value: unknown): value is Blob;
109
+ /**
110
+ * 检查是否为布尔值 - 使用 lodash-es 的实现
111
+ */
112
+ declare const isBoolean: (value: unknown) => value is boolean;
113
+ /**
114
+ * 检查是否为类数组
115
+ */
116
+ declare const isArrayLike: (value: unknown) => boolean;
117
+ /**
118
+ * 检查是否为类数组对象
119
+ */
120
+ declare const isArrayLikeObject: (value: unknown) => boolean;
121
+ /**
122
+ * 检查是否为类数组参数
123
+ */
124
+ declare const isArguments: (value: unknown) => boolean;
125
+ /**
126
+ * 检查是否为 Date 对象 - 使用 lodash-es 的实现
127
+ */
128
+ declare const isDate: (value: unknown) => value is Date;
129
+ /**
130
+ * 检查是否为 DOM 元素 - 使用 lodash-es 的实现
131
+ */
132
+ declare const isElement: (value: unknown) => boolean;
133
+ /**
134
+ * 检查是否为空值 - 使用 lodash-es 的实现
135
+ */
136
+ declare const isEmpty: (value: unknown) => boolean;
137
+ /**
138
+ * 检查是否严格相等 - 使用 lodash-es 的实现
139
+ */
140
+ declare const isEqual: (value: unknown, other: unknown) => boolean;
141
+ /**
142
+ * 检查是否为 Error 对象 - 使用 lodash-es 的实现
143
+ */
144
+ declare const isError: (value: unknown) => value is Error;
145
+ /**
146
+ * 检查是否为 File 对象(浏览器环境)
147
+ */
148
+ declare function isFile(value: unknown): value is File;
149
+ /**
150
+ * 检查是否为 FormData 对象(浏览器环境)
151
+ */
152
+ declare function isFormData(value: unknown): value is FormData;
153
+ /**
154
+ * 检查是否为函数 - 使用 lodash-es 的实现
155
+ */
156
+ declare const isFunction: (value: unknown) => value is AnyFunction;
157
+ /**
158
+ * 检查是否为 GeneratorFunction
159
+ */
160
+ declare function isGeneratorFunction(value: unknown): value is GeneratorFunction;
161
+ /**
162
+ * 检查是否为整数 - 使用 lodash-es 的实现
163
+ */
164
+ declare const isInteger: (value: unknown) => boolean;
165
+ /**
166
+ * 检查是否为有限数 - 使用 lodash-es 的实现
167
+ */
168
+ declare const isFinite: (value: unknown) => boolean;
169
+ /**
170
+ * 检查是否为有效长度 - 使用 lodash-es 的实现
171
+ */
172
+ declare const isLength: (value: unknown) => boolean;
173
+ /**
174
+ * 检查是否为 Map - 使用 lodash-es 的实现
175
+ */
176
+ declare const isMap: (value: unknown) => value is Map<any, any>;
177
+ /**
178
+ * 检查是否为 NaN - 使用 lodash-es 的实现
179
+ */
180
+ declare const isNaN: (value: unknown) => boolean;
181
+ /**
182
+ * 检查是否为 null 或 undefined - 使用 lodash-es 的实现
183
+ */
184
+ declare const isNil: (value: unknown) => value is null | undefined;
185
+ /**
186
+ * 检查是否为 null - 使用 lodash-es 的实现
187
+ */
188
+ declare const isNull: (value: unknown) => value is null;
189
+ /**
190
+ * 检查是否为数字 - 使用 lodash-es 的实现
191
+ */
192
+ declare const isNumber: (value: unknown) => value is number;
193
+ /**
194
+ * 检查是否为对象 - 使用 lodash-es 的实现
195
+ */
196
+ declare const isObject: (value: unknown) => value is object;
197
+ /**
198
+ * 检查是否为类对象 - 使用 lodash-es 的实现
199
+ */
200
+ declare const isObjectLike: (value: unknown) => boolean;
201
+ /**
202
+ * 检查是否为普通对象 - 使用 lodash-es 的实现
203
+ */
204
+ declare const isPlainObject: (value: unknown) => boolean;
205
+ /**
206
+ * 检查是否匹配对象 - 使用 lodash-es 的实现
207
+ */
208
+ declare const isMatch: (object: object, source: object) => boolean;
209
+ /**
210
+ * 检查是否为原生函数 - 使用 lodash-es 的实现
211
+ */
212
+ declare const isNative: (value: unknown) => boolean;
213
+ /**
214
+ * 检查是否为浏览器环境
215
+ */
216
+ declare function isBrowser(): boolean;
217
+ /**
218
+ * 检查是否为 Promise
219
+ */
220
+ declare function isPromise(value: unknown): value is Promise<any>;
221
+ /**
222
+ * 检查是否为 RegExp - 使用 lodash-es 的实现
223
+ */
224
+ declare const isRegExp: (value: unknown) => value is RegExp;
225
+ /**
226
+ * 检查是否为安全整数 - 使用 lodash-es 的实现
227
+ */
228
+ declare const isSafeInteger: (value: unknown) => boolean;
229
+ /**
230
+ * 检查是否为 Set - 使用 lodash-es 的实现
231
+ */
232
+ declare const isSet: (value: unknown) => value is Set<any>;
233
+ /**
234
+ * 检查是否为字符串 - 使用 lodash-es 的实现
235
+ */
236
+ declare const isString: (value: unknown) => value is string;
237
+ /**
238
+ * 检查是否为 Symbol - 使用 lodash-es 的实现
239
+ */
240
+ declare const isSymbol: (value: unknown) => value is symbol;
241
+ /**
242
+ * 检查是否为 TypedArray - 使用 lodash-es 的实现
243
+ */
244
+ declare const isTypedArray: (value: unknown) => boolean;
245
+ /**
246
+ * 检查是否为 undefined - 使用 lodash-es 的实现
247
+ */
248
+ declare const isUndefined: (value: unknown) => value is undefined;
249
+ /**
250
+ * 检查是否为 URL 对象(浏览器环境)
251
+ */
252
+ declare function isURL(value: unknown): value is URL;
253
+ /**
254
+ * 检查是否为 URLSearchParams 对象(浏览器环境)
255
+ */
256
+ declare function isURLSearchParams(value: unknown): value is URLSearchParams;
257
+ /**
258
+ * 检查是否为 WeakMap - 使用 lodash-es 的实现
259
+ */
260
+ declare const isWeakMap: (value: unknown) => value is WeakMap<object, any>;
261
+ /**
262
+ * 检查是否为 WeakSet - 使用 lodash-es 的实现
263
+ */
264
+ declare const isWeakSet: (value: unknown) => value is WeakSet<object>;
265
+ /**
266
+ * 检查是否为 Window 对象(浏览器环境)
267
+ */
268
+ declare function isWindow(value: unknown): value is Window;
269
+ /**
270
+ * 检查是否为 Document 对象(浏览器环境)
271
+ */
272
+ declare function isDocument(value: unknown): value is Document;
273
+ /**
274
+ * 检查是否为 Event 对象(浏览器环境)
275
+ */
276
+ declare function isEvent(value: unknown): value is Event;
277
+ /**
278
+ * 检查是否为 Primitive 类型
279
+ */
280
+ declare function isPrimitive(value: unknown): value is Primitive;
281
+ /**
282
+ * 检查是否为 Iterable 对象
283
+ */
284
+ declare function isIterable(value: unknown): value is Iterable<any>;
285
+ /**
286
+ * 检查是否为 AsyncIterable 对象
287
+ */
288
+ declare function isAsyncIterable(value: unknown): value is AsyncIterable<any>;
289
+ /**
290
+ * 检查是否为 Iterator 对象
291
+ */
292
+ declare function isIterator(value: unknown): value is Iterator<any>;
293
+ /**
294
+ * 检查是否为 Array Iterator
295
+ */
296
+ declare function isArrayIterator(value: unknown): boolean;
297
+ /**
298
+ * 检查是否为 Map Iterator
299
+ */
300
+ declare function isMapIterator(value: unknown): boolean;
301
+ /**
302
+ * 检查是否为 Set Iterator
303
+ */
304
+ declare function isSetIterator(value: unknown): boolean;
305
+ /**
306
+ * 检查是否为 String Iterator
307
+ */
308
+ declare function isStringIterator(value: unknown): boolean;
309
+ /**
310
+ * 检查是否为可序列化的 JSON 值
311
+ */
312
+ declare function isJSONSerializable(value: unknown): boolean;
313
+ /**
314
+ * 检查是否为有效的数组索引
315
+ */
316
+ declare function isArrayIndex(value: unknown): boolean;
317
+ /**
318
+ * 检查是否为有效的 Email 地址
319
+ */
320
+ declare function isEmail(value: unknown): value is string;
321
+ /**
322
+ * 检查是否为有效的 URL 字符串
323
+ */
324
+ declare function isURLString(value: unknown): value is string;
325
+ /**
326
+ * 检查是否为有效的手机号码(中国)
327
+ */
328
+ declare function isChinesePhone(value: unknown): value is string;
329
+ /**
330
+ * 检查是否为有效的身份证号码(中国)
331
+ */
332
+ declare function isChineseIDCard(value: unknown): value is string;
333
+ /**
334
+ * 检查是否为有效的邮政编码(中国)
335
+ */
336
+ declare function isChinesePostalCode(value: unknown): value is string;
337
+ /**
338
+ * 检查是否为有效的 JSON 字符串
339
+ */
340
+ declare function isJSONString(value: unknown): value is string;
341
+ /**
342
+ * 检查是否为 Base64 字符串
343
+ */
344
+ declare function isBase64(value: unknown): value is string;
345
+ /**
346
+ * 检查是否为 Hex 颜色值
347
+ */
348
+ declare function isHexColor(value: unknown): value is string;
349
+ /**
350
+ * 检查是否为 RGB 颜色值
351
+ */
352
+ declare function isRGBColor(value: unknown): value is string;
353
+ /**
354
+ * 检查是否为 HSL 颜色值
355
+ */
356
+ declare function isHSLColor(value: unknown): value is string;
357
+ /**
358
+ * 检查是否为有效的日期字符串
359
+ */
360
+ declare function isDateString(value: unknown): value is string;
361
+ /**
362
+ * 检查是否为有效的时间字符串
363
+ */
364
+ declare function isTimeString(value: unknown): value is string;
365
+ /**
366
+ * 检查是否为有效的日期时间字符串
367
+ */
368
+ declare function isDateTimeString(value: unknown): value is string;
369
+ /**
370
+ * 检查是否为有效的时区
371
+ */
372
+ declare function isTimezone(value: unknown): value is string;
373
+ /**
374
+ * 检查是否为有效的正则表达式字符串
375
+ */
376
+ declare function isRegExpString(value: unknown): value is string;
377
+ /**
378
+ * 检查是否为有效的 XML 字符串
379
+ */
380
+ declare function isXMLString(value: unknown): value is string;
381
+ /**
382
+ * 检查是否为有效的 HTML 字符串
383
+ */
384
+ declare function isHTMLString(value: unknown): value is string;
385
+
386
+ /**
387
+ * 生成唯一标识(时间戳 + 随机数)
388
+ * @param prefix 前缀
389
+ * @returns 唯一标识
390
+ */
391
+ declare function generateUniqueId(prefix?: string): string;
392
+
393
+ /**
394
+ * 环境变量
395
+ * @param appEnv 环境变量 import.meta.env.APP_ENV
396
+ * @returns 环境变量对象
397
+ */
398
+ declare function env(appEnv?: string): {
399
+ isDev: boolean;
400
+ isTest: boolean;
401
+ isPre: boolean;
402
+ isProd: boolean;
403
+ };
404
+
405
+ export { addFn, computeGoodsNumFn, computeGoodsWeightFn, computeNoTaxAmount2Fn, computeNoTaxAmountFn, computeNoTaxPrice2Fn, computeNoTaxPriceFn, computePrice2Fn, computePriceFn, computeTaxAmount2Fn, computeTaxAmountFn, computeTaxFn, computeTaxRateFn, computeWeightFn, divideFn, env, formatNumber, generateUniqueId, getCookie, hasCookie, isArguments, isArray, isArrayBuffer, isArrayIndex, isArrayIterator, isArrayLike, isArrayLikeObject, isAsyncFunction, isAsyncIterable, isBase64, isBigInt, isBlob, isBoolean, isBrowser, isChineseIDCard, isChinesePhone, isChinesePostalCode, isDate, isDateString, isDateTimeString, isDocument, isElement, isEmail, isEmpty, isEqual, isError, isEvent, isFile, isFinite, isFormData, isFunction, isGeneratorFunction, isHSLColor, isHTMLString, isHexColor, isInteger, isIterable, isIterator, isJSONSerializable, isJSONString, isLength, isMap, isMapIterator, isMatch, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isPrimitive, isPromise, isRGBColor, isRegExp, isRegExpString, isSafeInteger, isSameOrAfterDay, isSameOrBeforeDay, isSet, isSetIterator, isString, isStringIterator, isSymbol, isTimeString, isTimezone, isTypedArray, isURL, isURLSearchParams, isURLString, isUndefined, isWeakMap, isWeakSet, isWindow, isXMLString, multiplyFn, removeCookie, setCookie, subtractFn, sumBy, toThousands };