Global

Methods

arrayToHex(t) → {String}

Parameters:
Name Type Description
t Array 需要转换的数组
Source:
Returns:
16进制字符串
Type
String
Example

数组转16进制字符串

arrayToHex([1, 2, 3, 4]) => "01020304"

arrayToUtf8(t) → {String}

Parameters:
Name Type Description
t Array 需要转换的数组
Source:
Returns:
普通字符串
Type
String
Example
arrayToUtf8([1, 2, 3, 4]) => "1234"

compareVersion(v1, v2) → {Boolean}

Parameters:
Name Type Description
v1 String 需要比较的版本号
v2 String 最低要求的版本号
Source:
Returns:
是否满足最低要求的版本号
Type
Boolean
Example
compareVersion("1.0.0", "2.0.0") => false
compareVersion("2.0.0", "1.0.1") => true

decimalToHex(decimal, length) → {String}

Parameters:
Name Type Default Description
decimal Number 10进制数字
length Number 4 16进制字符串长度
Source:
Returns:
16进制字符串
Type
String
Example
decimalToHex(16909060) => "01020304"

filterInvisibleCharsRegex(input) → {*}

Parameters:
Name Type Description
input * 需要处理的字符串
Source:
Returns:
处理后的字符串
Type
*

getBrowserVersion() → {Object}

Source:
Returns:
浏览器内核名称及版本号
Type
Object
Example
const browserVersion = getBrowserVersion();
 console.log(browserVersion); // { name: 'Chrome', version: '87.0.0.0' }

getHexLength(hex) → {Number}

Parameters:
Name Type Description
hex String 16进制字符串
Source:
Returns:
16进制字符串长度
Type
Number
Example
getHexLength("01020304") => 4

hexToArray(t) → {Array}

Parameters:
Name Type Description
t String 需要转换的16进制字符串
Source:
Returns:
数组
Type
Array
Example
hexToArray("01020304") => [1, 2, 3, 4]

hexToDecimal(hexString) → {Number}

Parameters:
Name Type Description
hexString String 16进制字符串
Source:
Returns:
10进制数字
Type
Number
Example
hexToDecimal("01020304") => 16909060

leftPad(t, e) → {String}

Parameters:
Name Type Description
t String 需要补位的字符串
e Number 补位后的长度
Source:
Returns:
补位后的字符串
Type
String
Example
leftPad("hello", 10) => "00000hello"

paralleTasks(tasks, paralleCount) → {Promise}

Parameters:
Name Type Default Description
tasks Array.<function()> 需要处理的任务队列
paralleCount Number 2 并发数,默认为2
Source:
Returns:
返回一个Promise对象
Type
Promise
Example
async function mockAsync1() {
     await new Promise((resolve, reject) => {
         setTimeout(() => {
             resolve();
         }, 1000);
     });
     console.log("paralleTasks111");
}
async function mockAsync2() {
     await new Promise((resolve, reject) => {
         setTimeout(() => {
             resolve();
         }, 1000);
     });
     console.log("paralleTasks222");
}
paralleTasks([mockAsync1, mockAsync2], 1).then(() => {
     console.log("执行完毕");
});

parseArrayBufferToHex(t) → {String}

Parameters:
Name Type Description
t Uint8Array 需要转换的二进制数组
Source:
Returns:
16进制字符串
Type
String
Example
parseArrayBufferToHex(new Uint8Array([1, 2, 3, 4])) => "01020304"

parseHexToArrayBuffer(hexString) → {Buffer}

Parameters:
Name Type Description
hexString String 16进制字符串
Source:
Returns:
二进制数组
Type
Buffer
Example
parseHexToArrayBuffer("01020304") => new Uint8Array([1, 2, 3, 4])

parseUtf8StringToHex(t) → {String}

Parameters:
Name Type Description
t String 需要转换的字符串
Source:
Returns:
16进制字符串
Type
String
Example
parseUtf8StringToHex("你好hello") => "e4bda0e5a5bd68656c6c6f"

performChunk(datas, consumer) → {void}

Parameters:
Name Type Description
datas Array | Number 需要处理的数据,可以是数组,也可以是数字
consumer function 消费者函数,对数据的处理逻辑
Source:
Returns:
Type
void
Example
// 1. 传入数组
performChunk([1, 2, 3, 4], (item, i) => {
   console.log(item, i);
}
// 2. 传入数字
performChunk(10, (item, i) => {
  console.log(item, i);
}

processTasks(…tasks) → {*}

Parameters:
Name Type Attributes Description
tasks function <repeatable>
任务队列,每个任务无参数、异步
Source:
Returns:
Type
*

reverseHex(hex) → {String}

Parameters:
Name Type Description
hex String 16进制字符串
Source:
Returns:
调整后的16进制字符串
Type
String
Example
reverseHex("01020304") => "04030201"

useGenerateBrowserFingerprint() → {Number}

Source:
Returns:
浏览器指纹
Type
Number
Example
const fingerprint = useGenerateBrowserFingerprint(); // 1690444253