sculp-js 1.5.0 → 1.6.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.
Files changed (55) hide show
  1. package/lib/cjs/array.js +2 -21
  2. package/lib/cjs/async.js +2 -2
  3. package/lib/cjs/base64.js +62 -0
  4. package/lib/cjs/clipboard.js +2 -2
  5. package/lib/cjs/cookie.js +2 -2
  6. package/lib/cjs/date.js +2 -3
  7. package/lib/cjs/dom.js +2 -2
  8. package/lib/cjs/download.js +4 -4
  9. package/lib/cjs/easing.js +2 -2
  10. package/lib/cjs/file.js +2 -2
  11. package/lib/cjs/func.js +3 -3
  12. package/lib/cjs/index.js +15 -5
  13. package/lib/cjs/math.js +88 -0
  14. package/lib/cjs/number.js +2 -2
  15. package/lib/cjs/object.js +10 -20
  16. package/lib/cjs/path.js +2 -2
  17. package/lib/cjs/qs.js +2 -2
  18. package/lib/cjs/random.js +2 -2
  19. package/lib/cjs/string.js +2 -2
  20. package/lib/cjs/tooltip.js +2 -2
  21. package/lib/cjs/tree.js +2 -2
  22. package/lib/cjs/type.js +68 -2
  23. package/lib/cjs/unique.js +2 -2
  24. package/lib/cjs/url.js +2 -2
  25. package/lib/cjs/watermark.js +2 -2
  26. package/lib/cjs/we-decode.js +2 -2
  27. package/lib/es/array.js +3 -21
  28. package/lib/es/async.js +2 -2
  29. package/lib/es/base64.js +59 -0
  30. package/lib/es/clipboard.js +2 -2
  31. package/lib/es/cookie.js +2 -2
  32. package/lib/es/date.js +2 -3
  33. package/lib/es/dom.js +2 -2
  34. package/lib/es/download.js +4 -4
  35. package/lib/es/easing.js +2 -2
  36. package/lib/es/file.js +2 -2
  37. package/lib/es/func.js +3 -3
  38. package/lib/es/index.js +8 -6
  39. package/lib/es/math.js +82 -0
  40. package/lib/es/number.js +2 -2
  41. package/lib/es/object.js +9 -18
  42. package/lib/es/path.js +2 -2
  43. package/lib/es/qs.js +2 -2
  44. package/lib/es/random.js +2 -2
  45. package/lib/es/string.js +2 -2
  46. package/lib/es/tooltip.js +2 -2
  47. package/lib/es/tree.js +2 -2
  48. package/lib/es/type.js +66 -3
  49. package/lib/es/unique.js +2 -2
  50. package/lib/es/url.js +2 -2
  51. package/lib/es/watermark.js +2 -2
  52. package/lib/es/we-decode.js +2 -2
  53. package/lib/index.d.ts +93 -16
  54. package/lib/umd/index.js +320 -151
  55. package/package.json +2 -2
package/lib/index.d.ts CHANGED
@@ -9,6 +9,20 @@ type AnyObject = Record<string | number, any>;
9
9
  type PartialDeep<T> = {
10
10
  [P in keyof T]?: PartialDeep<T[P]>;
11
11
  };
12
+ /**
13
+ * 判断对象内是否有该静态属性
14
+ * @param {object} obj
15
+ * @param {string} key
16
+ * @returns {boolean}
17
+ */
18
+ declare function objectHas<T extends AnyObject>(obj: T, key: keyof T): boolean;
19
+ /**
20
+ * 判断一个对象是否为类数组
21
+ *
22
+ * @param any
23
+ * @returns {boolean}
24
+ */
25
+ declare function arrayLike(any: unknown): boolean;
12
26
  /**
13
27
  * 判断任意值的数据类型
14
28
  * @param {unknown} any
@@ -42,14 +56,37 @@ declare const isRegExp: (any: unknown) => any is RegExp;
42
56
  * @return {Object | boolean}
43
57
  */
44
58
  declare function isJsonString(str: string): Object | boolean;
45
-
46
59
  /**
47
- * 判断一个对象是否为类数组
60
+ * Checks if `value` is an empty object, collection, map, or set.
48
61
  *
49
- * @param any
50
- * @returns {boolean}
62
+ * Objects are considered empty if they have no own enumerable string keyed
63
+ * properties.
64
+ *
65
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
66
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
67
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
68
+ *
69
+ * @param {*} value The value to check.
70
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
71
+ * @example
72
+ *
73
+ * _.isEmpty(null);
74
+ * // => true
75
+ *
76
+ * _.isEmpty(true);
77
+ * // => true
78
+ *
79
+ * _.isEmpty(1);
80
+ * // => true
81
+ *
82
+ * _.isEmpty([1, 2, 3]);
83
+ * // => false
84
+ *
85
+ * _.isEmpty({ 'a': 1 });
86
+ * // => false
51
87
  */
52
- declare function arrayLike(any: unknown): boolean;
88
+ declare function isEmpty(value: any): boolean;
89
+
53
90
  /**
54
91
  * 遍历数组,返回 false 中断遍历(支持continue和break操作)
55
92
  *
@@ -156,7 +193,6 @@ declare function dateToEnd(value: DateValue): Date;
156
193
  * - DD:日
157
194
  * - dd: 日
158
195
  * - HH:时(24 小时制)
159
- * - hh:时(12 小时制)
160
196
  * - mm:分
161
197
  * - ss:秒
162
198
  * - SSS:毫秒
@@ -300,7 +336,7 @@ declare function downloadBlob(blob: Blob, filename: string, callback?: Function)
300
336
  * @param {string} filename
301
337
  * @param {Function} callback
302
338
  */
303
- declare function crossDomainDownload(url: string, filename: string, callback?: Function): void;
339
+ declare function crossOriginDownload(url: string, filename: string, callback?: Function): void;
304
340
  type FileType = 'json' | 'csv' | 'xls' | 'xlsx';
305
341
  /**
306
342
  * 将指定数据格式通过 A 链接的方式下载
@@ -317,13 +353,6 @@ declare function downloadData(data: AnyObject | AnyObject[], fileType: FileType,
317
353
  * @returns {boolean}
318
354
  */
319
355
  declare const isPlainObject: (obj: unknown) => boolean;
320
- /**
321
- * 判断对象内是否有该静态属性
322
- * @param {object} obj
323
- * @param {string} key
324
- * @returns {boolean}
325
- */
326
- declare function objectHas<T extends AnyObject>(obj: T, key: keyof T): boolean;
327
356
  /**
328
357
  * 遍历对象,返回 false 中断遍历
329
358
  * @param {O} obj
@@ -616,7 +645,7 @@ declare const once: <F extends AnyFunc = AnyFunc>(func: F) => OnceFunc<F>;
616
645
  */
617
646
  declare function setGlobal(key: string | number | symbol, val?: any): void;
618
647
  /**
619
- * 设置全局变量
648
+ * 获取全局变量
620
649
  * @param {string | number | symbol} key
621
650
  * @param val
622
651
  */
@@ -829,6 +858,41 @@ declare function flatTree(treeList: any[], options?: IFieldOptions): any[];
829
858
  */
830
859
  declare function fuzzySearchTree(nodes: any[], query: string, options?: ISearchTreeOpts): any[];
831
860
 
861
+ /**
862
+ * 数值安全乘法
863
+ * @param arg1 数值1
864
+ * @param arg2 数值2
865
+ */
866
+ declare const multiply: (arg1: number, arg2: number) => number;
867
+ /**
868
+ * 数值安全加法
869
+ * @param arg1 数值1
870
+ * @param arg2 数值2
871
+ */
872
+ declare const add: (arg1: number, arg2: number) => number;
873
+ /**
874
+ * 数值安全减法
875
+ * @param arg1 数值1
876
+ * @param arg2 数值2
877
+ */
878
+ declare const subtract: (arg1: number, arg2: number) => number;
879
+ /**
880
+ * 数值安全除法
881
+ * @param arg1 数值1
882
+ * @param arg2 数值2
883
+ */
884
+ declare const divide: (arg1: number, arg2: number) => number;
885
+ type NumberType = number | string;
886
+ /**
887
+ * Correct the given number to specifying significant digits.
888
+ *
889
+ * @param num The input number
890
+ * @param precision An integer specifying the number of significant digits
891
+ *
892
+ * @example strip(0.09999999999999998) === 0.1 // true
893
+ */
894
+ declare function strip(num: NumberType, precision?: number): number;
895
+
832
896
  /**
833
897
  * 字符串编码成Base64 (适用于任何环境,包括小程序)
834
898
  * @param {string} string
@@ -842,4 +906,17 @@ declare function weBtoa(string: string): string;
842
906
  */
843
907
  declare function weAtob(string: string): string;
844
908
 
845
- export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, type DateObj, type DateValue, type DebounceFunc, type FileType, HEX_POOL, type ICanvasWM, type ICompressOptions, type IFieldOptions, type ISearchTreeOpts, type ITreeConf, type IdLike, type LooseParamValue, type LooseParams, type ObjectAssignItem, type OnceFunc, type Params, type PartialDeep, type RandomString, type ReadyCallback, type Replacer, STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_POOL, STRING_UPPERCASE_ALPHA, type SetStyle, type SmoothScrollOptions, type Style, type ThrottleFunc, UNIQUE_NUMBER_SAFE_LENGTH, type UniqueString, type Url, type WithChildren, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, buildTree, calculateDate, calculateDateTime, chooseLocalFile, cloneDeep, compressImg, cookieDel, cookieGet, cookieSet, copyText, crossDomainDownload, dateParse, dateToEnd, dateToStart, debounce, downloadBlob, downloadData, downloadHref, downloadURL, flatTree, forEachDeep, forEachMap, formatDate, formatNumber, formatTree, fuzzySearchTree, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, hasClass, isArray, isBigInt, isBoolean, isDate, isDomReady, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPlainObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, isValidDate, numberAbbr, numberToHex, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick, onDomReady, once, parseQueryParams, pathJoin, pathNormalize, qsParse, qsStringify, randomNumber, randomString, randomUuid, removeClass, searchTreeById, setGlobal, setStyle, smoothScroll, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase, supportCanvas, throttle, tooltipEvent, typeIs, uniqueNumber, uniqueString, urlDelParams, urlParse, urlSetParams, urlStringify, wait, weAtob, weBtoa };
909
+ /**
910
+ * 将base64编码的字符串转换为原始字符串,包括对中文内容的处理(高性能,且支持Web、Node、小程序等任意平台)
911
+ * @param base64 base64编码的字符串
912
+ * @returns 原始字符串,包括中文内容
913
+ */
914
+ declare function decodeFromBase64(base64: string): string;
915
+ /**
916
+ * 将原始字符串,包括中文内容,转换为base64编码的字符串(高性能,且支持Web、Node、小程序等任意平台)
917
+ * @param rawStr 原始字符串,包括中文内容
918
+ * @returns base64编码的字符串
919
+ */
920
+ declare function encodeToBase64(rawStr: string): string;
921
+
922
+ export { type AnyArray, type AnyFunc, type AnyObject, type ArrayElements, type DateObj, type DateValue, type DebounceFunc, type FileType, HEX_POOL, type ICanvasWM, type ICompressOptions, type IFieldOptions, type ISearchTreeOpts, type ITreeConf, type IdLike, type LooseParamValue, type LooseParams, type ObjectAssignItem, type OnceFunc, type Params, type PartialDeep, type RandomString, type ReadyCallback, type Replacer, STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_POOL, STRING_UPPERCASE_ALPHA, type SetStyle, type SmoothScrollOptions, type Style, type ThrottleFunc, UNIQUE_NUMBER_SAFE_LENGTH, type UniqueString, type Url, type WithChildren, add, addClass, arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove, asyncMap, buildTree, calculateDate, calculateDateTime, chooseLocalFile, cloneDeep, compressImg, cookieDel, cookieGet, cookieSet, copyText, crossOriginDownload, dateParse, dateToEnd, dateToStart, debounce, decodeFromBase64, divide, downloadBlob, downloadData, downloadHref, downloadURL, encodeToBase64, flatTree, forEachDeep, forEachMap, formatDate, formatNumber, formatTree, fuzzySearchTree, genCanvasWM, getComputedCssVal, getGlobal, getStrWidthPx, getStyle, hasClass, isArray, isBigInt, isBoolean, isDate, isDomReady, isEmpty, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPlainObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, isValidDate, multiply, numberAbbr, numberToHex, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick, onDomReady, once, parseQueryParams, pathJoin, pathNormalize, qsParse, qsStringify, randomNumber, randomString, randomUuid, removeClass, searchTreeById, setGlobal, setStyle, smoothScroll, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase, strip, subtract, supportCanvas, throttle, tooltipEvent, typeIs, uniqueNumber, uniqueString, urlDelParams, urlParse, urlSetParams, urlStringify, wait, weAtob, weBtoa };