a-js-tools 1.0.5 → 1.0.7
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/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"name": "a-js-tools",
|
|
5
5
|
"description": "一点点 🤏 js 函数",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"a-type-of-js": "^1.0.
|
|
8
|
+
"a-type-of-js": "^1.0.4"
|
|
9
9
|
},
|
|
10
10
|
"main": "index.cjs",
|
|
11
11
|
"module": "index.mjs",
|
package/src/getRandomString.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var aTypeOfJs = require('a-type-of-js');
|
|
4
|
-
var isNode = require('./isNode.cjs');
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* 获取随机字符串
|
|
@@ -72,9 +71,7 @@ function getRandomString(options) {
|
|
|
72
71
|
if (initOptions.includeSpecial)
|
|
73
72
|
interleaveString(templateCharsArr, initOptions.chars3);
|
|
74
73
|
// 使用密码学安全的随机数生成器
|
|
75
|
-
const bytes =
|
|
76
|
-
? window.crypto.getRandomValues(new Uint8Array(initOptions.length))
|
|
77
|
-
: global.crypto.getRandomValues(new Uint8Array(initOptions.length));
|
|
74
|
+
const bytes = global.crypto.getRandomValues(new Uint8Array(initOptions.length));
|
|
78
75
|
let result = '';
|
|
79
76
|
/** 获取最后的 chars 数据 */
|
|
80
77
|
const chars = templateCharsArr.join('');
|
package/src/getRandomString.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isPlainObject, isNumber, isNaN, isUndefined } from 'a-type-of-js';
|
|
2
|
-
import { isBrowser } from './isNode.mjs';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* 获取随机字符串
|
|
@@ -70,9 +69,7 @@ function getRandomString(options) {
|
|
|
70
69
|
if (initOptions.includeSpecial)
|
|
71
70
|
interleaveString(templateCharsArr, initOptions.chars3);
|
|
72
71
|
// 使用密码学安全的随机数生成器
|
|
73
|
-
const bytes =
|
|
74
|
-
? window.crypto.getRandomValues(new Uint8Array(initOptions.length))
|
|
75
|
-
: global.crypto.getRandomValues(new Uint8Array(initOptions.length));
|
|
72
|
+
const bytes = global.crypto.getRandomValues(new Uint8Array(initOptions.length));
|
|
76
73
|
let result = '';
|
|
77
74
|
/** 获取最后的 chars 数据 */
|
|
78
75
|
const chars = templateCharsArr.join('');
|
package/src/performance.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module @a-js-tools/performance
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
|
-
type Callback = (...args:
|
|
8
|
+
type Callback = (...args: any[]) => void;
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
11
|
* 节流和防抖返回值类型
|
|
@@ -38,7 +38,7 @@ export type debounce_throttle_options = {
|
|
|
38
38
|
* }
|
|
39
39
|
*
|
|
40
40
|
*/
|
|
41
|
-
export declare function debounce<F extends
|
|
41
|
+
export declare function debounce<F extends Callback>(callback: F, options?: debounce_throttle_options): DebounceAndThrottleReturnType<F>;
|
|
42
42
|
/**
|
|
43
43
|
* 节流
|
|
44
44
|
*
|
|
@@ -46,5 +46,5 @@ export declare function debounce<F extends (...args: unknown[]) => void>(callbac
|
|
|
46
46
|
* @param options 延迟时间(毫秒),默认 200 (ms) 或设置 this
|
|
47
47
|
* @returns 返回的闭包函数
|
|
48
48
|
*/
|
|
49
|
-
export declare function throttle<F extends
|
|
49
|
+
export declare function throttle<F extends Callback>(callback: F, options?: debounce_throttle_options): DebounceAndThrottleReturnType<F>;
|
|
50
50
|
export {};
|